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

[PATCH v2] vPCI: resolve MISRA R10.1 boolean arithmetic type violation


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>
  • Date: Wed, 7 Oct 2026 20:39:52 +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=eG2iyk45wfTTtGBClH2QYspdg4KSKGMoA6n0lnGh65E=; b=LH8pqquNoUoJp8X11KvUzBH96d5Tn6xCHelMd+lxggYXnzPX46RiQpuDJgtZNH0IA6YlmSnfzI2vWB6WO5RzCmFp+DO1MNqDDrBe/Q2Ovh+al5MWMs0VZNPqPhWwq3XphgAuz7YDVsQpZIPcOJukirq0exoT0mJID4unUBEKxytJbzrGD7jCqv43jqtyUNrTDwkKhCE7qKHqw7fzrwIV2xTlh+DQi/Tt/IGvxhKCNr5JvMxKvcBNIZW0JYIeWmDqrY3I0chkHOqTcSM+SeOGQaEsFbnc0+9LlYi7+gy41FWE/4AnzkEeMmT4dxNAhZ1HTVOMzA5v5cqbHPlwV1vlgA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=E/nOhF+Jotbs1HZ/g5UZQxD1ccfqvr/LP/gVs4CFn1PqWwIF00QYu//ilR2Tqcy9LwBCjZcf4UDcSc2RACMVXNM2uSFXWEsBltUN8sz3UnG33eCy9NEPqU5QigCDsdjdMcK6VJUufftyElsMw23ClPgjDdfKJGGrTxnI2t3LH8C+wkArpSf7LQHXF2o4Rrmf/zhudmvoNjMxsJuod6mB+f+TpasuJmBMYqQu+bIMYVkIL33/9+VynY0RP6tl9+TpdkMhBScHmLgvPg5ITY9iOO2usuvoEwapOHXQOqxYADpAYBgICJQSXfcyNQ2KOs9Gn+SZE1oB2UGQh82aLTjO8w==
  • 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: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Stewart Hildebrand <stewart.hildebrand@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Wed, 07 Oct 2026 20:40:10 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHdVpwBNG1sftA3/ky6kFfXebDmZA==
  • Thread-topic: [PATCH v2] vPCI: resolve MISRA R10.1 boolean arithmetic type violation

MISRA C Rule 10.1 states: "Operands shall not be of an inappropriate
essential type".

bar_write() and guest_mem_bar_write() added the boolean 'hi' to a
pointer difference when printing the ignored BAR index. These handlers
are registered only for the memory BAR registers, so print
(reg - PCI_BASE_ADDRESS_0) / 4 instead. The expression has type
unsigned int, so use %u.

No functional changes.

Suggested-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@xxxxxxxx>
---
In the V1 
(https://patchew.org/Xen/e23266191a366abe66d8104783d97578aa8734a4.1779428826.git.dmytro._5Fprokopchuk1@xxxxxxxx/)
there was a long discussion, and I don't see a much sence to answer those 
questions
(actually I don't have additional proposals).

Looks like most agreed with Roger's alternative for this case.
So, let's proceed with that.

V2 test pipeline: 
https://gitlab.com/xen-project/people/dimaprkp4k/xen/-/pipelines/2923919592
---
 xen/drivers/vpci/header.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index d1c92cf77f..7e5f4b8a00 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -585,8 +585,8 @@ static void cf_check bar_write(
         /* If the value written is the current one avoid printing a warning. */
         if ( val != (uint32_t)(bar->addr >> (hi ? 32 : 0)) )
             gprintk(XENLOG_WARNING,
-                    "%pp: ignored BAR %zu write while mapped\n",
-                    &pdev->sbdf, bar - pdev->vpci->header.bars + hi);
+                    "%pp: ignored BAR %u write while mapped\n",
+                    &pdev->sbdf, (reg - PCI_BASE_ADDRESS_0) / 4);
         return;
     }
 
@@ -646,8 +646,8 @@ static void cf_check guest_mem_bar_write(const struct 
pci_dev *pdev,
         /* If the value written is the current one avoid printing a warning. */
         if ( guest_addr != bar->guest_addr )
             gprintk(XENLOG_WARNING,
-                    "%pp: ignored guest BAR %zu write while mapped\n",
-                    &pdev->sbdf, bar - pdev->vpci->header.bars + hi);
+                    "%pp: ignored guest BAR %u write while mapped\n",
+                    &pdev->sbdf, (reg - PCI_BASE_ADDRESS_0) / 4);
         return;
     }
     bar->guest_addr = guest_addr;
-- 
2.43.0

 


Rackspace

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