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

[xen staging] xen/unaligned: address violation of MISRA C Rule 20.7



commit 8e22c78e171bcc71dc4f7f6549a0a60c958f1465
Author:     Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
AuthorDate: Tue Apr 30 16:28:15 2024 +0200
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Thu May 9 18:19:49 2024 +0100

    xen/unaligned: address violation of MISRA C Rule 20.7
    
    MISRA C Rule 20.7 states: "Expressions resulting from the expansion
    of macro parameters shall be enclosed in parentheses". Therefore, some
    macro definitions should gain additional parentheses to ensure that all
    current and future users will be safe with respect to expansions that
    can possibly alter the semantics of the passed-in macro parameter.
    
    No functional change.
    
    Signed-off-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
    Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 tools/include/xen-tools/common-macros.h | 2 +-
 xen/include/xen/unaligned.h             | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/include/xen-tools/common-macros.h 
b/tools/include/xen-tools/common-macros.h
index 07aed92684..60912225cb 100644
--- a/tools/include/xen-tools/common-macros.h
+++ b/tools/include/xen-tools/common-macros.h
@@ -102,7 +102,7 @@
 
 #define put_unaligned_t(type, val, ptr) do {                        \
     struct { type x; } __packed *ptr_ = (typeof(ptr_))(ptr);        \
-    ptr_->x = val;                                                  \
+    ptr_->x = (val);                                                \
 } while (0)
 
 #define get_unaligned(ptr)      get_unaligned_t(typeof(*(ptr)), ptr)
diff --git a/xen/include/xen/unaligned.h b/xen/include/xen/unaligned.h
index 3eda0ece11..d9bb599e65 100644
--- a/xen/include/xen/unaligned.h
+++ b/xen/include/xen/unaligned.h
@@ -19,7 +19,7 @@
 
 #define put_unaligned_t(type, val, ptr) do {                           \
        struct { type x; } __packed *ptr_ = (typeof(ptr_))(ptr);        \
-       ptr_->x = val;                                                  \
+       ptr_->x = (val);                                                \
 } while (0)
 
 #define get_unaligned(ptr)     get_unaligned_t(typeof(*(ptr)), ptr)
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

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