[RFC PATCH 18/18] public: misra rule 20.7 deviation on memory.h

Luca Fancellu posted 18 patches 3 years, 1 month ago
There is a newer version of this series
[RFC PATCH 18/18] public: misra rule 20.7 deviation on memory.h
Posted by Luca Fancellu 3 years, 1 month ago
Cppcheck has found a violation of rule 20.7 for the macro
XENMEM_SHARING_OP_FIELD_MAKE_GREF, the argument "val" is used in an
expression, hence add parenthesis to the argument "val" to fix the
violation.

Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
---
 xen/include/public/memory.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/include/public/memory.h b/xen/include/public/memory.h
index 29cf5c823902..c5f0d31e235d 100644
--- a/xen/include/public/memory.h
+++ b/xen/include/public/memory.h
@@ -485,7 +485,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_mem_access_op_t);
 #define XENMEM_SHARING_OP_FIELD_IS_GREF_FLAG   (xen_mk_ullong(1) << 62)
 
 #define XENMEM_SHARING_OP_FIELD_MAKE_GREF(field, val)  \
-    (field) = (XENMEM_SHARING_OP_FIELD_IS_GREF_FLAG | val)
+    (field) = (XENMEM_SHARING_OP_FIELD_IS_GREF_FLAG | (val))
 #define XENMEM_SHARING_OP_FIELD_IS_GREF(field)         \
     ((field) & XENMEM_SHARING_OP_FIELD_IS_GREF_FLAG)
 #define XENMEM_SHARING_OP_FIELD_GET_GREF(field)        \
-- 
2.17.1
Re: [RFC PATCH 18/18] public: misra rule 20.7 deviation on memory.h
Posted by Jan Beulich 3 years, 1 month ago
On 20.12.2022 09:51, Luca Fancellu wrote:
> Cppcheck has found a violation of rule 20.7 for the macro
> XENMEM_SHARING_OP_FIELD_MAKE_GREF, the argument "val" is used in an
> expression, hence add parenthesis to the argument "val" to fix the
> violation.
> 
> Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>

Acked-by: Jan Beulich <jbeulich@suse.com>
again with an adjustment to the title.

Jan