Skip to contentSkip to conversation

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

PATCH In review Xenia Ragiadakou 3 participants 3 messages Aug 8, 2022 – Aug 9, 2022

lore
Share & tools
lore
#0 lore raw

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

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.

---
 xen/arch/arm/include/asm/regs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/include/asm/regs.h +1 -1
index 794721a103..0693a68131 100644
@@ -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)
 {
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#2 lore raw
In reply to Xenia Ragiadakou
Quoted 5 lines · Xenia Ragiadakou

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.

Quoted 20 lines
---
 xen/arch/arm/include/asm/regs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/include/asm/regs.h +1 -1
index 794721a103..0693a68131 100644
@@ -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)
 {
Signature · 1 line
2.34.1