Message ID | 20221201113750.18021-1-ajones@ventanamicro.com (mailing list archive) |
---|---|
State | Accepted |
Commit | e923f4625ed3ad7656c3f9f086c898798bafbbc5 |
Delegated to: | Palmer Dabbelt |
Headers | show |
Series | riscv: Apply a static assert to riscv_isa_ext_id | expand |
Context | Check | Description |
---|---|---|
conchuod/patch_count | success | Link |
conchuod/cover_letter | success | Single patches do not need cover letters |
conchuod/tree_selection | success | Guessed tree name to be for-next |
conchuod/fixes_present | success | Fixes tag not required for -next series |
conchuod/verify_signedoff | success | Signed-off-by tag matches author and committer |
conchuod/kdoc | success | Errors and warnings before: 0 this patch: 0 |
conchuod/module_param | success | Was 0 now: 0 |
conchuod/build_rv32_defconfig | success | Build OK |
conchuod/build_warn_rv64 | success | Errors and warnings before: 0 this patch: 0 |
conchuod/dtb_warn_rv64 | success | Errors and warnings before: 0 this patch: 0 |
conchuod/header_inline | success | No static functions without inline keyword in header files |
conchuod/checkpatch | warning | CHECK: Please use a blank line after function/struct/union/enum declarations |
conchuod/source_inline | success | Was 0 now: 0 |
conchuod/build_rv64_nommu_k210_defconfig | success | Build OK |
conchuod/verify_fixes | success | No Fixes tag |
conchuod/build_rv64_nommu_virt_defconfig | success | Build OK |
Am Donnerstag, 1. Dezember 2022, 12:37:50 CET schrieb 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 > 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 <ajones@ventanamicro.com> Reviewed-by: Heiko Stuebner <heiko.stuebner@vrull.eu> > --- > arch/riscv/include/asm/hwcap.h | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h > index b22525290073..86328e3acb02 100644 > --- a/arch/riscv/include/asm/hwcap.h > +++ b/arch/riscv/include/asm/hwcap.h > @@ -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 >
On Thu, Dec 01, 2022 at 12:37:50PM +0100, Andrew Jones 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 > 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 <ajones@ventanamicro.com> > --- > arch/riscv/include/asm/hwcap.h | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h > index b22525290073..86328e3acb02 100644 > --- a/arch/riscv/include/asm/hwcap.h > +++ b/arch/riscv/include/asm/hwcap.h > @@ -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 Reviewed-by: Conor Dooley <conor.dooley@microchip.com> > > /* > * This enum represents the logical ID for each RISC-V ISA extension static > -- > 2.38.1 > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv
On Thu, Dec 01, 2022 at 05:24:17PM +0000, Conor Dooley wrote: > On Thu, Dec 01, 2022 at 12:37:50PM +0100, Andrew Jones 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 > > 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 <ajones@ventanamicro.com> > > --- > > arch/riscv/include/asm/hwcap.h | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h > > index b22525290073..86328e3acb02 100644 > > --- a/arch/riscv/include/asm/hwcap.h > > +++ b/arch/riscv/include/asm/hwcap.h > > @@ -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. > > Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Thanks, drew > > > > > /* > > * This enum represents the logical ID for each RISC-V ISA extension static > > -- > > 2.38.1 > > > > > > _______________________________________________ > > linux-riscv mailing list > > linux-riscv@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/linux-riscv
On Thu, 1 Dec 2022 12:37:50 +0100, Andrew Jones 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 > 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. > > [...] Applied, thanks! [1/1] riscv: Apply a static assert to riscv_isa_ext_id https://git.kernel.org/palmer/c/e923f4625ed3 Best regards,
Hello: This patch was applied to riscv/linux.git (for-next) by Palmer Dabbelt <palmer@rivosinc.com>: 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 > 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. > > [...] 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!
diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h index b22525290073..86328e3acb02 100644 --- a/arch/riscv/include/asm/hwcap.h +++ b/arch/riscv/include/asm/hwcap.h @@ -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
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 <ajones@ventanamicro.com> --- arch/riscv/include/asm/hwcap.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)