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

Xenia Ragiadakou posted 1 patch 1 year, 8 months ago
Test gitlab-ci failed
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20220804122907.1821730-1-burzalodowa@gmail.com
xen/include/xen/compiler.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] xen/compiler: Fix MISRA C 2012 Rule 20.7 violation
Posted by Xenia Ragiadakou 1 year, 8 months ago
In __must_be_array(), the macro parameter 'a' 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/include/xen/compiler.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/include/xen/compiler.h b/xen/include/xen/compiler.h
index 933aec09a9..a563130334 100644
--- a/xen/include/xen/compiler.h
+++ b/xen/include/xen/compiler.h
@@ -123,7 +123,7 @@
 
 /* &a[0] degrades to a pointer: a different type from an array */
 #define __must_be_array(a) \
-  BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0])))
+  BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&(a)[0])))
 
 #ifdef CONFIG_CC_HAS_VISIBILITY_ATTRIBUTE
 /* Results in more efficient PIC code (no indirections through GOT or PLT). */
-- 
2.34.1
Re: [PATCH] xen/compiler: Fix MISRA C 2012 Rule 20.7 violation
Posted by Jan Beulich 1 year, 8 months ago
On 04.08.2022 14:29, Xenia Ragiadakou wrote:
> In __must_be_array(), the macro parameter 'a' 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>

Acked-by: Jan Beulich <jbeulich@suse.com>