[PATCH v2] xen/decompress: resolve MISRA R5.5 identifier/macro name conflicts

Dmytro Prokopchuk1 posted 1 patch 5 days, 14 hours ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/025bc771fe1339dfae476037af86c6bfa1048382.1779654114.git.dmytro._5Fprokopchuk1@epam.com
xen/common/decompress.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
[PATCH v2] xen/decompress: resolve MISRA R5.5 identifier/macro name conflicts
Posted by Dmytro Prokopchuk1 5 days, 14 hours ago
Convert 'free' macro in 'decompress.h' from object-like to function-like
form.

The object-like macro '#define free xfree' performs unconditional text
replacement, causing conflicts with identifiers named 'free', such as
struct fields in 'page_info' unions defined in 'xen/arch/arm/include/asm/mm.h'.
Function-like macros only match when followed by parentheses, allowing
'free' to be used both as a macro and as a struct field without conflicts.

Applying function-like form to 'malloc', 'large_malloc' and 'large_free'
ensures consistent macro style.

Function-like macros also intentionally prevent uses where the underlying
function identifier is needed directly, such as taking a function pointer.
No such uses exist in the current Xen codebase.

Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
---
Changes in v2:
- converted other macros for consistency
- updated commit message wording
Link to v1:
https://patchew.org/Xen/69ef81a2f85b35e6231ae389bf271cad2bbd7dfc.1779394622.git.dmytro._5Fprokopchuk1@epam.com/
---
 xen/common/decompress.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/xen/common/decompress.h b/xen/common/decompress.h
index 034c833665..487856e1bc 100644
--- a/xen/common/decompress.h
+++ b/xen/common/decompress.h
@@ -9,11 +9,11 @@
 #include <xen/types.h>
 #include <xen/xmalloc.h>
 
-#define malloc xmalloc_bytes
-#define free xfree
+#define malloc(a) xmalloc_bytes(a)
+#define free(a) xfree(a)
 
-#define large_malloc xmalloc_bytes
-#define large_free xfree
+#define large_malloc(a) xmalloc_bytes(a)
+#define large_free(a) xfree(a)
 
 #else
 
-- 
2.43.0