diff mbox series

[XEN,v5,1/3] arm/bitops: encapsulate violation of MISRA C:2012 Rule 10.1

Message ID c7728964a8e6afdb1f52ed93f3d7459cc72b85ee.1700724350.git.nicola.vetrini@bugseng.com (mailing list archive)
State New, archived
Headers show
Series address violations of MISRA C:2012 Rule 10.1 | expand

Commit Message

Nicola Vetrini Nov. 23, 2023, 7:37 a.m. UTC
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.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
---
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(-)

Comments

Jan Beulich Nov. 24, 2023, 8:06 a.m. UTC | #1
On 23.11.2023 08:37, Nicola Vetrini wrote:
> 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.
> 
> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

This patch failed my pre-push build test; apparently xen/macros.h needs
including explicitly.

Jan
Nicola Vetrini Nov. 24, 2023, 8:15 a.m. UTC | #2
On 2023-11-24 09:06, Jan Beulich wrote:
> On 23.11.2023 08:37, Nicola Vetrini wrote:
>> 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.
>> 
>> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
>> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
> 
> This patch failed my pre-push build test; apparently xen/macros.h needs
> including explicitly.
> 
> Jan

Yes, indeed. I must have dropped that change when experimenting with 
single evaluation and then never reinstated it.
Stefano Stabellini Nov. 29, 2023, 3:18 a.m. UTC | #3
On Fri, 24 Nov 2023, Nicola Vetrini wrote:
> On 2023-11-24 09:06, Jan Beulich wrote:
> > On 23.11.2023 08:37, Nicola Vetrini wrote:
> > > 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.
> > > 
> > > Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
> > > Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
> > 
> > This patch failed my pre-push build test; apparently xen/macros.h needs
> > including explicitly.
> > 
> > Jan
> 
> Yes, indeed. I must have dropped that change when experimenting with single
> evaluation and then never reinstated it.

Please re-send
diff mbox series

Patch

diff --git a/xen/arch/arm/include/asm/bitops.h b/xen/arch/arm/include/asm/bitops.h
index 71ae14cab355..673a8abae5bf 100644
--- a/xen/arch/arm/include/asm/bitops.h
+++ b/xen/arch/arm/include/asm/bitops.h
@@ -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