Avoid compiler casting warnings Part 2

This saves instructions that are related to casting as well as compiler warnings.
This commit is contained in:
Rose
2023-05-18 14:38:18 -04:00
parent f2a274b061
commit 22079c3072
21 changed files with 44 additions and 45 deletions

View File

@@ -321,7 +321,7 @@ mon_backchannel_cb(int fd, int what, void *v)
* Note that the backchannel is a *blocking* socket.
*/
n = recv(fd, &cstmp, sizeof(cstmp), MSG_WAITALL);
if (n != sizeof(cstmp)) {
if (n != ssizeof(cstmp)) {
if (n == -1) {
if (errno == EINTR || errno == EAGAIN)
debug_return;

View File

@@ -671,11 +671,11 @@ set_policy_rlimits(void)
debug_return;
}
int
serialize_rlimits(char **info, unsigned int info_max)
size_t
serialize_rlimits(char **info, size_t info_max)
{
char *str;
unsigned int idx, nstored = 0;
size_t idx, nstored = 0;
debug_decl(serialize_rlimits, SUDO_DEBUG_UTIL);
for (idx = 0; idx < nitems(saved_limits); idx++) {
@@ -706,9 +706,9 @@ serialize_rlimits(char **info, unsigned int info_max)
goto oom;
info[nstored++] = str;
}
debug_return_int(nstored);
debug_return_size_t(nstored);
oom:
while (nstored)
free(info[--nstored]);
debug_return_int(-1);
debug_return_size_t(-1);
}

View File

@@ -157,7 +157,7 @@ main(int argc, char *argv[], char *envp[])
/* Read sudo.conf and initialize the debug subsystem. */
if (sudo_conf_read(NULL, SUDO_CONF_DEBUG) == -1)
exit(EXIT_FAILURE);
return EXIT_FAILURE;
sudo_debug_register(getprogname(), NULL, NULL,
sudo_conf_debug_files(getprogname()), -1);
@@ -197,7 +197,7 @@ main(int argc, char *argv[], char *envp[])
if (rundir != NULL && chdir(rundir) == -1) {
sudo_warnx(U_("unable to change directory to %s"), rundir);
if (!ISSET(flags, CD_CWD_OPTIONAL))
exit(EXIT_FAILURE);
return EXIT_FAILURE;
}
/* Make a copy of the command to execute. */

View File

@@ -500,11 +500,11 @@ static char **
get_user_info(struct user_details *ud)
{
char *cp, **info, path[PATH_MAX];
unsigned int info_max = 32 + RLIM_NLIMITS;
unsigned int i = 0;
size_t info_max = 32 + RLIM_NLIMITS;
size_t i = 0, n;
mode_t mask;
struct passwd *pw;
int ttyfd, n;
int ttyfd;
debug_decl(get_user_info, SUDO_DEBUG_UTIL);
/*
@@ -629,7 +629,7 @@ get_user_info(struct user_details *ud)
goto oom;
n = serialize_rlimits(&info[i + 1], info_max - (i + 1));
if (n == -1)
if (n == (size_t)-1)
goto oom;
i += n;

View File

@@ -343,7 +343,7 @@ void restore_nproc(void);
void set_policy_rlimits(void);
void unlimit_nproc(void);
void unlimit_sudo(void);
int serialize_rlimits(char **info, unsigned int info_max);
size_t serialize_rlimits(char **info, size_t info_max);
bool parse_policy_rlimit(const char *str);
/* exec_ptrace.c */

View File

@@ -71,7 +71,7 @@ set_tmpdir(const struct sudo_cred *user_cred)
_PATH_TMP
};
struct sudo_cred saved_cred;
unsigned int i;
size_t i;
size_t len;
int dfd;
debug_decl(set_tmpdir, SUDO_DEBUG_EDIT);