[PATCH 2/2] livepatch: address violations of MISRA C Rule 20.7

Dmytro Prokopchuk1 posted 2 patches 1 week, 3 days ago
[PATCH 2/2] livepatch: address violations of MISRA C Rule 20.7
Posted by Dmytro Prokopchuk1 1 week, 3 days ago
MISRA C Rule 20.7 states: "Expressions resulting from the expansion
of macro parameters shall be enclosed in parentheses".

In macros LIVEPATCH_ASSIGN_SINGLE_HOOK() and LIVEPATCH_ASSIGN_MULTI_HOOK()
add parentheses around the macro's parameter 'hook' to prevent against
unintended expansions.

No functional changes.

Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
---
 xen/common/livepatch.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c
index 7446533c8c..a9986c2aa8 100644
--- a/xen/common/livepatch.c
+++ b/xen/common/livepatch.c
@@ -660,13 +660,13 @@ static inline int livepatch_check_expectations(const struct payload *payload)
  * Perform section pointer and size validation: single hook sections must contain a
  * single pointer only.
  */
-#define LIVEPATCH_ASSIGN_SINGLE_HOOK(elf, hook, section_name) do {                        \
-    const struct livepatch_elf_sec *__sec = livepatch_elf_sec_by_name(elf, section_name); \
-    if ( !__sec )                                                                         \
-        break;                                                                            \
-    if ( !section_ok(elf, __sec, sizeof(*hook)) || __sec->sec->sh_size != sizeof(*hook) ) \
-        return -EINVAL;                                                                   \
-    hook = __sec->addr;                                                                   \
+#define LIVEPATCH_ASSIGN_SINGLE_HOOK(elf, hook, section_name) do {                            \
+    const struct livepatch_elf_sec *__sec = livepatch_elf_sec_by_name(elf, section_name);     \
+    if ( !__sec )                                                                             \
+        break;                                                                                \
+    if ( !section_ok(elf, __sec, sizeof(*(hook))) || __sec->sec->sh_size != sizeof(*(hook)) ) \
+        return -EINVAL;                                                                       \
+    hook = __sec->addr;                                                                       \
 } while (0)
 
 /*
@@ -678,10 +678,10 @@ static inline int livepatch_check_expectations(const struct payload *payload)
     const struct livepatch_elf_sec *__sec = livepatch_elf_sec_by_name(elf, section_name); \
     if ( !__sec )                                                                         \
         break;                                                                            \
-    if ( !section_ok(elf, __sec, sizeof(*hook)) )                                         \
+    if ( !section_ok(elf, __sec, sizeof(*(hook))) )                                       \
         return -EINVAL;                                                                   \
     hook = __sec->addr;                                                                   \
-    nhooks = __sec->sec->sh_size / sizeof(*hook);                                         \
+    nhooks = __sec->sec->sh_size / sizeof(*(hook));                                       \
 } while (0)
 
 static int prepare_payload(struct payload *payload,
-- 
2.43.0