hw/pci: Add parenthesis to PCI_BUILD_BDF macro
authorRoque Arcudia Hernandez <roqueh@google.com>
Fri, 1 Nov 2024 21:59:23 +0000 (21:59 +0000)
committerMichael S. Tsirkin <mst@redhat.com>
Mon, 4 Nov 2024 21:03:25 +0000 (16:03 -0500)
commit26f2660bf7a3f0b6e9a939657ba656f4891ff46d
tree0eac927fad4407ba5817db3903b1ee6ab0535441
parent721c99aefcdb311bd41d20678d3935fd11454641
hw/pci: Add parenthesis to PCI_BUILD_BDF macro

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>
include/hw/pci/pci.h