mirror of
https://github.com/openSUSE/snapper.git
synced 2026-02-05 06:46:08 +01:00
- avoid some integer conversions
This commit is contained in:
@@ -150,7 +150,7 @@ namespace DBus
|
||||
}
|
||||
|
||||
|
||||
unsigned long
|
||||
uid_t
|
||||
Connection::get_unix_userid(const Message& m)
|
||||
{
|
||||
boost::lock_guard<boost::mutex> lock(mutex);
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace DBus
|
||||
void add_match(const string& rule) { add_match(rule.c_str()); }
|
||||
void remove_match(const string& rule) { remove_match(rule.c_str()); }
|
||||
|
||||
unsigned long get_unix_userid(const Message& m);
|
||||
uid_t get_unix_userid(const Message& m);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -321,10 +321,10 @@ static int snap_struct_unpack(DBusMessageIter *iter,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void snap_array_free(int32_t num_snaps,
|
||||
static void snap_array_free(uint32_t num_snaps,
|
||||
struct snap *snaps)
|
||||
{
|
||||
int i;
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < num_snaps; i++) {
|
||||
free(snaps[i].user_data);
|
||||
@@ -332,10 +332,10 @@ static void snap_array_free(int32_t num_snaps,
|
||||
free(snaps);
|
||||
}
|
||||
|
||||
static void snap_array_print(int32_t num_snaps,
|
||||
static void snap_array_print(uint32_t num_snaps,
|
||||
struct snap *snaps)
|
||||
{
|
||||
int i;
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < num_snaps; i++) {
|
||||
printf("id: %u\n"
|
||||
@@ -543,10 +543,10 @@ static int conf_struct_unpack(DBusMessageIter *iter,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void conf_array_free(int32_t num_confs,
|
||||
static void conf_array_free(uint32_t num_confs,
|
||||
struct config *confs)
|
||||
{
|
||||
int i;
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < num_confs; i++) {
|
||||
free(confs[i].attrs);
|
||||
@@ -554,10 +554,10 @@ static void conf_array_free(int32_t num_confs,
|
||||
free(confs);
|
||||
}
|
||||
|
||||
static void conf_array_print(int32_t num_confs,
|
||||
static void conf_array_print(uint32_t num_confs,
|
||||
struct config *confs)
|
||||
{
|
||||
int i;
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < num_confs; i++) {
|
||||
printf("name: %s\n"
|
||||
|
||||
@@ -425,8 +425,8 @@ static int forker( pam_handle_t * pamh, const char *pam_user, uid_t uid, gid_t g
|
||||
}
|
||||
}
|
||||
|
||||
static void fill_user_data( pam_handle_t * pamh, struct dict ( *user_data )[], int *num_user_data,
|
||||
int max_user_data )
|
||||
static void fill_user_data( pam_handle_t * pamh, struct dict ( *user_data )[],
|
||||
uint32_t * num_user_data, uint32_t max_user_data )
|
||||
{
|
||||
int fields[4] = { PAM_RUSER, PAM_RHOST, PAM_TTY, PAM_SERVICE };
|
||||
const char *names[4] = { "ruser", "rhost", "tty", "service" };
|
||||
@@ -472,9 +472,9 @@ static int get_ugid( pam_handle_t * pamh, const char *pam_user, uid_t * uid, gid
|
||||
static int worker( pam_handle_t * pamh, const char *pam_user, const char *snapper_conf,
|
||||
createmode_t createmode, const char *cleanup )
|
||||
{
|
||||
const int max_user_data = 5;
|
||||
const uint32_t max_user_data = 5;
|
||||
struct dict user_data[max_user_data];
|
||||
int num_user_data = 0;
|
||||
uint32_t num_user_data = 0;
|
||||
fill_user_data( pamh, &user_data, &num_user_data, max_user_data );
|
||||
|
||||
uid_t uid;
|
||||
@@ -500,8 +500,7 @@ static int worker( pam_handle_t * pamh, const char *pam_user, const char *snappe
|
||||
}
|
||||
|
||||
if ( forker( pamh, pam_user, uid, gid, snapper_conf, createmode, cleanup, num_user_data,
|
||||
user_data, snapshot_num_in, snapshot_num_out ) != 0 )
|
||||
{
|
||||
user_data, snapshot_num_in, snapshot_num_out ) != 0 ) {
|
||||
free( snapshot_num_out );
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -106,11 +106,11 @@ namespace snapper
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
ssize_t
|
||||
readlink(const string& path, string& buf)
|
||||
{
|
||||
char tmp[1024];
|
||||
int ret = ::readlink(path.c_str(), tmp, sizeof(tmp));
|
||||
ssize_t ret = ::readlink(path.c_str(), tmp, sizeof(tmp));
|
||||
if (ret >= 0)
|
||||
buf = string(tmp, ret);
|
||||
return ret;
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace snapper
|
||||
bool clonefile(int src_fd, int dest_fd);
|
||||
bool copyfile(int src_fd, int dest_fd);
|
||||
|
||||
int readlink(const string& path, string& buf);
|
||||
ssize_t readlink(const string& path, string& buf);
|
||||
int symlink(const string& oldpath, const string& newpath);
|
||||
|
||||
string realpath(const string& path);
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace snapper
|
||||
{
|
||||
off_t t = min(block_size, length);
|
||||
|
||||
int r1 = read(fd1, block1, t);
|
||||
ssize_t r1 = read(fd1, block1, t);
|
||||
if (r1 != t)
|
||||
{
|
||||
y2err("read failed path:" << file1.fullname() << " errno:" << errno);
|
||||
@@ -102,7 +102,7 @@ namespace snapper
|
||||
break;
|
||||
}
|
||||
|
||||
int r2 = read(fd2, block2, t);
|
||||
ssize_t r2 = read(fd2, block2, t);
|
||||
if (r2 != t)
|
||||
{
|
||||
y2err("read failed path:" << file2.fullname() << " errno:" << errno);
|
||||
|
||||
@@ -287,14 +287,14 @@ namespace snapper
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
ssize_t
|
||||
SDir::readlink(const string& name, string& buf) const
|
||||
{
|
||||
assert(name.find('/') == string::npos);
|
||||
assert(name != "..");
|
||||
|
||||
char tmp[1024];
|
||||
int ret = ::readlinkat(dirfd, name.c_str(), tmp, sizeof(tmp));
|
||||
ssize_t ret = ::readlinkat(dirfd, name.c_str(), tmp, sizeof(tmp));
|
||||
if (ret >= 0)
|
||||
buf = string(tmp, ret);
|
||||
return ret;
|
||||
@@ -600,7 +600,7 @@ namespace snapper
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
ssize_t
|
||||
SFile::readlink(string& buf) const
|
||||
{
|
||||
return dir.readlink(name, buf);
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace snapper
|
||||
int stat(const string& name, struct stat* buf, int flags) const;
|
||||
int open(const string& name, int flags) const;
|
||||
int open(const string& name, int flags, mode_t mode) const;
|
||||
int readlink(const string& name, string& buf) const;
|
||||
ssize_t readlink(const string& name, string& buf) const;
|
||||
int mkdir(const string& name, mode_t mode) const;
|
||||
int unlink(const string& name, int flags) const;
|
||||
int chmod(const string& name, mode_t mode, int flags) const;
|
||||
@@ -126,7 +126,7 @@ namespace snapper
|
||||
|
||||
int stat(struct stat* buf, int flags) const;
|
||||
int open(int flags) const;
|
||||
int readlink(string& buf) const;
|
||||
ssize_t readlink(string& buf) const;
|
||||
int chmod(mode_t mode, int flags) const;
|
||||
|
||||
bool xaSupported() const;
|
||||
|
||||
Reference in New Issue
Block a user