Report missing binary if test suite is run w/o prior install
[elfdbg/.git] / elf.c
diff --git a/elf.c b/elf.c
index a1d7ae5c08e5e8c8e41de27c9d9068d4b2c1e6c5..e576498709a6728e24b3a58d8b823f481d60d426 100644 (file)
--- a/elf.c
+++ b/elf.c
@@ -117,7 +117,7 @@ elf_destroy(Elf_Obj *e)
 }
 
 char *
 }
 
 char *
-elf_str_get(Elf_Obj *e, int index)
+elf_str_get(Elf_Obj *e, size_t index)
 {
        if (e == NULL || index > e->strtab_size)
                return (NULL);
 {
        if (e == NULL || index > e->strtab_size)
                return (NULL);
@@ -125,16 +125,17 @@ elf_str_get(Elf_Obj *e, int index)
        return (&e->strtab[e->shdr[index].sh_name]);
 }
 
        return (&e->strtab[e->shdr[index].sh_name]);
 }
 
-int
+unsigned int
 elf_debug_count(Elf_Obj *e)
 {
 elf_debug_count(Elf_Obj *e)
 {
-       int i, has_debug = 0;
-       char *debug_prefix = ".debug_";
+       unsigned int has_debug = 0;
+       const char debug_prefix[] = ".debug_";
        char *section_name = NULL;
 
        char *section_name = NULL;
 
-       for (i = 0; i < e->shdr_size; i++) {
+       for (size_t i = 0; i < e->shdr_size; i++) {
                section_name = elf_str_get(e, i);
                section_name = elf_str_get(e, i);
-               if (strnstr(section_name, debug_prefix, strlen(debug_prefix))) {
+        if (strnstr(section_name, debug_prefix,
+                    strlen(debug_prefix))) {
                        has_debug++;
                }
        }
                        has_debug++;
                }
        }
@@ -145,18 +146,18 @@ elf_debug_count(Elf_Obj *e)
 void
 elf_debug_print(Elf_Obj *e)
 {
 void
 elf_debug_print(Elf_Obj *e)
 {
-       int i;
-       char *debug_prefix = ".debug_";
+       const char debug_prefix[] = ".debug_";
        char *section_name = NULL;
 
        char *section_name = NULL;
 
-       printf("%d ELF debug sections:\n", elf_debug_count(e));
+       printf("%u ELF debug sections:\n", elf_debug_count(e));
 
 
-       for (i = 0; i < e->shdr_size; i++) {
+       for (size_t i = 0; i < e->shdr_size; i++) {
                if (e->shdr[i].sh_type != SHT_PROGBITS)
                        continue;
 
                section_name = elf_str_get(e, i);
                if (e->shdr[i].sh_type != SHT_PROGBITS)
                        continue;
 
                section_name = elf_str_get(e, i);
-               if (strnstr(section_name, debug_prefix, strlen(debug_prefix))) {
+               if (strnstr(section_name, debug_prefix,
+                    strlen(debug_prefix))) {
                        printf("%s\n", section_name);
                }
        }
                        printf("%s\n", section_name);
                }
        }