lkml.org 
[lkml]   [2019]   [Dec]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH -next] pci: fix a -Wtype-limits compilation warning
Date
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>
---
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),
--
2.21.0 (Apple Git-122.2)
\
 
 \ /
  Last update: 2019-12-18 18:00    [W:0.040 / U:8.144 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site