]> xenbits.xensource.com Git - xen.git/commitdiff
libelf: address violations of MISRA C Rule 20.7
authorNicola Vetrini <nicola.vetrini@bugseng.com>
Thu, 25 Apr 2024 07:48:11 +0000 (09:48 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 25 Apr 2024 07:48:11 +0000 (09:48 +0200)
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@bugseng.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/common/libelf/libelf-private.h
xen/include/xen/libelf.h

index 98cac65bc50def116457e9905d946ea7e0df7db2..197d7a7623a344c94ba17416b175aedb9d049800 100644 (file)
@@ -26,7 +26,7 @@
 /* we would like to use elf->log_callback but we can't because
  * there is no vprintk in Xen */
 #define elf_msg(elf, fmt, args ... ) \
-   if (elf->verbose) printk(fmt, ## args )
+   if ((elf)->verbose) printk(fmt, ## args )
 #define elf_err(elf, fmt, args ... ) \
    printk(fmt, ## args )
 
index 9ac530acc2a8645de208f4a3d080646bb3fb56f5..a0675a4dc3527e8195ce0f2cf0af4e32613d5969 100644 (file)
@@ -288,7 +288,7 @@ bool elf_access_ok(struct elf_binary * elf,
 #define elf_store_val(elf, type, ptr, val)                              \
     ({                                                                  \
         typeof(type) elf_store__val = (val);                            \
-        elf_ptrval elf_store__targ = ptr;                               \
+        elf_ptrval elf_store__targ = (ptr);                             \
         if (elf_access_ok((elf), elf_store__targ,                       \
                           sizeof(elf_store__val))) {                   \
             elf_memcpy_unchecked((void*)elf_store__targ, &elf_store__val, \