Turned gcc warnings up to eleven

Patch by Larry Doolittle
This commit is contained in:
Clifford Wolf 2015-07-04 11:47:19 +02:00
parent 2df7aadc7a
commit 91f75bdf1f
6 changed files with 19 additions and 17 deletions

View File

@ -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:

View File

@ -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

View File

@ -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;

View File

@ -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;
}

View File

@ -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");
}
}

View File

@ -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 ..");