diff --git a/Makefile b/Makefile index 99d8dfc..9ac5771 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,7 @@ LDFLAGS = -Tkernel.ld LDFLAGS += -m elf64lriscv CFLAGS = -Wall -Werror -O +CFLAGS += -Wno-unused-result CFLAGS += -mcmodel=medany CFLAGS += -march=rv64gc -mabi=lp64 CFLAGS += -ffreestanding -fno-common -nostdlib -mno-relax diff --git a/kern/ispinlock.c b/kern/ispinlock.c index e2a9e79..4a7b751 100644 --- a/kern/ispinlock.c +++ b/kern/ispinlock.c @@ -4,7 +4,7 @@ void spinlock_init(spinlock_t *l) { l->v = 0; } -bool spin_trylock(spinlock_t *l) { +__attribute__((warn_unused_result)) bool spin_trylock(spinlock_t *l) { uint32_t old; // old = xchg_acquire(&l->v, 1) using AMO __asm__ volatile("amoswap.w.aq %0, %2, (%1)\n" : "=&r"(old) : "r"(&l->v), "r"(1u) : "memory");