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

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


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>
  • Date: Mon, 8 Jun 2026 19:35:12 +0000
  • Accept-language: en-US, uk-UA, ru-RU
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gM/uJWznb4zSkV5by61LyWNXqXZ7xUU/M2EgvsQx6Zk=; b=DsqSEYLBLTN9zd260Vg0sX5lWa0fpvLrE7pskgyrKxO2TIh56P/5jMlPjT5UaMIX3vllG8wrtpoWrpwAj9WSf4mnhEkYOW+/m6bBrsSMHxi1jkpr1YurVhQn8bS5R0hiJ74+jp7ChuBTJspitfAbhzvz0BtYUu0WYhwarY6oXEPZZKGDmM1HkMgNennwL2+TR1ObHax9+liB3t5/bp8GE/LRT1/3eHQgy0YCCdzk4vHtUQmg27vqYIcSD2MPZUDbPjr3ytLrlbVxUqZBVQXecYaO77S4qLApYDfdfBOGp2XZu+1XW8o9uUYBgDvjCaFg0evp//TYqf/Fj9LwGqxu6g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FhGwSkvpGHV0kUchm/Gp9yHJtLfDdVDD+5ZAzcigOE0pcOp1P2EbEHb7SjPu3hcnq4QAaOBwGRfsvlA31JEUUbjqBPmmFstvrJBSdkK84vjs6yO/4RtpfqLBXdcINwNSgLg9M4dNR5leR8U1D75NZE2gYrHPBQD5kl81ZSNnvBqM5KKpanzFwy61eZew8rbD0clnq38fz0bQyYe06i5V/PGmlwmGo9HCONgoC5fVuoX4X4MrvljqFxbmAxTQWLRx9H3cMKLnxB5zZP3Mt7W5KnWVbgNto9g6ZCyx9vpLpP6Zp5Tv4nXDROyqbjoptlJrMWm0hr5ytOa+4cKFzoR23g==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • Delivery-date: Mon, 08 Jun 2026 19:35:35 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHc933sqAgjoPjitEesqeqMnsJ02w==
  • Thread-topic: [PATCH v3] xen/decompress: resolve MISRA R5.5 identifier/macro name conflicts

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.

Additionally moved 'large_{malloc,free}' past the #endif to reduce
redundancy.

While function-like macros 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@xxxxxxxx>
Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
---
Changes in v3:
- updated wording of the last paragraph in the commit message
- large_{malloc,free} moved past the #endif
- changed macro parameters naming ('s', 'p')
- added Jan's Acked-by
Link to v2:
- 
https://patchew.org/Xen/025bc771fe1339dfae476037af86c6bfa1048382.1779654114.git.dmytro._5Fprokopchuk1@xxxxxxxx/
Changes in v2:
- converted other macros for consistency
- updated commit message wording
---
 xen/common/decompress.h | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/xen/common/decompress.h b/xen/common/decompress.h
index 034c833665..b347d91980 100644
--- a/xen/common/decompress.h
+++ b/xen/common/decompress.h
@@ -9,11 +9,8 @@
 #include <xen/types.h>
 #include <xen/xmalloc.h>
 
-#define malloc xmalloc_bytes
-#define free xfree
-
-#define large_malloc xmalloc_bytes
-#define large_free xfree
+#define malloc(s) xmalloc_bytes(s)
+#define free(p) xfree(p)
 
 #else
 
@@ -21,9 +18,9 @@
 #define __init
 #define __initdata
 
-#define large_malloc malloc
-#define large_free free
-
 #endif
 
+#define large_malloc(s) malloc(s)
+#define large_free(p) free(p)
+
 #endif /* DECOMPRESS_H */
-- 
2.43.0



 


Rackspace

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