From: Jeff Smith Date: Thu, 16 Mar 2017 18:07:02 +0000 (-0500) Subject: peekfd: fix type-mismatches X-Git-Tag: v23.0~17^2~1^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=504bbd60c33ea24465d720d24df887f29a9c6bca;p=psmisc peekfd: fix type-mismatches Noticed when compiling with CFLAGS="-Wextra -Wno-ununsed-parameter" --- diff --git a/src/peekfd.c b/src/peekfd.c index cba2130..cb1e70d 100644 --- a/src/peekfd.c +++ b/src/peekfd.c @@ -130,8 +130,8 @@ void usage() { " Press CTRL-C to end output.\n")); } -int bufdiff(pid_t pid, unsigned char *lastbuf, unsigned int addr, unsigned int len) { - int i; +int bufdiff(pid_t pid, unsigned char *lastbuf, unsigned long addr, unsigned long len) { + unsigned long i; for (i = 0; i < len; i++) if (lastbuf[i] != (ptrace(PTRACE_PEEKTEXT, pid, addr + i, 0) & 0xff)) return 1; @@ -149,6 +149,7 @@ int main(int argc, char **argv) int numfds = 0; int *fds = NULL; int i; + unsigned long j; struct option options[] = { {"eight-bit-clean", 0, NULL, '8'}, @@ -220,7 +221,7 @@ int main(int argc, char **argv) int lastfd = numfds > 0 ? fds[0] : 0; int lastdir = 3; unsigned char *lastbuf = NULL; - int last_buf_size=-1; + unsigned long last_buf_size = -1; for(;;) { int status; @@ -255,10 +256,10 @@ int main(int argc, char **argv) } if ((regs.REG_ORIG_ACCUM == SYS_read || regs.REG_ORIG_ACCUM == SYS_write) && (regs.REG_PARAM3 == regs.REG_ACCUM)) { for (i = 0; i < numfds; i++) - if (fds[i] == regs.REG_PARAM1) + if (fds[i] == (int)regs.REG_PARAM1) break; if (i != numfds || numfds == 0) { - if (regs.REG_PARAM1 != lastfd || regs.REG_ORIG_ACCUM != lastdir) { + if ((int)regs.REG_PARAM1 != lastfd || (int)regs.REG_ORIG_ACCUM != lastdir) { lastfd = regs.REG_PARAM1; lastdir = regs.REG_ORIG_ACCUM; if (!no_headers) @@ -275,18 +276,18 @@ int main(int argc, char **argv) last_buf_size = regs.REG_PARAM3; } - for (i = 0; i < regs.REG_PARAM3; i++) { + for (j = 0; j < regs.REG_PARAM3; j++) { #if BYTE_ORDER == BIG_ENDIAN #if __WORDSIZE == 64 - unsigned int a = bswap_64(ptrace(PTRACE_PEEKTEXT, pid, regs.REG_PARAM2 + i, 0)); + unsigned int a = bswap_64(ptrace(PTRACE_PEEKTEXT, pid, regs.REG_PARAM2 + j, 0)); #else - unsigned int a = bswap_32(ptrace(PTRACE_PEEKTEXT, pid, regs.REG_PARAM2 + i, 0)); + unsigned int a = bswap_32(ptrace(PTRACE_PEEKTEXT, pid, regs.REG_PARAM2 + j, 0)); #endif #else - unsigned int a = ptrace(PTRACE_PEEKTEXT, pid, regs.REG_PARAM2 + i, 0); + unsigned int a = ptrace(PTRACE_PEEKTEXT, pid, regs.REG_PARAM2 + j, 0); #endif if (remove_duplicates) - lastbuf[i] = a & 0xff; + lastbuf[j] = a & 0xff; if (eight_bit_clean) putchar(a & 0xff);