address violations of MISRA C:2012 Rule 10.1
v5 cover address violations of MISRA C:2012 Rule 10.1
This series contains the leftover patches from [1] with the rename s/ISOLATE_LOW_BIT/ISOLATE_LSB/ applied. All the already committed patches from the aforementioned series are dropped.
[1] https://marc.info/?l=xen-devel&m=169841347803987
Nicola Vetrini (3):
arm/bitops: encapsulate violation of MISRA C:2012 Rule 10.1 xen/pdx: amend definition of PDX_GROUP_COUNT x86_64/mm: express macro CNT using ISOLATE_LSB
xen/arch/arm/include/asm/bitops.h | 4 ++-- xen/arch/x86/x86_64/mm.c | 12 ++++++------ xen/include/xen/pdx.h | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-)
Signature · 1 line
2.34.1
PATCH v5 1/3 arm/bitops: encapsulate violation of MISRA C:2012 Rule 10.1
The definitions of ffs{l}? violate Rule 10.1, by using the well-known pattern (x & -x); its usage is wrapped by the ISOLATE_LSB macro.
No functional change.
---
Changes in v4:
- Changed macro name.
Changes in v5:
- Changed macro name.
--- xen/arch/arm/include/asm/bitops.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
xen/arch/arm/include/asm/bitops.h +2 -2
@@ -155,8 +155,8 @@ static inline int fls(unsigned int x) } -#define ffs (x) ({ unsigned int __t = (x); fls(__t & -__t); }) -#define ffsl (x) ({ unsigned long __t = (x); flsl(__t & -__t); }) +#define ffs (x) ({ unsigned int __t = (x); fls(ISOLATE_LSB(__t)); }) +#define ffsl (x) ({ unsigned long __t = (x); flsl(ISOLATE_LSB(__t)); })/** * find_first_set_bit - find the first set bit in @word
Signature · 1 line
2.34.1
Re: [XEN PATCH v5 1/3] arm/bitops: encapsulate violation of MISRA C:2012 Rule 10.1
Quoted 7 lines · Nicola Vetrini
The definitions of ffs{l}? violate Rule 10.1, by using the well-known pattern (x & -x); its usage is wrapped by the
ISOLATE_LSBmacro.No functional change.
Signed-off-by Nicola Vetrini <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>
This patch failed my pre-push build test; apparently xen/macros.h needs including explicitly.
Jan
Re: [XEN PATCH v5 1/3] arm/bitops: encapsulate violation of MISRA C:2012 Rule 10.1
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Nicola Vetrini
The definitions of ffs{l}? violate Rule 10.1, by using the well-known pattern (x & -x); its usage is wrapped by the
ISOLATE_LSBmacro.No functional change.
Quoted 7 lines
Quoted 2 lines
Signed-off-by Nicola Vetrini <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>This patch failed my pre-push build test; apparently
xen/macros.hneeds including explicitly.Jan
Yes, indeed. I must have dropped that change when experimenting with single evaluation and then never reinstated it.
Signature · 2 lines
Nicola Vetrini, BSc Software Engineer, BUGSENG srl (https://bugseng.com)
Re: [XEN PATCH v5 1/3] arm/bitops: encapsulate violation of MISRA C:2012 Rule 10.1
Quoted 10 lines · Nicola Vetrini
Quoted 9 lines · Jan Beulich
Quoted 7 lines · Nicola Vetrini
The definitions of ffs{l}? violate Rule 10.1, by using the well-known pattern (x & -x); its usage is wrapped by the
ISOLATE_LSBmacro.No functional change.
Signed-off-by Nicola Vetrini <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>
Quoted 7 lines
Quoted 4 lines
This patch failed my pre-push build test; apparently
xen/macros.hneeds including explicitly.Jan
Yes, indeed. I must have dropped that change when experimenting with single evaluation and then never reinstated it.
Please re-send
PATCH v5 2/3 xen/pdx: amend definition of PDX_GROUP_COUNT
In reply to Nicola VetriniThe definition of PDX_GROUP_COUNT causes violations of MISRA C:2012 Rule 10.1, therefore the problematic part now uses the ISOLATE_LSB macro, which encapsulates the pattern.
---
Changes in v4:
- Changed macro name.
Changes in v5:
- Changed macro name.
--- xen/include/xen/pdx.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/include/xen/pdx.h +1 -1
@@ -70,7 +70,7 @@extern unsigned long max_pdx;#define PDX_GROUP_COUNT ((1 << PDX_GROUP_SHIFT) / \ - (sizeof(*frame_table) & -sizeof(*frame_table))) + (ISOLATE_LSB(sizeof(*frame_table))))extern unsigned long pdx_group_valid[];/**
Signature · 1 line
2.34.1
PATCH v5 3/3 x86_64/mm: express macro CNT using ISOLATE_LSB
In reply to Nicola VetriniThe various definitions of macro CNT (and the related BUILD_BUG_ON) can be rewritten using ISOLATE_LSB, encapsulating a violation of MISRA C:2012 Rule 10.1.
---
Changes in v4:
- Changed macro name
Changes in v5:
- Add A-by
- Changed macro name.
--- xen/arch/x86/x86_64/mm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
xen/arch/x86/x86_64/mm.c +6 -6
@@ -351,9 +351,9 @@ static int setup_compat_m2p_table(struct mem_hotadd_info *info) ~((1UL << (L2_PAGETABLE_SHIFT - 2)) - 1) );#define MFN (x) (((x) << L2_PAGETABLE_SHIFT) / sizeof(unsigned int)) -#define CNT ((sizeof(*frame_table) & -sizeof(*frame_table)) / \ +#define CNT (ISOLATE_LSB(sizeof(*frame_table)) / \ sizeof(*compat_machine_to_phys_mapping)) -BUILD_BUG_ON ((sizeof (*frame_table) & -sizeof (*frame_table)) % \ +BUILD_BUG_ON (ISOLATE_LSB (sizeof (*frame_table)) % \sizeof (*compat_machine_to_phys_mapping));for ( i = smap; i < emap; i += (1UL << (L2_PAGETABLE_SHIFT -2 )) )
@@ -410,10 +410,10 @@ static int setup_m2p_table(struct mem_hotadd_info *info) va =RO_MPT_VIRT_START + smap *sizeof (*machine_to_phys_mapping);#define MFN (x) (((x) << L2_PAGETABLE_SHIFT) / sizeof(unsigned long)) -#define CNT ((sizeof(*frame_table) & -sizeof(*frame_table)) / \ +#define CNT (ISOLATE_LSB(sizeof(*frame_table)) / \ sizeof(*machine_to_phys_mapping)) -BUILD_BUG_ON ((sizeof (*frame_table) & -sizeof (*frame_table)) % \ +BUILD_BUG_ON (ISOLATE_LSB (sizeof (*frame_table)) % \sizeof (*machine_to_phys_mapping)); i = smap;
@@ -539,7 +539,7 @@ void __init paging_init(void) mpt_size = (max_page *BYTES_PER_LONG ) + (1UL <<L2_PAGETABLE_SHIFT ) -1 ; mpt_size &= ~((1UL <<L2_PAGETABLE_SHIFT ) -1UL );#define MFN (x) (((x) << L2_PAGETABLE_SHIFT) / sizeof(unsigned long)) -#define CNT ((sizeof(*frame_table) & -sizeof(*frame_table)) / \ +#define CNT (ISOLATE_LSB(sizeof(*frame_table)) / \ sizeof(*machine_to_phys_mapping))BUILD_BUG_ON ((sizeof (*frame_table) & ~sizeof (*frame_table)) % \sizeof (*machine_to_phys_mapping));
@@ -666,7 +666,7 @@ void __init paging_init(void) mpt_size =0 ;#define MFN (x) (((x) << L2_PAGETABLE_SHIFT) / sizeof(unsigned int)) -#define CNT ((sizeof(*frame_table) & -sizeof(*frame_table)) / \ +#define CNT (ISOLATE_LSB(sizeof(*frame_table)) / \ sizeof(*compat_machine_to_phys_mapping))BUILD_BUG_ON ((sizeof (*frame_table) & ~sizeof (*frame_table)) % \sizeof (*compat_machine_to_phys_mapping));
Signature · 1 line
2.34.1