53 lines
2.0 KiB
Diff
53 lines
2.0 KiB
Diff
|
|
From 3c108b874b8b142a42939d785d6706a44e7035d7 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Roque Arcudia Hernandez <roqueh@google.com>
|
||
|
|
Date: Fri, 1 Nov 2024 21:59:23 +0000
|
||
|
|
Subject: [PATCH] hw/pci: Add parenthesis to PCI_BUILD_BDF macro
|
||
|
|
MIME-Version: 1.0
|
||
|
|
Content-Type: text/plain; charset=UTF-8
|
||
|
|
Content-Transfer-Encoding: 8bit
|
||
|
|
|
||
|
|
The bus parameter in the macro PCI_BUILD_BDF is not surrounded by
|
||
|
|
parenthesis. This can create a compile error when warnings are
|
||
|
|
treated as errors or can potentially create runtime errors due to the
|
||
|
|
operator precedence.
|
||
|
|
|
||
|
|
For instance:
|
||
|
|
|
||
|
|
file.c:x:32: error: suggest parentheses around '-' inside '<<'
|
||
|
|
[-Werror=parentheses]
|
||
|
|
171 | uint16_t bdf = PCI_BUILD_BDF(a - b, sdev->devfn);
|
||
|
|
| ~~^~~
|
||
|
|
include/hw/pci/pci.h:19:41: note: in definition of macro
|
||
|
|
'PCI_BUILD_BDF'
|
||
|
|
19 | #define PCI_BUILD_BDF(bus, devfn) ((bus << 8) | (devfn))
|
||
|
|
| ^~~
|
||
|
|
cc1: all warnings being treated as errors
|
||
|
|
|
||
|
|
Signed-off-by: Roque Arcudia Hernandez <roqueh@google.com>
|
||
|
|
Reviewed-by: Nabih Estefan <nabihestefan@google.com>
|
||
|
|
Message-Id: <20241101215923.3399311-1-roqueh@google.com>
|
||
|
|
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
||
|
|
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
||
|
|
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
||
|
|
Signed-off-by: Zhongrui Tang <tangzhongrui_yewu@cmss.chinamobile.com>
|
||
|
|
---
|
||
|
|
include/hw/pci/pci.h | 2 +-
|
||
|
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||
|
|
|
||
|
|
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
|
||
|
|
index fa6313aabc..7cf7b5619a 100644
|
||
|
|
--- a/include/hw/pci/pci.h
|
||
|
|
+++ b/include/hw/pci/pci.h
|
||
|
|
@@ -15,7 +15,7 @@ extern bool pci_available;
|
||
|
|
#define PCI_BUS_NUM(x) (((x) >> 8) & 0xff)
|
||
|
|
#define PCI_SLOT(devfn) (((devfn) >> 3) & 0x1f)
|
||
|
|
#define PCI_FUNC(devfn) ((devfn) & 0x07)
|
||
|
|
-#define PCI_BUILD_BDF(bus, devfn) ((bus << 8) | (devfn))
|
||
|
|
+#define PCI_BUILD_BDF(bus, devfn) (((bus) << 8) | (devfn))
|
||
|
|
#define PCI_BDF_TO_DEVFN(x) ((x) & 0xff)
|
||
|
|
#define PCI_BUS_MAX 256
|
||
|
|
#define PCI_DEVFN_MAX 256
|
||
|
|
--
|
||
|
|
2.41.0.windows.1
|
||
|
|
|