From b19c512d19a970e9ab297164fd89a81f63ff3955 Mon Sep 17 00:00:00 2001 From: Dmytro Prokopchuk Date: Wed, 14 Oct 2026 09:24:19 +0200 Subject: [PATCH] vPCI: resolve MISRA R10.1 boolean arithmetic type violation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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é Signed-off-by: Dmytro Prokopchuk Reviewed-by: Jan Beulich Reviewed-by: Roger Pau Monné --- 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;