[PATCH] xen/arm: regs: Fix MISRA C 2012 Rule 20.7 violation

Xenia Ragiadakou posted 1 patch 1 year, 8 months ago
Test gitlab-ci passed
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20220808094837.1880522-1-burzalodowa@gmail.com
xen/arch/arm/include/asm/regs.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] xen/arm: regs: Fix MISRA C 2012 Rule 20.7 violation
Posted by Xenia Ragiadakou 1 year, 8 months ago
In macro psr_mode(), the macro parameter 'm' is used as expression and
therefore it is good to be enclosed in parentheses to prevent against
unintended expansions.

Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
---
 xen/arch/arm/include/asm/regs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/arm/include/asm/regs.h b/xen/arch/arm/include/asm/regs.h
index 794721a103..0693a68131 100644
--- a/xen/arch/arm/include/asm/regs.h
+++ b/xen/arch/arm/include/asm/regs.h
@@ -11,7 +11,7 @@
 #include <asm/current.h>
 #include <asm/processor.h>
 
-#define psr_mode(psr,m) (((psr) & PSR_MODE_MASK) == m)
+#define psr_mode(psr,m) (((psr) & PSR_MODE_MASK) == (m))
 
 static inline bool regs_mode_is_32bit(const struct cpu_user_regs *regs)
 {
-- 
2.34.1
Re: [PATCH] xen/arm: regs: Fix MISRA C 2012 Rule 20.7 violation
Posted by Stefano Stabellini 1 year, 8 months ago
On Mon, 8 Aug 2022, Xenia Ragiadakou wrote:
> In macro psr_mode(), the macro parameter 'm' is used as expression and
> therefore it is good to be enclosed in parentheses to prevent against
> unintended expansions.
> 
> Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

> ---
>  xen/arch/arm/include/asm/regs.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/xen/arch/arm/include/asm/regs.h b/xen/arch/arm/include/asm/regs.h
> index 794721a103..0693a68131 100644
> --- a/xen/arch/arm/include/asm/regs.h
> +++ b/xen/arch/arm/include/asm/regs.h
> @@ -11,7 +11,7 @@
>  #include <asm/current.h>
>  #include <asm/processor.h>
>  
> -#define psr_mode(psr,m) (((psr) & PSR_MODE_MASK) == m)
> +#define psr_mode(psr,m) (((psr) & PSR_MODE_MASK) == (m))
>  
>  static inline bool regs_mode_is_32bit(const struct cpu_user_regs *regs)
>  {
> -- 
> 2.34.1
>
Re: [PATCH] xen/arm: regs: Fix MISRA C 2012 Rule 20.7 violation
Posted by Rahul Singh 1 year, 8 months ago
Hi Xenia,

> On 8 Aug 2022, at 10:48 am, Xenia Ragiadakou <burzalodowa@gmail.com> wrote:
> 
> In macro psr_mode(), the macro parameter 'm' is used as expression and
> therefore it is good to be enclosed in parentheses to prevent against
> unintended expansions.
> 
> Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>

Reviewed-by: Rahul Singh <rahul.singh@arm.com>

Regards,
Rahul