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

[RFC PATCH 06/18] public: cppcheck: misra rule 20.7 on public/arch-arm.h



Cppcheck has found violations of rule 20.7 for the macros
___DEFINE_XEN_GUEST_HANDLE, set_xen_guest_handle_raw and __DECL_REG.
For the first and third finding, the macro parameters are never
used in an expression, cppcheck is not taking into account the
context where the arguments are used, so we can suppress the findings.
For the set_xen_guest_handle_raw, the argument is not involved in any
expression but it doesn't harm the code or readability to have
parenthesis on it, so fix it.

Eclair and coverity does not report these findings.

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

diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h
index 1528ced5097a..7afc0d1ca23d 100644
--- a/xen/include/public/arch-arm.h
+++ b/xen/include/public/arch-arm.h
@@ -156,6 +156,7 @@
 #define uint64_aligned_t uint64_t __attribute__((aligned(8)))
 
 #ifndef __ASSEMBLY__
+/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */
 #define ___DEFINE_XEN_GUEST_HANDLE(name, type)                  \
     typedef union { type *p; unsigned long q; }                 \
         __guest_handle_ ## name;                                \
@@ -180,7 +181,7 @@
     do {                                                    \
         __typeof__(&(hnd)) _sxghr_tmp = &(hnd);             \
         _sxghr_tmp->q = 0;                                  \
-        _sxghr_tmp->p = val;                                \
+        _sxghr_tmp->p = (val);                              \
     } while ( 0 )
 #define set_xen_guest_handle(hnd, val) set_xen_guest_handle_raw(hnd, val)
 
@@ -206,6 +207,7 @@ typedef uint64_t xen_ulong_t;
     }
 #else
 /* Non-gcc sources must always use the proper 64-bit name (e.g., x0). */
+/* SAF-1-false-positive-cppcheck R20.7 argument as text substitution */
 #define __DECL_REG(n64, n32) uint64_t n64
 #endif
 
-- 
2.17.1




 


Rackspace

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