From e21b92e66ad6c143da489331d4d56abfa2092160 Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Tue, 21 Sep 2010 12:31:45 +0200 Subject: [PATCH] asm/dasm: Improve cflags Signed-off-by: Michael Buesch --- assembler/Makefile | 6 ++++-- assembler/main.c | 4 ++-- assembler/scanner.l | 4 ++-- disassembler/Makefile | 6 ++++-- disassembler/main.c | 10 ++++++---- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/assembler/Makefile b/assembler/Makefile index aaaf7b7..6bc3321 100644 --- a/assembler/Makefile +++ b/assembler/Makefile @@ -18,8 +18,10 @@ QUIET_SPARSE = @/bin/true endif PREFIX ?= /usr/local -CFLAGS ?= -O2 -fomit-frame-pointer -D_BSD_SOURCE -D_GNU_SOURCE -CFLAGS += -std=c99 -Wall -D_BSD_SOURCE -D_GNU_SOURCE +CFLAGS ?= -O2 -fomit-frame-pointer -pipe +CFLAGS += -std=gnu99 -D_GNU_SOURCE \ + -Wall -Wextra -Wformat=2 -Wundef -Wno-unused-parameter \ + -Wshadow -Wpointer-arith SPARSEFLAGS = $(CFLAGS) -D__transparent_union__=__unused__ -D_STRING_ARCH_unaligned=1 \ -D__builtin_stpcpy=stpcpy LDFLAGS += -lfl diff --git a/assembler/main.c b/assembler/main.c index 8abe03c..ad180b2 100644 --- a/assembler/main.c +++ b/assembler/main.c @@ -429,7 +429,7 @@ static struct code_output * do_assemble_insn(struct assembler_context *ctx, struct instruction *insn, unsigned int opcode) { - int i; + unsigned int i; struct operlist *ol; int nr_oper = 0; uint64_t code = 0; @@ -1017,7 +1017,7 @@ static void resolve_labels(struct assembler_context *ctx) { struct code_output *c; int addr; - int i; + unsigned int i; unsigned int current_address; /* Calculate the absolute addresses for each instruction. */ diff --git a/assembler/scanner.l b/assembler/scanner.l index 436d333..11f3890 100644 --- a/assembler/scanner.l +++ b/assembler/scanner.l @@ -183,7 +183,7 @@ static void interpret_cppinfo(const char *str) goto error; memset(tmp, 0, sizeof(tmp)); memcpy(tmp, str, min(sizeof(tmp) - 1, - (int)(found - str))); + (size_t)(found - str))); cur_lineinfo.lineno = strtoul(tmp, NULL, 10) - 1; str = found; str++; @@ -200,7 +200,7 @@ static void interpret_cppinfo(const char *str) memset(cur_lineinfo.file, 0, sizeof(cur_lineinfo.file)); memcpy(cur_lineinfo.file, str, min(sizeof(cur_lineinfo.file) - 1, - (int)(found - str))); + (size_t)(found - str))); return; error: diff --git a/disassembler/Makefile b/disassembler/Makefile index bf2e197..fe59ece 100644 --- a/disassembler/Makefile +++ b/disassembler/Makefile @@ -14,8 +14,10 @@ QUIET_SPARSE = @/bin/true endif PREFIX ?= /usr/local -CFLAGS ?= -O2 -fomit-frame-pointer -CFLAGS += -std=gnu99 -Wall -D_BSD_SOURCE -D_GNU_SOURCE +CFLAGS ?= -O2 -fomit-frame-pointer -pipe +CFLAGS += -std=gnu99 -D_GNU_SOURCE \ + -Wall -Wextra -Wformat=2 -Wundef -Wno-unused-parameter \ + -Wshadow -Wpointer-arith SPARSEFLAGS = $(CFLAGS) -D__transparent_union__=__unused__ -D_STRING_ARCH_unaligned=1 LDFLAGS ?= diff --git a/disassembler/main.c b/disassembler/main.c index 09e7643..b73c3bf 100644 --- a/disassembler/main.c +++ b/disassembler/main.c @@ -788,9 +788,9 @@ static void resolve_labels(struct disassembler_context *ctx) static void emit_asm(struct disassembler_context *ctx) { struct statement *stmt; - int first, i; + int first; int err; - unsigned int addr = 0; + unsigned int i, addr = 0; err = open_output_file(); if (err) @@ -808,14 +808,16 @@ static void emit_asm(struct disassembler_context *ctx) first = 1; for (i = 0; i < ARRAY_SIZE(stmt->u.insn.operands); i++) { if (!stmt->u.insn.operands[i] && - stmt->u.insn.is_labelref != i) + (stmt->u.insn.is_labelref < 0 || + (unsigned int)stmt->u.insn.is_labelref != i)) continue; if (first) fprintf(outfile, "\t"); if (!first) fprintf(outfile, ", "); first = 0; - if (stmt->u.insn.is_labelref == i) { + if (stmt->u.insn.is_labelref >= 0 && + (unsigned int)stmt->u.insn.is_labelref == i) { fprintf(outfile, "%s", stmt->u.insn.labelref->u.label.name); } else { -- 2.31.1