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@citrix.com>
Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger@xenproject.org>
This commit is contained in:
Dmytro Prokopchuk authored and Jan Beulich committed 2026-10-14 09:24:19 +02:00
1 parent 6b30eca0e3
commit b19c512d19
1 file changed
+4 -4
+4 -4
View File
@@ -585,8 +585,8 @@ static void cf_check bar_write(
/* If the value written is the current one avoid printing a warning. */ /* If the value written is the current one avoid printing a warning. */
if ( val != (uint32_t)(bar->addr >> (hi ? 32 : 0)) ) if ( val != (uint32_t)(bar->addr >> (hi ? 32 : 0)) )
gprintk(XENLOG_WARNING, gprintk(XENLOG_WARNING,
"%pp: ignored BAR %zu write while mapped\n", "%pp: ignored BAR %u write while mapped\n",
&pdev->sbdf, bar - pdev->vpci->header.bars + hi); &pdev->sbdf, (reg - PCI_BASE_ADDRESS_0) / 4);
return; 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 the value written is the current one avoid printing a warning. */
if ( guest_addr != bar->guest_addr ) if ( guest_addr != bar->guest_addr )
gprintk(XENLOG_WARNING, gprintk(XENLOG_WARNING,
"%pp: ignored guest BAR %zu write while mapped\n", "%pp: ignored guest BAR %u write while mapped\n",
&pdev->sbdf, bar - pdev->vpci->header.bars + hi); &pdev->sbdf, (reg - PCI_BASE_ADDRESS_0) / 4);
return; return;
} }
bar->guest_addr = guest_addr; bar->guest_addr = guest_addr;
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.