scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 40525604fca878404a8e7bec907162a4519515db
parent 1f77007724382f0824b79f3990a61337ae499242
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 28 Nov 2017 08:32:14 +0000

[objdump] Remove size_t check of fields

These fields don't have any relation with size_t, so they
can be used with offset_t directly.

Diffstat:
Mobjdump/main.c | 23++++++++---------------
1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/objdump/main.c b/objdump/main.c @@ -73,7 +73,7 @@ printstrings(struct myrohdr *hdr) static int printsections(struct myrohdr *hdr, FILE *fp) { - size_t n, i; + unsigned long long n, i; struct myrosect sect; puts("sections:"); @@ -100,7 +100,7 @@ printsections(struct myrohdr *hdr, FILE *fp) static int printsymbols(struct myrohdr *hdr, FILE *fp) { - size_t n, i; + unsigned long long n, i; struct myrosym sym; puts("symbols:"); @@ -127,7 +127,7 @@ printsymbols(struct myrohdr *hdr, FILE *fp) static int printrelocs(struct myrohdr *hdr, FILE *fp) { - size_t n, i; + unsigned long long n, i; struct myrorel rel; puts("relocs:"); @@ -192,11 +192,11 @@ main(int argc, char *argv[]) goto wrong_file; if (rdmyrohdr(fp, &hdr) < 0) goto wrong_file; - if (hdr.strsize > SIZE_MAX || - hdr.secsize > SIZE_MAX / MYROSECT_SIZ || - hdr.symsize > SIZE_MAX / MYROSYM_SIZ || - hdr.relsize > SIZE_MAX / MYROREL_SIZ) { - goto overflow; + if (hdr.strsize > SIZE_MAX) { + fprintf(stderr, + "objdump: %s: overflow in header\n", + *argv, strerror(errno)); + goto close_file; } strsiz = hdr.strsize; @@ -224,13 +224,6 @@ wrong_file: fprintf(stderr, "objdump: %s: %s\n", *argv, strerror(errno)); - goto close_file; - -overflow: - fprintf(stderr, - "objdump: %s: overflow in header\n", - *argv, strerror(errno)); - close_file: if (fp) fclose(fp);