[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH 08/18] xen: cppcheck: misra rule 20.7 deviation on init.h



Cppcheck has found violations of rule 20.7 for the macros
__init_call, presmp_initcall, __initcall and __exitcall.
For the first one, the macro parameter is never used as an expression,
it is used for text substitution but cppcheck is not taking into
account the context of use of the argument, so we can suppress the
finding.
For the other findings, the argument is not used as an expression,
but adding parenthesis doesn't harm the code or the readability,
hence add parenthesis on the argument.

Eclair and coverity does not report these findings.

Signed-off-by: Luca Fancellu <luca.fancellu@xxxxxxx>
---
 xen/include/xen/init.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/xen/include/xen/init.h b/xen/include/xen/init.h
index 0af0e234ec80..7c072b7c8cf8 100644
--- a/xen/include/xen/init.h
+++ b/xen/include/xen/init.h
@@ -15,6 +15,7 @@
 #define __initconstrel    __section(".init.rodata.rel")
 #define __exitdata        __used_section(".exit.data")
 #define __initsetup       __used_section(".init.setup")
+/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */
 #define __init_call(lvl)  __used_section(".initcall" lvl ".init")
 #define __exit_call       __used_section(".exitcall.exit")
 
@@ -65,11 +66,11 @@ typedef int (*initcall_t)(void);
 typedef void (*exitcall_t)(void);
 
 #define presmp_initcall(fn) \
-    const static initcall_t __initcall_##fn __init_call("presmp") = fn
+    const static initcall_t __initcall_##fn __init_call("presmp") = (fn)
 #define __initcall(fn) \
-    const static initcall_t __initcall_##fn __init_call("1") = fn
+    const static initcall_t __initcall_##fn __init_call("1") = (fn)
 #define __exitcall(fn) \
-    static exitcall_t __exitcall_##fn __exit_call = fn
+    static exitcall_t __exitcall_##fn __exit_call = (fn)
 
 void do_presmp_initcalls(void);
 void do_initcalls(void);
-- 
2.17.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.