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
struct instruction *insn,
unsigned int opcode)
{
- int i;
+ unsigned int i;
struct operlist *ol;
int nr_oper = 0;
uint64_t code = 0;
{
struct code_output *c;
int addr;
- int i;
+ unsigned int i;
unsigned int current_address;
/* Calculate the absolute addresses for each instruction. */
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++;
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:
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 ?=
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)
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 {