diff mbox series

[XEN,for-4.19,2/9] arm/bitops: encapsulate violation of MISRA C:2012 Rule 10.1

Message ID a789098c17d5a45b7388dcf1333751df1126f123.1696514677.git.nicola.vetrini@bugseng.com (mailing list archive)
State Superseded
Headers show
Series address violations of MISRA C:2012 Rule 10.1 | expand

Commit Message

Nicola Vetrini Oct. 6, 2023, 8:26 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 LOWEST_POW2 macro.

No functional change.
---
 xen/arch/arm/include/asm/bitops.h | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Stefano Stabellini Oct. 10, 2023, 12:45 a.m. UTC | #1
On Fri, 6 Oct 2023, 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 LOWEST_POW2 macro.
> 
> No functional change.

Once we settle on a name for LOWEST_POW2 I can provided by reviewed-by
for this and the other patches in this series where LOWEST_POW2 is added


> ---
>  xen/arch/arm/include/asm/bitops.h | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/xen/arch/arm/include/asm/bitops.h b/xen/arch/arm/include/asm/bitops.h
> index 71ae14cab355..d119e1ccc952 100644
> --- a/xen/arch/arm/include/asm/bitops.h
> +++ b/xen/arch/arm/include/asm/bitops.h
> @@ -9,6 +9,8 @@
>  #ifndef _ARM_BITOPS_H
>  #define _ARM_BITOPS_H
>  
> +#include <xen/macros.h>
> +
>  #include <asm/asm_defns.h>
>  
>  /*
> @@ -155,8 +157,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(LOWEST_POW2(__t)); })
> +#define ffsl(x) ({ unsigned long __t = (x); flsl(LOWEST_POW2(__t)); })
>  
>  /**
>   * find_first_set_bit - find the first set bit in @word
> -- 
> 2.34.1
>
diff mbox series

Patch

diff --git a/xen/arch/arm/include/asm/bitops.h b/xen/arch/arm/include/asm/bitops.h
index 71ae14cab355..d119e1ccc952 100644
--- a/xen/arch/arm/include/asm/bitops.h
+++ b/xen/arch/arm/include/asm/bitops.h
@@ -9,6 +9,8 @@ 
 #ifndef _ARM_BITOPS_H
 #define _ARM_BITOPS_H
 
+#include <xen/macros.h>
+
 #include <asm/asm_defns.h>
 
 /*
@@ -155,8 +157,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(LOWEST_POW2(__t)); })
+#define ffsl(x) ({ unsigned long __t = (x); flsl(LOWEST_POW2(__t)); })
 
 /**
  * find_first_set_bit - find the first set bit in @word