From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Roque Arcudia Hernandez <roqueh@google.com>,
nabihestefan@google.com, mst@redhat.com,
marcel.apfelbaum@gmail.com
Cc: qemu-devel@nongnu.org, QEMU Trivial <qemu-trivial@nongnu.org>
Subject: Re: [PATCH] hw/pci: Add parenthesis to PCI_BUILD_BDF macro
Date: Sun, 3 Nov 2024 12:47:45 +0100 [thread overview]
Message-ID: <9d436b3b-4ff2-492b-8aea-c23bcfc2d7e7@linaro.org> (raw)
In-Reply-To: <20241101215923.3399311-1-roqueh@google.com>
On 1/11/24 18:59, Roque Arcudia Hernandez wrote:
> 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>
> ---
> 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 35d4fe0bbf..1daec974da 100644
> --- a/include/hw/pci/pci.h
> +++ b/include/hw/pci/pci.h
> @@ -16,7 +16,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
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
prev parent reply other threads:[~2024-11-03 11:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-01 21:59 [PATCH] hw/pci: Add parenthesis to PCI_BUILD_BDF macro Roque Arcudia Hernandez
2024-11-03 11:47 ` Philippe Mathieu-Daudé [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9d436b3b-4ff2-492b-8aea-c23bcfc2d7e7@linaro.org \
--to=philmd@linaro.org \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=nabihestefan@google.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=roqueh@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).