Numerous warnings had snuck into the build, preventing ltrace from
building with --enable-debug (which uses -Wall, -Werror, and more).
This patch fixes the problems, mostly caused by -Wsign-compare.

Signed-off-by: Zachary T Welch <[email protected]>
---
 display_args.c                |   14 +++++++-------
 ltrace-elf.c                  |    2 +-
 ltrace-elf.h                  |    2 +-
 options.c                     |    2 +-
 options.h                     |    4 ++--
 sysdeps/linux-gnu/arm/trace.c |    2 +-
 sysdeps/linux-gnu/proc.c      |    6 +++---
 sysdeps/linux-gnu/trace.c     |    6 +++---
 8 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/display_args.c b/display_args.c
index 993a808..c639c88 100644
--- a/display_args.c
+++ b/display_args.c
@@ -15,8 +15,8 @@ static int display_value(enum tof type, Process *proc,
 static int display_unknown(enum tof type, Process *proc, long value);
 static int display_format(enum tof type, Process *proc, int arg_num);
 
-static int string_maxlength = INT_MAX;
-static int array_maxlength = INT_MAX;
+static size_t string_maxlength = INT_MAX;
+static size_t array_maxlength = INT_MAX;
 
 static long
 get_length(enum tof type, Process *proc, int len_spec,
@@ -59,8 +59,8 @@ display_arrayptr(enum tof type, Process *proc,
                            void *addr, arg_type_info * info,
                            void *st, arg_type_info* st_info) {
        int len = 0;
-       int i;
-       int array_len;
+       size_t i;
+       size_t array_len;
 
        if (addr == NULL)
                return fprintf(options.output, "NULL");
@@ -143,7 +143,7 @@ display_pointer(enum tof type, Process *proc, long value,
 static int
 display_enum(enum tof type, Process *proc,
                arg_type_info* info, long value) {
-       int ii;
+       size_t ii;
        for (ii = 0; ii < info->u.enum_info.entries; ++ii) {
                if (info->u.enum_info.values[ii] == value)
                        return fprintf(options.output, "%s", 
info->u.enum_info.keys[ii]);
@@ -281,7 +281,7 @@ static int
 display_string(enum tof type, Process *proc, void *addr,
                          size_t maxlength) {
        unsigned char *str1;
-       int i;
+       size_t i;
        int len = 0;
 
        if (!addr) {
@@ -328,7 +328,7 @@ display_format(enum tof type, Process *proc, int arg_num) {
        void *addr;
        unsigned char *str1;
        int i;
-       int len = 0;
+       size_t len = 0;
        arg_type_info info;
 
        info.type = ARGTYPE_POINTER;
diff --git a/ltrace-elf.c b/ltrace-elf.c
index 81185fe..29a8b9d 100644
--- a/ltrace-elf.c
+++ b/ltrace-elf.c
@@ -762,7 +762,7 @@ read_elf(Process *proc) {
                        }
        }
 
-       int found_count = 0;
+       unsigned found_count = 0;
 
        for (xptr = opt_x; xptr; xptr = xptr->next) {
                if (xptr->found)
diff --git a/ltrace-elf.h b/ltrace-elf.h
index 3d23f57..37f2a18 100644
--- a/ltrace-elf.h
+++ b/ltrace-elf.h
@@ -41,7 +41,7 @@ struct ltelf {
 
 #define PLTS_ARE_EXECUTABLE(lte) ((lte->lte_flags & LTE_PLT_EXECUTABLE) != 0)
 
-extern int library_num;
+extern size_t library_num;
 extern char *library[MAX_LIBRARIES];
 
 extern struct library_symbol *read_elf(Process *);
diff --git a/options.c b/options.c
index c7e3be6..74c28bd 100644
--- a/options.c
+++ b/options.c
@@ -37,7 +37,7 @@ struct options_t options = {
 };
 
 char *library[MAX_LIBRARIES];
-int library_num = 0;
+size_t library_num = 0;
 static char *progname;         /* Program name (`ltrace') */
 int opt_i = 0;                 /* instruction pointer */
 int opt_r = 0;                 /* print relative timestamp */
diff --git a/options.h b/options.h
index 9079cbf..9a00629 100644
--- a/options.h
+++ b/options.h
@@ -11,8 +11,8 @@ struct options_t {
        FILE *output;   /* output to a specific file */
        int summary;    /* count time, calls, and report a summary on program 
exit */
        int debug;      /* debug */
-       int arraylen;   /* default maximum # of array elements printed */
-       int strlen;     /* default maximum # of bytes printed in strings */
+       size_t arraylen;   /* default maximum # of array elements printed */
+       size_t strlen;     /* default maximum # of bytes printed in strings */
        int follow;     /* trace child processes */
        int no_plt;     /* set bps on PLT entries */
        int no_signals; /* don't print signals */
diff --git a/sysdeps/linux-gnu/arm/trace.c b/sysdeps/linux-gnu/arm/trace.c
index e9fcbdd..39b8264 100644
--- a/sysdeps/linux-gnu/arm/trace.c
+++ b/sysdeps/linux-gnu/arm/trace.c
@@ -46,7 +46,7 @@ syscall_p(Process *proc, int status, int *sysnum) {
                /* get the user's pc (plus 8) */
                int pc = ptrace(PTRACE_PEEKUSER, proc->pid, off_pc, 0);
                /* fetch the SWI instruction */
-               int insn = ptrace(PTRACE_PEEKTEXT, proc->pid, pc - 4, 0);
+               unsigned insn = ptrace(PTRACE_PEEKTEXT, proc->pid, pc - 4, 0);
                int ip = ptrace(PTRACE_PEEKUSER, proc->pid, off_ip, 0);
 
                if (insn == 0xef000000 || insn == 0x0f000000
diff --git a/sysdeps/linux-gnu/proc.c b/sysdeps/linux-gnu/proc.c
index 642cb32..3c17e1f 100644
--- a/sysdeps/linux-gnu/proc.c
+++ b/sysdeps/linux-gnu/proc.c
@@ -143,7 +143,7 @@ load_debug_struct(Process *proc) {
 
 static void
 linkmap_add_cb(void *data) { //const char *lib_name, ElfW(Addr) addr) {
-       int i = 0;
+       size_t i = 0;
        struct cb_data *lm_add = data;
        struct ltelf lte;
        struct opt_x_t *xptr;
@@ -252,13 +252,13 @@ hook_libdl_cb(void *data) {
 
 int
 linkmap_init(Process *proc, struct ltelf *lte) {
-       void *dbg_addr = NULL;
+       void *dbg_addr = NULL, *dyn_addr = (void *)(unsigned)lte->dyn_addr;
        struct r_debug *rdbg = NULL;
        struct cb_data data;
 
        debug(DEBUG_FUNCTION, "linkmap_init()");
 
-       if (find_dynamic_entry_addr(proc, (void *)lte->dyn_addr, DT_DEBUG, 
&dbg_addr) == -1) {
+       if (find_dynamic_entry_addr(proc, dyn_addr, DT_DEBUG, &dbg_addr) == -1) 
{
                debug(2, "Couldn't find debug structure!");
                return -1;
        }
diff --git a/sysdeps/linux-gnu/trace.c b/sysdeps/linux-gnu/trace.c
index 2ec2904..e4be465 100644
--- a/sysdeps/linux-gnu/trace.c
+++ b/sysdeps/linux-gnu/trace.c
@@ -178,8 +178,8 @@ umovebytes(Process *proc, void *addr, void *laddr, size_t 
len) {
                long a;
                char c[sizeof(long)];
        } a;
-       int offset = 0, started = 0;
-       size_t bytes_read = 0;
+       int started = 0;
+       size_t offset = 0, bytes_read = 0;
 
        while (offset < len) {
                a.a = ptrace(PTRACE_PEEKTEXT, proc->pid, addr + offset, 0);
@@ -215,7 +215,7 @@ umovestr(Process *proc, void *addr, int len, void *laddr) {
                long a;
                char c[sizeof(long)];
        } a;
-       int i;
+       unsigned i;
        int offset = 0;
 
        while (offset < len) {
-- 
1.7.2.2


_______________________________________________
Ltrace-devel mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/ltrace-devel

Reply via email to