drivers/usb/host/ohci-at91.c:33:36: warning: comparison is always true due to limited range of data type

From: kernel test robot
Date: Fri Jun 12 2020 - 10:30:38 EST


Hi Krzysztof,

First bad commit (maybe != root cause):

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: b791d1bdf9212d944d749a5c7ff6febdba241771
commit: 88eaaecc44461f9fb147bf7ee6ccc6d4e9fc23e0 usb: host: Enable compile testing for some of drivers
date: 6 months ago
config: h8300-randconfig-r024-20200612 (attached as .config)
compiler: h8300-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 88eaaecc44461f9fb147bf7ee6ccc6d4e9fc23e0
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=h8300

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>, old ones prefixed by <<):

In file included from arch/h8300/include/asm/bug.h:8,
from include/linux/bug.h:5,
from include/linux/thread_info.h:12,
from include/asm-generic/current.h:5,
from ./arch/h8300/include/generated/asm/current.h:1,
from include/linux/mutex.h:14,
from include/linux/notifier.h:14,
from include/linux/clk.h:14,
from drivers/usb/host/ohci-at91.c:16:
include/linux/dma-mapping.h: In function 'dma_map_resource':
include/asm-generic/page.h:91:32: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
91 | #define pfn_valid(pfn) ((pfn) >= ARCH_PFN_OFFSET && ((pfn) - ARCH_PFN_OFFSET) < max_mapnr)
| ^~
include/asm-generic/bug.h:139:27: note: in definition of macro 'WARN_ON_ONCE'
139 | int __ret_warn_once = !!(condition); | ^~~~~~~~~
include/linux/dma-mapping.h:352:19: note: in expansion of macro 'pfn_valid'
352 | if (WARN_ON_ONCE(pfn_valid(PHYS_PFN(phys_addr))))
| ^~~~~~~~~
drivers/usb/host/ohci-at91.c: In function 'ohci_at91_hub_control':
>> drivers/usb/host/ohci-at91.c:33:36: warning: comparison is always true due to limited range of data type [-Wtype-limits]
33 | #define valid_port(index) ((index) >= 0 && (index) < AT91_MAX_USBH_PORTS)
| ^~
>> drivers/usb/host/ohci-at91.c:347:8: note: in expansion of macro 'valid_port'
347 | if (valid_port(wIndex)) {
| ^~~~~~~~~~
>> drivers/usb/host/ohci-at91.c:33:36: warning: comparison is always true due to limited range of data type [-Wtype-limits]
33 | #define valid_port(index) ((index) >= 0 && (index) < AT91_MAX_USBH_PORTS)
| ^~
drivers/usb/host/ohci-at91.c:356:8: note: in expansion of macro 'valid_port'
356 | if (valid_port(wIndex) && ohci_at91->sfr_regmap) {
| ^~~~~~~~~~
>> drivers/usb/host/ohci-at91.c:33:36: warning: comparison is always true due to limited range of data type [-Wtype-limits]
33 | #define valid_port(index) ((index) >= 0 && (index) < AT91_MAX_USBH_PORTS)
| ^~
drivers/usb/host/ohci-at91.c:371:8: note: in expansion of macro 'valid_port'
371 | if (valid_port(wIndex)) {
| ^~~~~~~~~~
>> drivers/usb/host/ohci-at91.c:33:36: warning: comparison is always true due to limited range of data type [-Wtype-limits]
33 | #define valid_port(index) ((index) >= 0 && (index) < AT91_MAX_USBH_PORTS)
| ^~
drivers/usb/host/ohci-at91.c:382:8: note: in expansion of macro 'valid_port'
382 | if (valid_port(wIndex))
| ^~~~~~~~~~
>> drivers/usb/host/ohci-at91.c:33:36: warning: comparison is always true due to limited range of data type [-Wtype-limits]
33 | #define valid_port(index) ((index) >= 0 && (index) < AT91_MAX_USBH_PORTS)
| ^~
drivers/usb/host/ohci-at91.c:391:8: note: in expansion of macro 'valid_port'
391 | if (valid_port(wIndex)) {
| ^~~~~~~~~~
>> drivers/usb/host/ohci-at91.c:33:36: warning: comparison is always true due to limited range of data type [-Wtype-limits]
33 | #define valid_port(index) ((index) >= 0 && (index) < AT91_MAX_USBH_PORTS)
| ^~
drivers/usb/host/ohci-at91.c:399:8: note: in expansion of macro 'valid_port'
399 | if (valid_port(wIndex) && ohci_at91->sfr_regmap) {
| ^~~~~~~~~~
>> drivers/usb/host/ohci-at91.c:33:36: warning: comparison is always true due to limited range of data type [-Wtype-limits]
33 | #define valid_port(index) ((index) >= 0 && (index) < AT91_MAX_USBH_PORTS)
| ^~
drivers/usb/host/ohci-at91.c:447:7: note: in expansion of macro 'valid_port'
447 | if (valid_port(wIndex)) {
| ^~~~~~~~~~
In file included from drivers/usb/host/ohci-at91.c:31:
At top level:
drivers/usb/host/ohci.h:165:18: warning: 'cc_to_error' defined but not used [-Wunused-const-variable=]
165 | static const int cc_to_error [16] = {
| ^~~~~~~~~~~

vim +33 drivers/usb/host/ohci-at91.c

39a269c09f854d Andrew Victor 2006-01-22 32
0ee6d1eeef7bf4 Nicolas Ferre 2012-03-21 @33 #define valid_port(index) ((index) >= 0 && (index) < AT91_MAX_USBH_PORTS)
0ee6d1eeef7bf4 Nicolas Ferre 2012-03-21 34 #define at91_for_each_port(index) \
0ee6d1eeef7bf4 Nicolas Ferre 2012-03-21 35 for ((index) = 0; (index) < AT91_MAX_USBH_PORTS; (index)++)
0ee6d1eeef7bf4 Nicolas Ferre 2012-03-21 36

:::::: The code at line 33 was first introduced by commit
:::::: 0ee6d1eeef7bf4e08aba37bf1da377b25e8d853a USB: ohci-at91: change maximum number of ports

:::::: TO: Nicolas Ferre <nicolas.ferre@xxxxxxxxx>
:::::: CC: Nicolas Ferre <nicolas.ferre@xxxxxxxxx>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip