[XEN PATCH] xen/compiler: address violation of MISRA C Rule 20.9

Nicola Vetrini posted 1 patch 3 weeks, 4 days ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/d7c9e5cdabbcc3262f0e23fbf914cd6bb7e47990.1712321857.git.nicola.vetrini@bugseng.com
xen/include/xen/compiler.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[XEN PATCH] xen/compiler: address violation of MISRA C Rule 20.9
Posted by Nicola Vetrini 3 weeks, 4 days ago
The rule states:
"All identifiers used in the controlling expression of #if or #elif
preprocessing directives shall be #define'd before evaluation".
In this case, using defined(identifier) is a MISRA-compliant
way to achieve the same effect.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
---
This is the only outstanding violation of the rule, given the current
configurations. There are likely other sites that may benefit from
a gradual refactor.
---
 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 fc87a2edad7f..179ff23e62c5 100644
--- a/xen/include/xen/compiler.h
+++ b/xen/include/xen/compiler.h
@@ -30,7 +30,7 @@
 
 #define __weak        __attribute__((__weak__))
 
-#if !CONFIG_CC_IS_CLANG || CONFIG_CLANG_VERSION >= 140000
+#if !defined(CONFIG_CC_IS_CLANG) || CONFIG_CLANG_VERSION >= 140000
 # define nocall       __attribute__((__error__("Nonstandard ABI")))
 #else
 # define nocall
-- 
2.34.1
Re: [XEN PATCH] xen/compiler: address violation of MISRA C Rule 20.9
Posted by Jan Beulich 3 weeks, 4 days ago
On 05.04.2024 14:59, Nicola Vetrini wrote:
> The rule states:
> "All identifiers used in the controlling expression of #if or #elif
> preprocessing directives shall be #define'd before evaluation".
> In this case, using defined(identifier) is a MISRA-compliant
> way to achieve the same effect.
> 
> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>

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