* 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.
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
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;
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])
#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 */
#define filtered(tcp) ((tcp)->flags & TCB_FILTERED)
struct xlat {
- int val;
+ unsigned int val;
const char *str;
};
#define XLAT(x) { x, #x }
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);
#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 *);
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);
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);
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);
}
}
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;
const struct_ioctlent *
ioctl_next_match(const struct_ioctlent *iop)
{
- long code;
+ unsigned long code;
code = iop->code;
iop++;
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) {
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) {
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) {
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;
if (!verbose(tcp) || umove(tcp, arg, &i) < 0)
return 0;
- tprintf(", [%d]", i);
+ tprintf(", [%u]", i);
return 1;
case MTDFILEMODE:
return;
}
- if (addrlen < 2 || addrlen > sizeof(addrbuf))
+ if (addrlen < 2 || addrlen > (int) sizeof(addrbuf))
addrlen = sizeof(addrbuf);
memset(&addrbuf, 0, sizeof(addrbuf));
int
sys_prctl(struct tcb *tcp)
{
- int i;
+ unsigned int i;
if (entering(tcp)) {
printxval(prctl_options, tcp->u_arg[0], "PR_???");
char data[sizeof(long)];
} cp;
const char *sep;
- int n = 0;
+ unsigned int n = 0;
unsigned wordsize = current_wordsize;
cp.p64 = 1;
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_???");
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);
}
#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);
*/
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;
}
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
#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",
} 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,
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)
static struct tcb *
alloctcb(int pid)
{
- int i;
+ unsigned int i;
struct tcb *tcp;
if (nprocs == tcbtabsize)
* 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;
static void
startup_attach(void)
{
- int tcbi;
+ unsigned int tcbi;
struct tcb *tcp;
/*
#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, ':');
struct tcb *tcp;
int c, i;
int optF = 0;
+ unsigned int tcbi;
struct sigaction sa;
progname = argv[0] ? argv[0] : "strace";
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);
static struct tcb *
pid2tcb(int pid)
{
- int i;
+ unsigned int i;
if (pid <= 0)
return NULL;
static void
cleanup(void)
{
- int i;
+ unsigned int i;
struct tcb *tcp;
int fatal_sig;
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;
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)
}
static void
-update_personality(struct tcb *tcp, int personality)
+update_personality(struct tcb *tcp, unsigned int personality)
{
if (personality == current_personality)
return;
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;
};
static void
-reallocate_qual(int n)
+reallocate_qual(const unsigned int n)
{
unsigned p;
qualbits_t *qp;
}
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);
}
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') {
}
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);
}
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);
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;
}
}
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++) {
#elif defined(POWERPC)
scno = ppc_regs.gpr[0];
# ifdef POWERPC64
- int currpers;
+ unsigned int currpers;
/*
* Check for 64/32 bit mode.
# 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.
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;
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
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);
}
if (entering(tcp)) {
- int cnt = 0, max_cnt;
+ unsigned int cnt = 0, max_cnt;
tprints("{{");
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 {
}
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)
* 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);
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);
}
/*
* 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;
{
static char *str = NULL;
static char *outstr;
- int size;
+ unsigned int size;
int ellipsis;
if (!addr) {
* 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)
* 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;