xen/drivers/vpci/header.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
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>
---
In the V1 (https://patchew.org/Xen/e23266191a366abe66d8104783d97578aa8734a4.1779428826.git.dmytro._5Fprokopchuk1@epam.com/)
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
On Wed, Oct 07, 2026 at 08:39:52PM +0000, Dmytro Prokopchuk1 wrote: > 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: Roger Pau Monné <roger@xenproject.org> Thanks, Roger.
On 07.10.2026 22:39, Dmytro Prokopchuk1 wrote: > 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>
© 2016 - 2026 Red Hat, Inc.