From 91f75bdf1fc2fcde9efb5de420caeacd89e2ce0e Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Sat, 4 Jul 2015 11:47:19 +0200 Subject: [PATCH] Turned gcc warnings up to eleven Patch by Larry Doolittle --- Makefile | 14 ++++++++------ firmware/firmware.h | 6 +++--- firmware/irq.c | 2 +- firmware/multest.c | 6 +++--- firmware/sieve.c | 4 ++-- firmware/stats.c | 4 ++-- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index e5d07fd..ff8408b 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,9 @@ TEST_OBJS = $(addsuffix .o,$(basename $(wildcard tests/*.S))) FIRMWARE_OBJS = firmware/start.o firmware/irq.o firmware/print.o firmware/sieve.o firmware/multest.o firmware/stats.o -GCC_WARNS = -Wall -Wextra -Wshadow -Wundef +GCC_WARNS = -Wall -Wextra -Wshadow -Wundef -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings +GCC_WARNS += -Wredundant-decls -Wstrict-prototypes -Wmissing-prototypes -pedantic # -Wconversion +TOOLCHAIN_PREFIX = riscv64-unknown-elf- test: testbench.exe firmware/firmware.hex vvp -N testbench.exe @@ -44,23 +46,23 @@ firmware/firmware.hex: firmware/firmware.bin firmware/makehex.py python3 firmware/makehex.py $< > $@ firmware/firmware.bin: firmware/firmware.elf - riscv64-unknown-elf-objcopy -O binary $< $@ + $(TOOLCHAIN_PREFIX)objcopy -O binary $< $@ chmod -x $@ firmware/firmware.elf: $(FIRMWARE_OBJS) $(TEST_OBJS) firmware/sections.lds - riscv64-unknown-elf-gcc -Os -m32 -ffreestanding -nostdlib -o $@ \ + $(TOOLCHAIN_PREFIX)gcc -Os -m32 -ffreestanding -nostdlib -o $@ \ -Wl,-Bstatic,-T,firmware/sections.lds,-Map,firmware/firmware.map,--strip-debug \ $(FIRMWARE_OBJS) $(TEST_OBJS) -lgcc chmod -x $@ firmware/start.o: firmware/start.S - riscv64-unknown-elf-gcc -c -m32 -o $@ $< + $(TOOLCHAIN_PREFIX)gcc -c -m32 -o $@ $< firmware/%.o: firmware/%.c - riscv64-unknown-elf-gcc -c -m32 -march=RV32I -Os $(GCC_WARNS) -ffreestanding -nostdlib -o $@ $< + $(TOOLCHAIN_PREFIX)gcc -c -m32 -march=RV32I -Os --std=c99 $(GCC_WARNS) -ffreestanding -nostdlib -o $@ $< tests/%.o: tests/%.S tests/riscv_test.h tests/test_macros.h - riscv64-unknown-elf-gcc -c -m32 -o $@ -DTEST_FUNC_NAME=$(notdir $(basename $<)) \ + $(TOOLCHAIN_PREFIX)gcc -c -m32 -o $@ -DTEST_FUNC_NAME=$(notdir $(basename $<)) \ -DTEST_FUNC_TXT='"$(notdir $(basename $<))"' -DTEST_FUNC_RET=$(notdir $(basename $<))_ret $< toc: diff --git a/firmware/firmware.h b/firmware/firmware.h index f243f31..ce5e321 100644 --- a/firmware/firmware.h +++ b/firmware/firmware.h @@ -21,16 +21,16 @@ void print_dec(unsigned int val); void print_hex(unsigned int val); // sieve.c -void sieve(); +void sieve(void); // multest.c uint32_t hard_mul(uint32_t a, uint32_t b); uint32_t hard_mulh(uint32_t a, uint32_t b); uint32_t hard_mulhsu(uint32_t a, uint32_t b); uint32_t hard_mulhu(uint32_t a, uint32_t b); -void multest(); +void multest(void); // stats.c -void stats(); +void stats(void); #endif diff --git a/firmware/irq.c b/firmware/irq.c index 2d76b1a..2dff1b0 100644 --- a/firmware/irq.c +++ b/firmware/irq.c @@ -109,7 +109,7 @@ uint32_t *irq(uint32_t *regs, uint32_t irqs) print_dec(timer_irq_count); print_str("\n"); - __asm__("sbreak"); + __asm__ volatile ("sbreak"); } return regs; diff --git a/firmware/multest.c b/firmware/multest.c index 508ed36..c6323ec 100644 --- a/firmware/multest.c +++ b/firmware/multest.c @@ -7,7 +7,7 @@ #include "firmware.h" -uint32_t xorshift32() { +static uint32_t xorshift32(void) { static uint32_t x = 314159265; x ^= x << 13; x ^= x >> 17; @@ -15,7 +15,7 @@ uint32_t xorshift32() { return x; } -void multest() +void multest(void) { int i; for (i = 0; i < 10; i++) @@ -76,7 +76,7 @@ void multest() if (s_mul != h_mul || s_mulh != h_mulh || s_mulhsu != h_mulhsu || s_mulhu != h_mulhu) { print_str("ERROR!\n"); - asm volatile ("sbreak"); + __asm__ volatile ("sbreak"); return; } diff --git a/firmware/sieve.c b/firmware/sieve.c index 73550c8..20a45d8 100644 --- a/firmware/sieve.c +++ b/firmware/sieve.c @@ -52,7 +52,7 @@ static void print_prime(int idx, int val) hash = mkhash(hash, val); } -void sieve() +void sieve(void) { int i, j, k; int idx = 1; @@ -79,7 +79,7 @@ void sieve() print_str(" OK\n"); } else { print_str(" ERROR\n"); - asm volatile ("sbreak"); + __asm__ volatile ("sbreak"); } } diff --git a/firmware/stats.c b/firmware/stats.c index e0b6f6a..4a06751 100644 --- a/firmware/stats.c +++ b/firmware/stats.c @@ -25,10 +25,10 @@ static void stats_print_dec(unsigned int val, int digits, bool zero_pad) } } -void stats() +void stats(void) { unsigned int num_cycles, num_instr; - asm("rdcycle %0; rdinstret %1;" : "=r"(num_cycles), "=r"(num_instr)); + __asm__("rdcycle %0; rdinstret %1;" : "=r"(num_cycles), "=r"(num_instr)); print_str("Cycle counter ........"); stats_print_dec(num_cycles, 8, false); print_str("\nInstruction counter ..");