riscv: Apply a static assert to riscv_isa_ext_id
PATCH 1/1 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.
--- arch/riscv/include/asm/hwcap.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/riscv/include/asm/hwcap.h +2 -1
@@ -59,8 +59,9 @@ enum riscv_isa_ext_id {RISCV_ISA_EXT_ZIHINTPAUSE ,RISCV_ISA_EXT_SSTC ,RISCV_ISA_EXT_SVINVAL , - RISCV_ISA_EXT_ID_MAX = RISCV_ISA_EXT_MAX, + RISCV_ISA_EXT_ID_MAX }; +static_assert (RISCV_ISA_EXT_ID_MAX <=RISCV_ISA_EXT_MAX );/* * This enum represents the logical ID for each RISC-V ISA extension static
Signature · 7 lines
2.38.1 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Am Donnerstag, 1. Dezember 2022, 12:37:50 CET schrieb Andrew Jones:
Quoted 8 lines
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 puttingRISCV_ISA_EXT_ID_MAXto more work. Before it was redundant withRISCV_ISA_EXT_MAXand 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]>
Quoted 10 lines
--- arch/riscv/include/asm/hwcap.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/riscv/include/asm/hwcap.h +0
-0
arch/riscv/include/asm/hwcap.h enum riscv_isa_ext_id { · line 67
Quoted 10 lines
arch/riscv/include/asm/hwcap.h +2
-1@@ -59,8 +59,9 @@ enum riscv_isa_ext_id {RISCV_ISA_EXT_ZIHINTPAUSE ,RISCV_ISA_EXT_SSTC ,RISCV_ISA_EXT_SVINVAL , - RISCV_ISA_EXT_ID_MAX = RISCV_ISA_EXT_MAX, + RISCV_ISA_EXT_ID_MAX }; +static_assert (RISCV_ISA_EXT_ID_MAX <=RISCV_ISA_EXT_MAX );/* * This enum represents the logical ID for each RISC-V ISA extension static
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Quoted 17 lines · Andrew Jones
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 puttingRISCV_ISA_EXT_ID_MAXto more work. Before it was redundant withRISCV_ISA_EXT_MAXand 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]>--- arch/riscv/include/asm/hwcap.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/riscv/include/asm/hwcap.h +0
-0
arch/riscv/include/asm/hwcap.h enum riscv_isa_ext_id { · line 64
Quoted 7 lines
arch/riscv/include/asm/hwcap.h +2
-1@@ -59,8 +59,9 @@ enum riscv_isa_ext_id {RISCV_ISA_EXT_ZIHINTPAUSE ,RISCV_ISA_EXT_SSTC ,RISCV_ISA_EXT_SVINVAL , - RISCV_ISA_EXT_ID_MAX = RISCV_ISA_EXT_MAX, + RISCV_ISA_EXT_ID_MAX }; +static_assert (RISCV_ISA_EXT_ID_MAX <=RISCV_ISA_EXT_MAX );
FWIW checkpatch complains about the lack of a blank line prior to the static_assert, but dunno how much anyone cares about that. Lack of a blank line here makes the purpose more obvious to me /shrug
Quoted 11 lines
arch/riscv/include/asm/hwcap.h +0
-0/* * This enum represents the logical ID for each RISC-V ISA extension static Signature · 7 lines
2.38.1 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Quoted 13 lines · Conor Dooley
Quoted 12 lines · Andrew Jones
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 puttingRISCV_ISA_EXT_ID_MAXto more work. Before it was redundant withRISCV_ISA_EXT_MAXand 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]>--- arch/riscv/include/asm/hwcap.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 16 lines
arch/riscv/include/asm/hwcap.h enum riscv_isa_ext_id { · line 64
Quoted 12 lines
arch/riscv/include/asm/hwcap.h +2
-1@@ -59,8 +59,9 @@ enum riscv_isa_ext_id {RISCV_ISA_EXT_ZIHINTPAUSE ,RISCV_ISA_EXT_SSTC ,RISCV_ISA_EXT_SVINVAL , - RISCV_ISA_EXT_ID_MAX = RISCV_ISA_EXT_MAX, + RISCV_ISA_EXT_ID_MAX }; +static_assert (RISCV_ISA_EXT_ID_MAX <=RISCV_ISA_EXT_MAX );FWIW checkpatch complains about the lack of a blank line prior to the
static_assert, but dunno how much anyone cares about that. Lack of a blank line here makes the purpose more obvious to me /shrug
To me too. Hopefully checkpatch robots will feel the same.
Quoted 2 lines
Reviewed-by Conor Dooley <[email protected]>
Thanks,
drew
Quoted 8 lines
Quoted 8 lines
arch/riscv/include/asm/hwcap.h +0
-0/* * This enum represents the logical ID for each RISC-V ISA extension static Signature · 1 line
2.38.1
Quoted 4 lines
Quoted 4 lines
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
Palmer Dabbelt
AppliedQuoted 8 lines · Andrew Jones
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 puttingRISCV_ISA_EXT_ID_MAXto more work. Before it was redundant withRISCV_ISA_EXT_MAXand hence only used to document the limit. Now it grows with the enum and is used to check the limit.[...]
Applied, thanks!
[1/1] riscv: Apply a static assert to riscv_isa_ext_id
https://git.kernel.org/palmer/c/e923f4625ed3
Best regards,
Signature · 6 lines
Palmer Dabbelt <[email protected]> _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
This patch was applied to riscv/linux.git (for-next) by Palmer Dabbelt <[email protected]>:
Hello:
This patch was applied to riscv/linux.git (for-next) by Palmer Dabbelt <[email protected]>:
Quoted 8 lines · On Thu, 1 Dec 2022 12:37:50 +0100 you wrote:
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 puttingRISCV_ISA_EXT_ID_MAXto more work. Before it was redundant withRISCV_ISA_EXT_MAXand hence only used to document the limit. Now it grows with the enum and is used to check the limit.[...]
Here is the summary with links:
- riscv: Apply a static assert to riscv_isa_ext_id
https://git.kernel.org/riscv/c/e923f4625ed3
You are awesome, thank you!
Signature · 9 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv