All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] vPCI: resolve MISRA R10.1 boolean arithmetic type violation
@ 2026-10-07 20:39 Dmytro Prokopchuk1
  2026-10-08  7:47 ` Jan Beulich
  2026-10-13 15:18 ` Roger Pau Monné
  0 siblings, 2 replies; 3+ messages in thread
From: Dmytro Prokopchuk1 @ 2026-10-07 20:39 UTC (permalink / raw)
  To: xen-devel@lists.xenproject.org
  Cc: Dmytro Prokopchuk1, Roger Pau Monné, Stewart Hildebrand,
	Roger Pau Monné

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] vPCI: resolve MISRA R10.1 boolean arithmetic type violation
  2026-10-07 20:39 [PATCH v2] vPCI: resolve MISRA R10.1 boolean arithmetic type violation Dmytro Prokopchuk1
@ 2026-10-08  7:47 ` Jan Beulich
  2026-10-13 15:18 ` Roger Pau Monné
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Beulich @ 2026-10-08  7:47 UTC (permalink / raw)
  To: Dmytro Prokopchuk1
  Cc: Roger Pau Monné, Stewart Hildebrand,
	xen-devel@lists.xenproject.org

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>



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] vPCI: resolve MISRA R10.1 boolean arithmetic type violation
  2026-10-07 20:39 [PATCH v2] vPCI: resolve MISRA R10.1 boolean arithmetic type violation Dmytro Prokopchuk1
  2026-10-08  7:47 ` Jan Beulich
@ 2026-10-13 15:18 ` Roger Pau Monné
  1 sibling, 0 replies; 3+ messages in thread
From: Roger Pau Monné @ 2026-10-13 15:18 UTC (permalink / raw)
  To: Dmytro Prokopchuk1
  Cc: xen-devel@lists.xenproject.org, Stewart Hildebrand,
	Roger Pau Monné

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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-13 15:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-07 20:39 [PATCH v2] vPCI: resolve MISRA R10.1 boolean arithmetic type violation Dmytro Prokopchuk1
2026-10-08  7:47 ` Jan Beulich
2026-10-13 15:18 ` Roger Pau Monné

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.