From 0bde518078a4f8e75cc5a1aefef23fae5993de52 Mon Sep 17 00:00:00 2001 From: dwmalone Date: Sun, 15 Feb 2004 22:01:23 +0000 Subject: [PATCH] Fix a few WARNS: 1) Include string.h for strcpy. 2) Don't make duplicate declaration of dump_file, we now include extern.h. 3) Help out with some constness. 4) Cast to slightly better types in some comparisons. --- usr.bin/ldd/sods.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/usr.bin/ldd/sods.c b/usr.bin/ldd/sods.c index 195651e27060..cdc5e783a09d 100644 --- a/usr.bin/ldd/sods.c +++ b/usr.bin/ldd/sods.c @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include "extern.h" @@ -72,7 +73,6 @@ __FBSDID("$FreeBSD$"); #ifdef STANDALONE static #endif -void dump_file(const char *); static void dump_rels(const char *, const struct relocation_info *, unsigned long, const char *(*)(unsigned long), unsigned char *); @@ -182,7 +182,7 @@ dump_file(const char *fname) file_base = (const char *) objbase; /* Makes address arithmetic easier */ - if (IS_ELF(*(Elf32_Ehdr*) file_base)) { + if (IS_ELF(*(const Elf32_Ehdr*) file_base)) { warnx("%s: this is an ELF program; use objdump to examine", fname); ++error_count; munmap(objbase, sb.st_size); @@ -286,13 +286,13 @@ dump_file(const char *fname) (const struct relocation_info *) (text_addr + sdt->sdt_rel); rtrel_count = (sdt->sdt_hash - sdt->sdt_rel) / sizeof rtrel_base[0]; assert(rtrel_count * sizeof rtrel_base[0] == - sdt->sdt_hash - sdt->sdt_rel); + (size_t)(sdt->sdt_hash - sdt->sdt_rel)); rtsym_base = (const struct nzlist *) (text_addr + sdt->sdt_nzlist); rtsym_count = (sdt->sdt_strings - sdt->sdt_nzlist) / sizeof rtsym_base[0]; assert(rtsym_count * sizeof rtsym_base[0] == - sdt->sdt_strings - sdt->sdt_nzlist); + (size_t)(sdt->sdt_strings - sdt->sdt_nzlist)); if (rtsym_count != 0) { rtsym_used = (unsigned char *) calloc(rtsym_count, @@ -338,8 +338,8 @@ dump_rels(const char *label, const struct relocation_info *base, size = 1u << r->r_length; - if (origin <= r->r_address - && r->r_address < origin + ex->a_text + ex->a_data + if (origin <= (unsigned long)r->r_address + && (unsigned long)r->r_address < origin + ex->a_text + ex->a_data && 1 <= size && size <= 4) { /* * XXX - This can cause unaligned accesses. OK for the