Skip to content

Commit e923f46

Browse files
jones-drewpalmer-dabbelt
authored andcommitted
riscv: Apply a static assert to riscv_isa_ext_id
Add a static assert to ensure a RISCV_ISA_EXT_* enum is never created with a value >= RISCV_ISA_EXT_MAX. We can do this by putting RISCV_ISA_EXT_ID_MAX to more work. Before it was redundant with RISCV_ISA_EXT_MAX and hence only used to document the limit. Now it grows with the enum and is used to check the limit. Signed-off-by: Andrew Jones <[email protected]> Reviewed-by: Conor Dooley <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent c3ec1e8 commit e923f46

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/riscv/include/asm/hwcap.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ enum riscv_isa_ext_id {
5959
RISCV_ISA_EXT_ZIHINTPAUSE,
6060
RISCV_ISA_EXT_SSTC,
6161
RISCV_ISA_EXT_SVINVAL,
62-
RISCV_ISA_EXT_ID_MAX = RISCV_ISA_EXT_MAX,
62+
RISCV_ISA_EXT_ID_MAX
6363
};
64+
static_assert(RISCV_ISA_EXT_ID_MAX <= RISCV_ISA_EXT_MAX);
6465

6566
/*
6667
* This enum represents the logical ID for each RISC-V ISA extension static

0 commit comments

Comments
 (0)