From: Logan Gunthorpe <logang@deltatee.com>
To: Qian Cai <cai@lca.pw>, bhelgaas@google.com
Cc: jamessewart@arista.com, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH -next] pci: fix a -Wtype-limits compilation warning
Date: Wed, 18 Dec 2019 10:22:31 -0700 [thread overview]
Message-ID: <c2908ed5-b0a7-74a7-7d03-84ad38e1a95a@deltatee.com> (raw)
In-Reply-To: <20191218170004.5297-1-cai@lca.pw>
On 2019-12-18 10:00 a.m., Qian Cai wrote:
> The commit a7d06153eea2 ("PCI: Fix pci_add_dma_alias() bitmask size")
> introduced a compilation warning and a potential infinite loop because
> it is no longer possible to be self-terminated as u8 is always less than
> 256,
>
> In file included from ./include/linux/kernel.h:12,
> from ./include/asm-generic/bug.h:19,
> from ./arch/x86/include/asm/bug.h:83,
> from ./include/linux/bug.h:5,
> from ./include/linux/jump_label.h:250,
> from ./arch/x86/include/asm/string_64.h:6,
> from ./arch/x86/include/asm/string.h:5,
> from ./include/linux/string.h:20,
> from ./include/linux/uuid.h:12,
> from ./include/linux/mod_devicetable.h:13,
> from ./include/linux/pci.h:27,
> from drivers/pci/search.c:11:
> drivers/pci/search.c: In function 'pci_for_each_dma_alias':
> ./include/linux/bitops.h:30:13: warning: comparison is always true due
> to limited range of data type [-Wtype-limits]
> (bit) < (size); \
> ^
> drivers/pci/search.c:46:3: note: in expansion of macro 'for_each_set_bit'
> for_each_set_bit(devfn, pdev->dma_alias_mask, MAX_NR_DEVFNS) {
>
> Fixed it by using u16 for "devfn" in this occasion.
>
> Fixes: a7d06153eea2 ("PCI: Fix pci_add_dma_alias() bitmask size")
> Signed-off-by: Qian Cai <cai@lca.pw>
Makes sense to me,
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
> ---
> drivers/pci/search.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pci/search.c b/drivers/pci/search.c
> index 9e4dfae47252..42bc44d0e681 100644
> --- a/drivers/pci/search.c
> +++ b/drivers/pci/search.c
> @@ -41,7 +41,7 @@ int pci_for_each_dma_alias(struct pci_dev *pdev,
> * DMA, iterate over that too.
> */
> if (unlikely(pdev->dma_alias_mask)) {
> - u8 devfn;
> + u16 devfn;
>
> for_each_set_bit(devfn, pdev->dma_alias_mask, MAX_NR_DEVFNS) {
> ret = fn(pdev, PCI_DEVID(pdev->bus->number, devfn),
>
next prev parent reply other threads:[~2019-12-18 17:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-18 17:00 Qian Cai
2019-12-18 17:22 ` Logan Gunthorpe [this message]
2019-12-18 18:24 ` Bjorn Helgaas
2019-12-18 18:31 ` Logan Gunthorpe
2019-12-18 20:08 ` Qian Cai
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=c2908ed5-b0a7-74a7-7d03-84ad38e1a95a@deltatee.com \
--to=logang@deltatee.com \
--cc=bhelgaas@google.com \
--cc=cai@lca.pw \
--cc=jamessewart@arista.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
/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
all inboxes | Powered by JetHome®