Mailing List Archive

[XEN PATCH] xen/compiler: address violation of MISRA C Rule 20.9
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 [ In reply to ]
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>