|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v2] 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@xxxxxxxxxx> Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@xxxxxxxx> --- In the V1 (https://patchew.org/Xen/e23266191a366abe66d8104783d97578aa8734a4.1779428826.git.dmytro._5Fprokopchuk1@xxxxxxxx/) 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
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |