From 3ed5d021837768405d9f9c9e7d2b05dc6a110d94 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Wed, 10 Sep 2014 13:46:04 +0000 Subject: [PATCH] Fix compilation warnings reported by gcc -Wsign-compare * configure.ac (gl_WARN_ADD): Add -Wsign-compare. * defs.h (struct tcb): Change 'currpers' type to unsigned. (struct xlat): Change 'val' type to unsigned (signame): Add 'const' qualifier to its argument. (xlookup, printxval): Add 'const' qualifier to the 2nd argument and change its type to unsigned. (printpathn): Change the 3rd argument type to unsigned. (ioctl_lookup): Change 1st argument type to unsigned. * count.c (call_summary_pers, call_summary): Change 'i' type to unsigned. * file.c (print_xattr_list): Fix comparisons between signed and unsigned long values. * ioctl.c (compare): Fix cast. (ioctl_lookup): Change 1st argument type to to unsigned. (ioctl_next_match): Change 'code' type to unsigned. * mem.c (sys_move_pages): Change 'i' type to unsigned. * mtd.c (mtd_ioctl): Change 'i' and 'j' types to unsigned. Print 'i' using %u format string. * process.c (sys_prctl): Change 'i' type to unsigned. (printargv): Change 'n' type to unsigned. (sys_ptrace): Change 'addr' type to unsigned. * scsi.c (print_sg_io_buffer): Add 'const' qualifier to 'len' argument and change its type to unsigned. Change 'i' and 'allocated' types to unsigned. * signal.c (signame): Add 'const' qualifier to its argument. Fix comparisons between signed and unsigned values. (sprintsigmask_n, printsiginfo): Fix comparisons between signed and unsigned values. * sock.c (sock_ioctl): Change 'i' and 'nifra' types to unsigned. * strace.c (expand_tcbtab, alloctcb): Change 'i' type to unsigned. (detach): Change 'sig' type to unsigned. (startup_attach): Change 'tcbi' type to unsigned. (startup_child): Change 'm', 'n', and 'len' types to unsigned. (init): Use new variable to iterate 'tcbtab'. (pid2tcb): Change 'i' type to unsigned. (cleanup): Change 'i' and 'sig' types to unsigned. * syscall.c (update_personality): Change 'personality' argument type to unsigned. (struct qual_options): Change 'bitflag' type to unsigned. (reallocate_qual): Add 'const' qualifier to its argument and change its type to unsigned. (qualify_one): Change 'n' and 'bitflag' arguments types to unsigned. Add 'const' qualifier to 'n', 'not', and 'pers' arguments. Change 'p' type to signed int. (qual_syscall): Change 'bitflag' argument type to unsigned. Add 'const' qualifier to 'bitflag' and 'not' arguments. Change 'p' type to signed int. (qual_signal): Change 'bitflag' argument type to unsigned. Add 'const' qualifier to 'bitflag' and 'not' arguments. Change 'i' type to unsigned. (qual_desc): Change 'bitflag' argument type to unsigned. Add 'const' qualifier to 'bitflag' and 'not' arguments. (qualify): Change 'i' type to unsigned. (get_scno): Change 'currpers' type to unsigned. Fix a comparison between signed and unsigned values. * system.c (sys_sysctl): Change 'cnt' and 'max_cnt' types to unsigned. Fix comparisons between signed and unsigned values. * util.c (xlookup, printxval): Add 'const' qualifier to 'val' argument and change its type to unsigned. (printuid): Fix a comparison between signed and unsigned values. (printpathn): Change 'n' argument type to unsigned. (printstr): Change 'size' type to unsigned. Fix a comparison between signed and unsigned values. (setbpt): Change 'i' type to unsigned. * net.c (printsock): Silence a compilation warning. * reboot.c (sys_reboot): Likewise. --- configure.ac | 1 + count.c | 4 ++-- defs.h | 14 +++++++------- file.c | 3 ++- ioctl.c | 6 +++--- mem.c | 6 +++--- mtd.c | 4 ++-- net.c | 2 +- process.c | 6 +++--- reboot.c | 2 +- scsi.c | 7 +++---- signal.c | 24 ++++++++++++++---------- sock.c | 4 ++-- strace.c | 28 +++++++++++++++------------- syscall.c | 41 +++++++++++++++++++++-------------------- system.c | 6 +++--- util.c | 14 +++++++------- 17 files changed, 90 insertions(+), 82 deletions(-) diff --git a/configure.ac b/configure.ac index 52c1ecf6..6fe83cfb 100644 --- a/configure.ac +++ b/configure.ac @@ -164,6 +164,7 @@ AC_DEFINE_UNQUOTED([ENABLE_ARM_OABI], [$enable_arm_oabi], gl_WARN_ADD([-Wall]) gl_WARN_ADD([-Wwrite-strings]) +gl_WARN_ADD([-Wsign-compare]) AC_ARG_ENABLE([gcc-Werror], [AS_HELP_STRING([--enable-gcc-Werror], [turn on gcc's -Werror option])], [case $enableval in diff --git a/count.c b/count.c index e41994d3..25921b25 100644 --- a/count.c +++ b/count.c @@ -156,7 +156,7 @@ void set_overhead(int n) static void call_summary_pers(FILE *outf) { - int i; + unsigned int i; int call_cum, error_cum; struct timeval tv_cum, dtv; double float_tv_cum; @@ -230,7 +230,7 @@ call_summary_pers(FILE *outf) void call_summary(FILE *outf) { - int i, old_pers = current_personality; + unsigned int i, old_pers = current_personality; for (i = 0; i < SUPPORTED_PERSONALITIES; ++i) { if (!countv[i]) diff --git a/defs.h b/defs.h index 625cac67..396e5196 100644 --- a/defs.h +++ b/defs.h @@ -414,7 +414,7 @@ struct tcb { #endif long u_rval; /* Return value */ #if SUPPORTED_PERSONALITIES > 1 - int currpers; /* Personality at the time of scno update */ + unsigned int currpers; /* Personality at the time of scno update */ #endif int curcol; /* Output column for this process */ FILE *outf; /* Output file for this process */ @@ -508,7 +508,7 @@ typedef uint8_t qualbits_t; #define filtered(tcp) ((tcp)->flags & TCB_FILTERED) struct xlat { - int val; + unsigned int val; const char *str; }; #define XLAT(x) { x, #x } @@ -642,12 +642,12 @@ extern long getrval2(struct tcb *); extern int setbpt(struct tcb *); extern int clearbpt(struct tcb *); -extern const char *signame(int); +extern const char *signame(const int); extern void pathtrace_select(const char *); extern int pathtrace_match(struct tcb *); extern int getfdpath(struct tcb *, int, char *, unsigned); -extern const char *xlookup(const struct xlat *, int); +extern const char *xlookup(const struct xlat *, const unsigned int); extern int string_to_uint(const char *str); extern int string_quote(const char *, char *, long, int); @@ -665,7 +665,7 @@ extern int next_set_bit(const void *bit_array, unsigned cur_bit, unsigned size_b #endif extern int printllval(struct tcb *, const char *, int); -extern void printxval(const struct xlat *, int, const char *); +extern void printxval(const struct xlat *, const unsigned int, const char *); extern int printargs(struct tcb *); extern int printargs_lu(struct tcb *); extern int printargs_ld(struct tcb *); @@ -678,7 +678,7 @@ extern void printstr(struct tcb *, long, long); extern void printnum(struct tcb *, long, const char *); extern void printnum_int(struct tcb *, long, const char *); extern void printpath(struct tcb *, long); -extern void printpathn(struct tcb *, long, int); +extern void printpathn(struct tcb *, long, unsigned int); #define TIMESPEC_TEXT_BUFSIZE (sizeof(long)*3 * 2 + sizeof("{%u, %u}")) #define TIMEVAL_TEXT_BUFSIZE TIMESPEC_TEXT_BUFSIZE extern void printtv_bitness(struct tcb *, long, enum bitness_t, int); @@ -710,7 +710,7 @@ extern void tprint_open_modes(mode_t); extern const char *sprint_open_modes(mode_t); extern void print_loff_t(struct tcb *, long); -extern const struct_ioctlent *ioctl_lookup(long); +extern const struct_ioctlent *ioctl_lookup(unsigned long); extern const struct_ioctlent *ioctl_next_match(const struct_ioctlent *); extern int ioctl_decode(struct tcb *, long, long); extern int term_ioctl(struct tcb *, long, long); diff --git a/file.c b/file.c index 47ca2302..f788bd69 100644 --- a/file.c +++ b/file.c @@ -2202,7 +2202,8 @@ print_xattr_list(struct tcb *tcp, unsigned long addr, unsigned long size) tprints("NULL"); } else { unsigned long len = - (size < tcp->u_rval) ? size : tcp->u_rval; + (size < (unsigned long) tcp->u_rval) ? + size : (unsigned long) tcp->u_rval; printstr(tcp, addr, len); } } diff --git a/ioctl.c b/ioctl.c index 3f6c410b..99b31fb0 100644 --- a/ioctl.c +++ b/ioctl.c @@ -34,13 +34,13 @@ static int compare(const void *a, const void *b) { - unsigned long code1 = (long) a; + unsigned long code1 = (unsigned long) a; unsigned long code2 = ((struct_ioctlent *) b)->code; return (code1 > code2) ? 1 : (code1 < code2) ? -1 : 0; } const struct_ioctlent * -ioctl_lookup(long code) +ioctl_lookup(unsigned long code) { struct_ioctlent *iop; @@ -60,7 +60,7 @@ ioctl_lookup(long code) const struct_ioctlent * ioctl_next_match(const struct_ioctlent *iop) { - long code; + unsigned long code; code = iop->code; iop++; diff --git a/mem.c b/mem.c index 6ecd363c..28f744fb 100644 --- a/mem.c +++ b/mem.c @@ -481,7 +481,7 @@ sys_move_pages(struct tcb *tcp) if (tcp->u_arg[2] == 0) tprints("NULL, "); else { - int i; + unsigned int i; long puser = tcp->u_arg[2]; tprints("{"); for (i = 0; i < npages; ++i) { @@ -500,7 +500,7 @@ sys_move_pages(struct tcb *tcp) if (tcp->u_arg[3] == 0) tprints("NULL, "); else { - int i; + unsigned int i; long nodeuser = tcp->u_arg[3]; tprints("{"); for (i = 0; i < npages; ++i) { @@ -522,7 +522,7 @@ sys_move_pages(struct tcb *tcp) if (tcp->u_arg[4] == 0) tprints("NULL, "); else { - int i; + unsigned int i; long statususer = tcp->u_arg[4]; tprints("{"); for (i = 0; i < npages; ++i) { diff --git a/mtd.c b/mtd.c index 8ba658b5..88e8dbcc 100644 --- a/mtd.c +++ b/mtd.c @@ -60,7 +60,7 @@ int mtd_ioctl(struct tcb *tcp, long code, long arg) struct mtd_write_req mreq; struct nand_oobinfo ninfo; struct nand_ecclayout_user nlay; - int i, j; + unsigned int i, j; if (entering(tcp)) return 0; @@ -235,7 +235,7 @@ int mtd_ioctl(struct tcb *tcp, long code, long arg) if (!verbose(tcp) || umove(tcp, arg, &i) < 0) return 0; - tprintf(", [%d]", i); + tprintf(", [%u]", i); return 1; case MTDFILEMODE: diff --git a/net.c b/net.c index 7b899170..46c491f8 100644 --- a/net.c +++ b/net.c @@ -189,7 +189,7 @@ printsock(struct tcb *tcp, long addr, int addrlen) return; } - if (addrlen < 2 || addrlen > sizeof(addrbuf)) + if (addrlen < 2 || addrlen > (int) sizeof(addrbuf)) addrlen = sizeof(addrbuf); memset(&addrbuf, 0, sizeof(addrbuf)); diff --git a/process.c b/process.c index 2cd0f01f..e465319e 100644 --- a/process.c +++ b/process.c @@ -131,7 +131,7 @@ unalignctl_string(unsigned int ctl) int sys_prctl(struct tcb *tcp) { - int i; + unsigned int i; if (entering(tcp)) { printxval(prctl_options, tcp->u_arg[0], "PR_???"); @@ -726,7 +726,7 @@ printargv(struct tcb *tcp, long addr) char data[sizeof(long)]; } cp; const char *sep; - int n = 0; + unsigned int n = 0; unsigned wordsize = current_wordsize; cp.p64 = 1; @@ -2103,7 +2103,7 @@ int sys_ptrace(struct tcb *tcp) { const struct xlat *x; - long addr; + unsigned long addr; if (entering(tcp)) { printxval(ptrace_cmds, tcp->u_arg[0], "PTRACE_???"); diff --git a/reboot.c b/reboot.c index 397a1269..e3fa77a9 100644 --- a/reboot.c +++ b/reboot.c @@ -16,7 +16,7 @@ sys_reboot(struct tcb *tcp) printflags(bootflags2, tcp->u_arg[1], "LINUX_REBOOT_MAGIC_???"); tprints(", "); printflags(bootflags3, tcp->u_arg[2], "LINUX_REBOOT_CMD_???"); - if (tcp->u_arg[2] == LINUX_REBOOT_CMD_RESTART2) { + if (tcp->u_arg[2] == (long) LINUX_REBOOT_CMD_RESTART2) { tprints(", "); printstr(tcp, tcp->u_arg[3], -1); } diff --git a/scsi.c b/scsi.c index 2aa4c7b3..a2e23c8b 100644 --- a/scsi.c +++ b/scsi.c @@ -36,16 +36,15 @@ #include "xlat/sg_io_dxfer_direction.h" static void -print_sg_io_buffer(struct tcb *tcp, unsigned char *addr, int len) +print_sg_io_buffer(struct tcb *tcp, unsigned char *addr, const unsigned int len) { unsigned char *buf = NULL; - int allocated, i; + unsigned int allocated, i; if (len == 0) return; allocated = (len > max_strlen) ? max_strlen : len; - if (len < 0 || - (buf = malloc(allocated)) == NULL || + if ((buf = malloc(allocated)) == NULL || umoven(tcp, (unsigned long) addr, allocated, (char *) buf) < 0) { tprintf("%p", addr); free(buf); diff --git a/signal.c b/signal.c index f6eeed0e..74e0fd90 100644 --- a/signal.c +++ b/signal.c @@ -144,18 +144,22 @@ struct sigcontext { */ const char * -signame(int sig) +signame(const int sig) { - static char buf[sizeof("SIGRT_%d") + sizeof(int)*3]; + static char buf[sizeof("SIGRT_%u") + sizeof(int)*3]; - if (sig >= 0 && sig < nsignals) - return signalent[sig]; + if (sig >= 0) { + const unsigned int s = sig; + + if (s < nsignals) + return signalent[s]; #ifdef SIGRTMIN - if (sig >= __SIGRTMIN && sig <= __SIGRTMAX) { - sprintf(buf, "SIGRT_%d", (int)(sig - __SIGRTMIN)); - return buf; - } + if (s >= __SIGRTMIN && s <= __SIGRTMAX) { + sprintf(buf, "SIGRT_%u", s - __SIGRTMIN); + return buf; + } #endif + } sprintf(buf, "%d", sig); return buf; } @@ -217,7 +221,7 @@ sprintsigmask_n(const char *prefix, const void *sig_mask, unsigned int bytes) for (i = 0; (i = next_set_bit(mask, i, size * 32)) >= 0; ) { ++i; *s++ = sep; - if (i < nsignals) { + if ((unsigned) i < nsignals) { s = stpcpy(s, signalent[i] + 3); } #ifdef SIGRTMIN @@ -428,7 +432,7 @@ printsiginfo(siginfo_t *sip, int verbose) #endif { if (sip->si_errno) { - if (sip->si_errno < 0 || sip->si_errno >= nerrnos) + if (sip->si_errno < 0 || (unsigned) sip->si_errno >= nerrnos) tprintf(", si_errno=%d", sip->si_errno); else tprintf(", si_errno=%s", diff --git a/sock.c b/sock.c index d3a5b35a..dca9bfd4 100644 --- a/sock.c +++ b/sock.c @@ -224,8 +224,8 @@ sock_ioctl(struct tcb *tcp, long code, long arg) } else if (ifc.ifc_buf == NULL) { tprints("NULL"); } else { - int i; - unsigned nifra = ifc.ifc_len / sizeof(struct ifreq); + unsigned int i; + unsigned int nifra = ifc.ifc_len / sizeof(struct ifreq); struct ifreq ifra[nifra]; if (umoven(tcp, (unsigned long) ifc.ifc_buf, diff --git a/strace.c b/strace.c index 2bc5c675..0ef44aa1 100644 --- a/strace.c +++ b/strace.c @@ -675,7 +675,7 @@ expand_tcbtab(void) callers have pointers and it would be a pain. So tcbtab is a table of pointers. Since we never free the TCBs, we allocate a single chunk of many. */ - int i = tcbtabsize; + unsigned int i = tcbtabsize; struct tcb *newtcbs = calloc(tcbtabsize, sizeof(newtcbs[0])); struct tcb **newtab = realloc(tcbtab, tcbtabsize * 2 * sizeof(tcbtab[0])); if (!newtab || !newtcbs) @@ -689,7 +689,7 @@ expand_tcbtab(void) static struct tcb * alloctcb(int pid) { - int i; + unsigned int i; struct tcb *tcp; if (nprocs == tcbtabsize) @@ -837,7 +837,7 @@ detach(struct tcb *tcp) * 3. Attach SIGSTOP was already pending (TCB_IGNORE_ONE_SIGSTOP set) */ for (;;) { - int sig; + unsigned int sig; if (waitpid(tcp->pid, &status, __WALL) < 0) { if (errno == EINTR) continue; @@ -954,7 +954,7 @@ process_opt_p_list(char *opt) static void startup_attach(void) { - int tcbi; + unsigned int tcbi; struct tcb *tcp; /* @@ -1183,7 +1183,7 @@ startup_child(char **argv) #endif /* USE_DEBUGGING_EXEC */ else { const char *path; - int m, n, len; + size_t m, n, len; for (path = getenv("PATH"); path && *path; path += m) { const char *colon = strchr(path, ':'); @@ -1635,6 +1635,7 @@ init(int argc, char *argv[]) struct tcb *tcp; int c, i; int optF = 0; + unsigned int tcbi; struct sigaction sa; progname = argv[0] ? argv[0] : "strace"; @@ -1658,8 +1659,8 @@ init(int argc, char *argv[]) tcp = calloc(tcbtabsize, sizeof(*tcp)); if (!tcp) die_out_of_memory(); - for (c = 0; c < tcbtabsize; c++) - tcbtab[c] = tcp++; + for (tcbi = 0; tcbi < tcbtabsize; tcbi++) + tcbtab[tcbi] = tcp++; shared_log = stderr; set_sortby(DEFAULT_SORTBY); @@ -1978,7 +1979,7 @@ init(int argc, char *argv[]) static struct tcb * pid2tcb(int pid) { - int i; + unsigned int i; if (pid <= 0) return NULL; @@ -1995,7 +1996,7 @@ pid2tcb(int pid) static void cleanup(void) { - int i; + unsigned int i; struct tcb *tcp; int fatal_sig; @@ -2049,10 +2050,11 @@ trace(void) while (1) { int pid; int wait_errno; - int status, sig; + int status; int stopped; - struct tcb *tcp; + unsigned int sig; unsigned event; + struct tcb *tcp; if (interrupted) return; @@ -2185,10 +2187,10 @@ trace(void) if (ptrace(PTRACE_GETEVENTMSG, pid, NULL, (long) &old_pid) < 0) goto dont_switch_tcbs; /* Avoid truncation in pid2tcb() param passing */ - if (old_pid > UINT_MAX) - goto dont_switch_tcbs; if (old_pid <= 0 || old_pid == pid) goto dont_switch_tcbs; + if ((unsigned long) old_pid > UINT_MAX) + goto dont_switch_tcbs; execve_thread = pid2tcb(old_pid); /* It should be !NULL, but I feel paranoid */ if (!execve_thread) diff --git a/syscall.c b/syscall.c index b0ad47e1..e74881d5 100644 --- a/syscall.c +++ b/syscall.c @@ -323,7 +323,7 @@ set_personality(int personality) } static void -update_personality(struct tcb *tcp, int personality) +update_personality(struct tcb *tcp, unsigned int personality) { if (personality == current_personality) return; @@ -370,7 +370,7 @@ update_personality(struct tcb *tcp, int personality) static int qual_syscall(), qual_signal(), qual_desc(); static const struct qual_options { - int bitflag; + unsigned int bitflag; const char *option_name; int (*qualify)(const char *, int, int); const char *argument_name; @@ -396,7 +396,7 @@ static const struct qual_options { }; static void -reallocate_qual(int n) +reallocate_qual(const unsigned int n) { unsigned p; qualbits_t *qp; @@ -410,9 +410,9 @@ reallocate_qual(int n) } static void -qualify_one(int n, int bitflag, int not, int pers) +qualify_one(const unsigned int n, unsigned int bitflag, const int not, const int pers) { - unsigned p; + int p; if (num_quals <= n) reallocate_qual(n + 1); @@ -428,10 +428,10 @@ qualify_one(int n, int bitflag, int not, int pers) } static int -qual_syscall(const char *s, int bitflag, int not) +qual_syscall(const char *s, const unsigned int bitflag, const int not) { - unsigned p; - unsigned i; + int p; + unsigned int i; int rc = -1; if (*s >= '0' && *s <= '9') { @@ -457,9 +457,9 @@ qual_syscall(const char *s, int bitflag, int not) } static int -qual_signal(const char *s, int bitflag, int not) +qual_signal(const char *s, const unsigned int bitflag, const int not) { - int i; + unsigned int i; if (*s >= '0' && *s <= '9') { int signo = string_to_uint(s); @@ -480,7 +480,7 @@ qual_signal(const char *s, int bitflag, int not) } static int -qual_desc(const char *s, int bitflag, int not) +qual_desc(const char *s, const unsigned int bitflag, const int not) { if (*s >= '0' && *s <= '9') { int desc = string_to_uint(s); @@ -516,20 +516,20 @@ void qualify(const char *s) { const struct qual_options *opt; - int not; char *copy; const char *p; - int i, n; + int not; + unsigned int i; if (num_quals == 0) reallocate_qual(MIN_QUALS); opt = &qual_options[0]; for (i = 0; (p = qual_options[i].option_name); i++) { - n = strlen(p); - if (strncmp(s, p, n) == 0 && s[n] == '=') { + unsigned int len = strlen(p); + if (strncmp(s, p, len) == 0 && s[len] == '=') { opt = &qual_options[i]; - s += n + 1; + s += len + 1; break; } } @@ -555,6 +555,7 @@ qualify(const char *s) if (!copy) die_out_of_memory(); for (p = strtok(copy, ","); p; p = strtok(NULL, ",")) { + int n; if (opt->bitflag == QUAL_TRACE && (n = lookup_class(p)) > 0) { unsigned pers; for (pers = 0; pers < SUPPORTED_PERSONALITIES; pers++) { @@ -1220,7 +1221,7 @@ get_scno(struct tcb *tcp) #elif defined(POWERPC) scno = ppc_regs.gpr[0]; # ifdef POWERPC64 - int currpers; + unsigned int currpers; /* * Check for 64/32 bit mode. @@ -1242,7 +1243,7 @@ get_scno(struct tcb *tcp) # ifndef __X32_SYSCALL_BIT # define __X32_SYSCALL_BIT 0x40000000 # endif - int currpers; + unsigned int currpers; # if 1 /* GETREGSET of NT_PRSTATUS tells us regset size, * which unambiguously detects i386. @@ -1530,7 +1531,7 @@ get_scno(struct tcb *tcp) if (upeek(tcp->pid, 4*PT_R9, &scno) < 0) return -1; #elif defined(TILE) - int currpers; + unsigned int currpers; scno = tile_regs.regs[10]; # ifdef __tilepro__ currpers = 1; @@ -2660,7 +2661,7 @@ trace_syscall_exiting(struct tcb *tcp) default: if (u_error < 0) tprintf("= -1 E??? (errno %ld)", u_error); - else if (u_error < nerrnos) + else if ((unsigned long) u_error < nerrnos) tprintf("= -1 %s (%s)", errnoent[u_error], strerror(u_error)); else diff --git a/system.c b/system.c index 435e2c18..86cb0243 100644 --- a/system.c +++ b/system.c @@ -433,7 +433,7 @@ sys_sysctl(struct tcb *tcp) return printargs(tcp); size = sizeof(int) * (unsigned long) info.nlen; - name = (size / sizeof(int) != info.nlen) ? NULL : malloc(size); + name = (size / sizeof(int) != (unsigned long) info.nlen) ? NULL : malloc(size); if (name == NULL || umoven(tcp, (unsigned long) info.name, size, (char *) name) < 0) { free(name); @@ -445,7 +445,7 @@ sys_sysctl(struct tcb *tcp) } if (entering(tcp)) { - int cnt = 0, max_cnt; + unsigned int cnt = 0, max_cnt; tprints("{{"); @@ -540,7 +540,7 @@ sys_sysctl(struct tcb *tcp) max_cnt = max_strlen; while (cnt < max_cnt) tprintf(", %x", name[cnt++]); - if (cnt < info.nlen) + if (cnt < (unsigned) info.nlen) tprints(", ..."); tprintf("}, %d, ", info.nlen); } else { diff --git a/util.c b/util.c index c78e962c..c8dc5914 100644 --- a/util.c +++ b/util.c @@ -141,7 +141,7 @@ tv_mul(struct timeval *tv, const struct timeval *a, int n) } const char * -xlookup(const struct xlat *xlat, int val) +xlookup(const struct xlat *xlat, const unsigned int val) { for (; xlat->str != NULL; xlat++) if (xlat->val == val) @@ -210,7 +210,7 @@ next_set_bit(const void *bit_array, unsigned cur_bit, unsigned size_bits) * Print entry in struct xlat table, if there. */ void -printxval(const struct xlat *xlat, int val, const char *dflt) +printxval(const struct xlat *xlat, const unsigned int val, const char *dflt) { const char *str = xlookup(xlat, val); @@ -414,7 +414,7 @@ printfd(struct tcb *tcp, int fd) void printuid(const char *text, unsigned long uid) { - tprintf((uid == -1) ? "%s%ld" : "%s%lu", text, uid); + tprintf(((long) uid == -1) ? "%s%ld" : "%s%lu", text, uid); } /* @@ -564,7 +564,7 @@ string_quote(const char *instr, char *outstr, long len, int size) * If path length exceeds `n', append `...' to the output. */ void -printpathn(struct tcb *tcp, long addr, int n) +printpathn(struct tcb *tcp, long addr, unsigned int n) { char path[MAXPATHLEN + 1]; int nul_seen; @@ -612,7 +612,7 @@ printstr(struct tcb *tcp, long addr, long len) { static char *str = NULL; static char *outstr; - int size; + unsigned int size; int ellipsis; if (!addr) { @@ -658,7 +658,7 @@ printstr(struct tcb *tcp, long addr, long len) * or we were requested to print more than -s NUM chars)... */ ellipsis = (string_quote(str, outstr, len, size) && - (len < 0 || len > max_strlen)); + (len < 0 || (unsigned long) len > max_strlen)); tprints(outstr); if (ellipsis) @@ -1480,7 +1480,7 @@ setbpt(struct tcb *tcp) * godforsaken tables. */ if (clone_scno[current_personality] == 0) { - int i; + unsigned int i; for (i = 0; i < nsyscalls; ++i) if (sysent[i].sys_func == sys_clone) { clone_scno[current_personality] = i; -- 2.40.0