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

[PATCH] generic/altp2m: address violations of MISRA C Rule 2.1


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>
  • Date: Thu, 9 Apr 2026 17:37:26 +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=oz6kcvmrfWfOFr05VYYyyaBTJCtYUCnt4WDyMt+tzgk=; b=iS0OzG7yG97Ehr3qr2c/a2fX/nKvyCqCvqQ6oh33yxQiOzuJyY60muG/sIrRT6n1qIX4QZL6xbrdjKnGSm4cNBrz8Hes0qxYc/Jpf9cVH3vCUmTGwts1Qv3qqDBzakTB+TmKN9U7lFwC+KkYP6UpT8CGmuz1KpGH4+lMjy3L0Ar4EZUo9zMqgvv5Y236Qa9eW1qojvUKrs0kh2pSbN7yjuGwqvJmzRd5sLsbbGUNdh0iogbSLvwBtmJ8U/VzjL8lYOZaaNA7rTbjtwjzHqSnCLS1MzEh7D6oWxmDO5DudL/whKRr6hPbrBXP1rhLus1YaOmthzexWnxHLxNJczy06g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RpP1adUHHeJ7+T5BXsQ6T0UgCNTBp/RIf0bma6Fj+79zOPDTfvHo+EcrbLcLURLsXf3ZCis8a0gcUA1l/3XFpqg0VDfIVwHS8h555trOyIDySrklPxLbkIygwZ65F3nS09zJobzbGhQh2Cm2PolCTBBtGMSpFRSUIi2GjjcoeEleCDJCZOAswM14hEJGjUUtr1E67vY96+Wyuur3K1NFbz1NIEYkD/r3VXl+dB2laNV8Z8Y0r4p0y5Wf/YZqVESPrCNteSLuFlat2b+v/EoS0JK7DEJz6V7sgl5FqRTqc/IXcNLM4ZhoTGE9p2pHzzMEcJfy8eUzUQxzOzou3/BCmA==
  • 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: Thu, 09 Apr 2026 17:37:33 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHcyEeH3FAPJgz8C0q4McY6u5ZElQ==
  • Thread-topic: [PATCH] generic/altp2m: address violations of MISRA C Rule 2.1

MISRA C Rule 2.1 states: "A project shall not contain unreachable code".

In certain build configurations, the function 'altp2m_vcpu_idx()' is defined
as an inline function that contains the 'BUG()' macro. This resulted in a
violation because the 'BUG()' macro makes the function non-returning.

To ensure compliance with MISRA C Rule 2.1, this patch removes the inline
function implementation and its BUG()-based unreachable code. It is replaced
with an unconditional function declaration for 'altp2m_vcpu_idx()'. It relies
on the compiler's Dead Code Elimination (DCE) to remove the unused function
in builds where it is not needed.

Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@xxxxxxxx>
---
Test CI pipeline:
https://gitlab.com/xen-project/people/dimaprkp4k/xen/-/pipelines/2441424553
---
 xen/include/asm-generic/altp2m.h | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/xen/include/asm-generic/altp2m.h b/xen/include/asm-generic/altp2m.h
index 39865a842a..df6b9a9c01 100644
--- a/xen/include/asm-generic/altp2m.h
+++ b/xen/include/asm-generic/altp2m.h
@@ -15,12 +15,7 @@ static inline bool altp2m_active(const struct domain *d)
 }
 
 /* Alternate p2m VCPU */
-static inline unsigned int altp2m_vcpu_idx(const struct vcpu *v)
-{
-    /* Not implemented on GENERIC, should not be reached. */
-    BUG();
-    return 0;
-}
+uint16_t altp2m_vcpu_idx(const struct vcpu *v);
 
 #endif /* __ASM_GENERIC_ALTP2M_H */
 
-- 
2.43.0



 


Rackspace

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