]> granicus.if.org Git - strace/commitdiff
Fix compilation warnings reported by gcc -Wsign-compare
authorDmitry V. Levin <ldv@altlinux.org>
Wed, 10 Sep 2014 13:46:04 +0000 (13:46 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 17 Sep 2014 19:18:18 +0000 (19:18 +0000)
* 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.

17 files changed:
configure.ac
count.c
defs.h
file.c
ioctl.c
mem.c
mtd.c
net.c
process.c
reboot.c
scsi.c
signal.c
sock.c
strace.c
syscall.c
system.c
util.c

index 52c1ecf66ec8e2941e2d36c79e5849e53ef27aec..6fe83cfbddb4de1fb4a3169ed39bdbeead9be8cc 100644 (file)
@@ -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 e41994d3715a9728c7cf1070da9b85d6caed2925..25921b25713b1d553f0f08e91a68246a576176ab 100644 (file)
--- 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 625cac673d5deb9bb79e74ee9b35c06dd6670cfe..396e519634a98a66874e4caf717e87e72cc522c3 100644 (file)
--- 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 47ca2302fd49d1a6ea32c872c22a04aa39d8a58f..f788bd69d21eec93e6e239a0daf9329ed8dd1234 100644 (file)
--- 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 3f6c410b652eca90ae2de45808f2f7ac9cba8eb7..99b31fb076f0c85c8fd48294b6c901c5208f5ca1 100644 (file)
--- a/ioctl.c
+++ b/ioctl.c
 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 6ecd363c82ad8fdc5bdb16371a1aee5b35e944d4..28f744fb3f01915d9d6de7f166f1efa6df5eb88c 100644 (file)
--- 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 8ba658b5ca3df7b7b3c8599055264eef766ecea3..88e8dbcc64332917bd856e9473a1e50394e84479 100644 (file)
--- 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 7b89917062e47565adf64e023444536728eb634f..46c491f8f6d78763c90f8fdcf20842d418c1dbae 100644 (file)
--- 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));
index 2cd0f01f6f50127241a856cfdc19d5d2dfd4e07f..e465319e71210c335b6265f0a5f654c0c4994810 100644 (file)
--- 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_???");
index 397a1269d10aa034b3d3114a314137f31be6b9e5..e3fa77a994a1ef73a61b87ff097389ebfc3c779a 100644 (file)
--- 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 2aa4c7b35e9cfc3fdeecfa76ced4e08279623364..a2e23c8b1cb10da3cbff19e7e686ccb310b339cd 100644 (file)
--- a/scsi.c
+++ b/scsi.c
 #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);
index f6eeed0e8e3ba8407d6f619b7766c350d1c4a095..74e0fd90735da4f9b3e23d5a997f7bc5f8b26111 100644 (file)
--- 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 d3a5b35adcd3d96e459eef27a0ee0888cbff2e89..dca9bfd4713a45857c1391e011bc90d1bdfefaf4 100644 (file)
--- 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,
index 2bc5c675f1c7f850aa58982b0d7b96225e5d6fac..0ef44aa116c78a3f0d8e9b0d7a200e2ab344fddf 100644 (file)
--- 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)
index b0ad47e13caf837e60715d406d007f7572a78dd8..e74881d5e1ce4a38d144739ce529cf3d515b83c0 100644 (file)
--- 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
index 435e2c18614fda17cf9e645a8ce71d77a39f82e2..86cb024340ac1ebf121568f2821fe2d0903fb665 100644 (file)
--- 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 c78e962c9d49d6499e65c01bf58736e6cd9298d1..c8dc5914bc09d27c4bf09feb051964788c1790a1 100644 (file)
--- 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;