All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vPCI: resolve MISRA R10.1 boolean arithmetic type violation
@ 2026-05-22  6:13 Dmytro Prokopchuk1
  2026-05-22  6:40 ` Jan Beulich
  0 siblings, 1 reply; 12+ messages in thread
From: Dmytro Prokopchuk1 @ 2026-05-22  6:13 UTC (permalink / raw)
  To: xen-devel@lists.xenproject.org
  Cc: Dmytro Prokopchuk1, Roger Pau Monné, Stewart Hildebrand

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

Boolean values cannot be directly used in arithmetic operations.
Convert boolean to integer in vPCI header bar index calculation
using the ternary operator to satisfy strict type checking rule.

No functional changes.

Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
---
Test CI pipeline:
https://gitlab.com/xen-project/people/dimaprkp4k/xen/-/pipelines/2545399814
---
 xen/drivers/vpci/header.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index a760d8c32f..2b7f78728d 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -586,7 +586,7 @@ static void cf_check bar_write(
         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);
+                    &pdev->sbdf, bar - pdev->vpci->header.bars + (hi ? 1 : 0));
         return;
     }
 
@@ -647,7 +647,7 @@ static void cf_check guest_mem_bar_write(const struct pci_dev *pdev,
         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);
+                    &pdev->sbdf, bar - pdev->vpci->header.bars + (hi ? 1 : 0));
         return;
     }
     bar->guest_addr = guest_addr;
-- 
2.43.0


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

end of thread, other threads:[~2026-06-05  8:21 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-22  6:13 [PATCH] vPCI: resolve MISRA R10.1 boolean arithmetic type violation Dmytro Prokopchuk1
2026-05-22  6:40 ` Jan Beulich
2026-05-26 22:12   ` Stefano Stabellini
2026-05-27 14:34     ` Roger Pau Monné
2026-06-02  8:39     ` Jan Beulich
2026-06-03  1:41       ` Stefano Stabellini
2026-06-03  6:04         ` Jan Beulich
2026-06-03 12:54           ` Roger Pau Monné
2026-06-03 13:02             ` Jan Beulich
2026-06-03 20:43               ` Stefano Stabellini
2026-06-04  6:15                 ` Nicola Vetrini
2026-06-05  8:20                 ` Jan Beulich

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.