diff mbox series

[RFC,14/18] public/x86: cppcheck: misra rule 20.7 deviation on xen-x86_32.h

Message ID 20221220085100.22848-15-luca.fancellu@arm.com (mailing list archive)
State Superseded
Headers show
Series cppcheck rule 20.7 fixes | expand

Commit Message

Luca Fancellu Dec. 20, 2022, 8:50 a.m. UTC
Cppcheck has found violations of rule 20.7 for the macros
___DEFINE_XEN_GUEST_HANDLE, set_xen_guest_handle_raw, __DECL_REG_LO8
and __DECL_REG_LO16.
For set_xen_guest_handle_raw, while the "val" argument is never used
in an expression, it doesn't harm the code or the readability to add
parenthesis, so add them to the argument.
For the other findings, the macro parameters are never used as an
expression, cppcheck is not taking into account the context for their
use, so we can suppress the finding.

Eclair and coverity does not report these findings.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
---
 xen/include/public/arch-x86/xen-x86_32.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/xen/include/public/arch-x86/xen-x86_32.h b/xen/include/public/arch-x86/xen-x86_32.h
index 139438e83534..6755f12044e4 100644
--- a/xen/include/public/arch-x86/xen-x86_32.h
+++ b/xen/include/public/arch-x86/xen-x86_32.h
@@ -74,6 +74,7 @@ 
 /* 32-/64-bit invariability for control interfaces (domctl/sysctl). */
 #if defined(__XEN__) || defined(__XEN_TOOLS__)
 #undef ___DEFINE_XEN_GUEST_HANDLE
+/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */
 #define ___DEFINE_XEN_GUEST_HANDLE(name, type)                  \
     typedef struct { type *p; }                                 \
         __guest_handle_ ## name;                                \
@@ -82,7 +83,7 @@ 
 #undef set_xen_guest_handle_raw
 #define set_xen_guest_handle_raw(hnd, val)                  \
     do { if ( sizeof(hnd) == 8 ) *(uint64_t *)&(hnd) = 0;   \
-         (hnd).p = val;                                     \
+         (hnd).p = (val);                                     \
     } while ( 0 )
 #define  int64_aligned_t  int64_t __attribute__((aligned(8)))
 #define uint64_aligned_t uint64_t __attribute__((aligned(8)))
@@ -96,6 +97,7 @@ 
 /* nothing */
 #elif defined(__XEN__) || defined(__XEN_TOOLS__)
 /* Anonymous unions include all permissible names (e.g., al/ah/ax/eax). */
+/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */
 #define __DECL_REG_LO8(which) union { \
     uint32_t e ## which ## x; \
     uint16_t which ## x; \
@@ -104,6 +106,7 @@ 
         uint8_t which ## h; \
     }; \
 }
+/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */
 #define __DECL_REG_LO16(name) union { \
     uint32_t e ## name, _e ## name; \
     uint16_t name; \