Re: [PATCH v5 2/2] input: joystick: driver for Adafruit Seesaw Gamepad

From: kernel test robot
Date: Wed Oct 18 2023 - 20:11:44 EST


Hi Anshul,

kernel test robot noticed the following build warnings:

[auto build test WARNING on dtor-input/next]
[also build test WARNING on dtor-input/for-linus hid/for-next linus/master v6.6-rc6 next-20231018]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Anshul-Dalal/input-joystick-driver-for-Adafruit-Seesaw-Gamepad/20231017-160635
base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
patch link: https://lore.kernel.org/r/20231017034356.1436677-2-anshulusr%40gmail.com
patch subject: [PATCH v5 2/2] input: joystick: driver for Adafruit Seesaw Gamepad
config: sparc-allyesconfig (https://download.01.org/0day-ci/archive/20231019/202310190852.BCw4Ry7D-lkp@xxxxxxxxx/config)
compiler: sparc64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231019/202310190852.BCw4Ry7D-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202310190852.BCw4Ry7D-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

In file included from include/linux/thread_info.h:27,
from arch/sparc/include/asm/current.h:15,
from include/linux/sched.h:12,
from include/linux/delay.h:23,
from drivers/input/joystick/adafruit-seesaw.c:17:
drivers/input/joystick/adafruit-seesaw.c: In function 'seesaw_read_data':
>> include/linux/bitops.h:52:11: warning: array subscript 'long unsigned int[0]' is partly outside array bounds of 'u32[1]' {aka 'unsigned int[1]'} [-Warray-bounds=]
52 | __builtin_constant_p(*(const unsigned long *)(addr))) ? \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/bitops.h:61:41: note: in expansion of macro 'bitop'
61 | #define test_bit(nr, addr) bitop(_test_bit, nr, addr)
| ^~~~~
drivers/input/joystick/adafruit-seesaw.c:89:27: note: in expansion of macro 'test_bit'
89 | data->button_a = !test_bit(BUTTON_A, (long *)&result);
| ^~~~~~~~
drivers/input/joystick/adafruit-seesaw.c:87:13: note: object 'result' of size 4
87 | u32 result = get_unaligned_be32(&read_buf);
| ^~~~~~
In file included from include/linux/bitops.h:34:
In function 'generic_test_bit',
inlined from 'seesaw_read_data' at drivers/input/joystick/adafruit-seesaw.c:89:20:
>> include/asm-generic/bitops/generic-non-atomic.h:128:27: warning: array subscript 'long unsigned int[0]' is partly outside array bounds of 'u32[1]' {aka 'unsigned int[1]'} [-Warray-bounds=]
128 | return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
| ~~~~^~~~~~~~~~~~~~
drivers/input/joystick/adafruit-seesaw.c: In function 'seesaw_read_data':
drivers/input/joystick/adafruit-seesaw.c:87:13: note: object 'result' of size 4
87 | u32 result = get_unaligned_be32(&read_buf);
| ^~~~~~
In function 'generic_test_bit',
inlined from 'seesaw_read_data' at drivers/input/joystick/adafruit-seesaw.c:90:20:
>> include/asm-generic/bitops/generic-non-atomic.h:128:27: warning: array subscript 'long unsigned int[0]' is partly outside array bounds of 'u32[1]' {aka 'unsigned int[1]'} [-Warray-bounds=]
128 | return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
| ~~~~^~~~~~~~~~~~~~
drivers/input/joystick/adafruit-seesaw.c: In function 'seesaw_read_data':
drivers/input/joystick/adafruit-seesaw.c:87:13: note: object 'result' of size 4
87 | u32 result = get_unaligned_be32(&read_buf);
| ^~~~~~
In function 'generic_test_bit',
inlined from 'seesaw_read_data' at drivers/input/joystick/adafruit-seesaw.c:91:20:
>> include/asm-generic/bitops/generic-non-atomic.h:128:27: warning: array subscript 'long unsigned int[0]' is partly outside array bounds of 'u32[1]' {aka 'unsigned int[1]'} [-Warray-bounds=]
128 | return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
| ~~~~^~~~~~~~~~~~~~
drivers/input/joystick/adafruit-seesaw.c: In function 'seesaw_read_data':
drivers/input/joystick/adafruit-seesaw.c:87:13: note: object 'result' of size 4
87 | u32 result = get_unaligned_be32(&read_buf);
| ^~~~~~
In function 'generic_test_bit',
inlined from 'seesaw_read_data' at drivers/input/joystick/adafruit-seesaw.c:92:20:
>> include/asm-generic/bitops/generic-non-atomic.h:128:27: warning: array subscript 'long unsigned int[0]' is partly outside array bounds of 'u32[1]' {aka 'unsigned int[1]'} [-Warray-bounds=]
128 | return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
| ~~~~^~~~~~~~~~~~~~
drivers/input/joystick/adafruit-seesaw.c: In function 'seesaw_read_data':
drivers/input/joystick/adafruit-seesaw.c:87:13: note: object 'result' of size 4
87 | u32 result = get_unaligned_be32(&read_buf);
| ^~~~~~
In function 'generic_test_bit',
inlined from 'seesaw_read_data' at drivers/input/joystick/adafruit-seesaw.c:93:24:
>> include/asm-generic/bitops/generic-non-atomic.h:128:27: warning: array subscript 'long unsigned int[0]' is partly outside array bounds of 'u32[1]' {aka 'unsigned int[1]'} [-Warray-bounds=]
128 | return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
| ~~~~^~~~~~~~~~~~~~
drivers/input/joystick/adafruit-seesaw.c: In function 'seesaw_read_data':
drivers/input/joystick/adafruit-seesaw.c:87:13: note: object 'result' of size 4
87 | u32 result = get_unaligned_be32(&read_buf);
| ^~~~~~
In function 'generic_test_bit',
inlined from 'seesaw_read_data' at drivers/input/joystick/adafruit-seesaw.c:94:25:
>> include/asm-generic/bitops/generic-non-atomic.h:128:27: warning: array subscript 'long unsigned int[0]' is partly outside array bounds of 'u32[1]' {aka 'unsigned int[1]'} [-Warray-bounds=]
128 | return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
| ~~~~^~~~~~~~~~~~~~
drivers/input/joystick/adafruit-seesaw.c: In function 'seesaw_read_data':
drivers/input/joystick/adafruit-seesaw.c:87:13: note: object 'result' of size 4
87 | u32 result = get_unaligned_be32(&read_buf);
| ^~~~~~


vim +52 include/linux/bitops.h

0e862838f29014 Alexander Lobakin 2022-06-24 35
b03fc1173c0c2b Alexander Lobakin 2022-06-24 36 /*
b03fc1173c0c2b Alexander Lobakin 2022-06-24 37 * Many architecture-specific non-atomic bitops contain inline asm code and due
b03fc1173c0c2b Alexander Lobakin 2022-06-24 38 * to that the compiler can't optimize them to compile-time expressions or
b03fc1173c0c2b Alexander Lobakin 2022-06-24 39 * constants. In contrary, generic_*() helpers are defined in pure C and
b03fc1173c0c2b Alexander Lobakin 2022-06-24 40 * compilers optimize them just well.
b03fc1173c0c2b Alexander Lobakin 2022-06-24 41 * Therefore, to make `unsigned long foo = 0; __set_bit(BAR, &foo)` effectively
b03fc1173c0c2b Alexander Lobakin 2022-06-24 42 * equal to `unsigned long foo = BIT(BAR)`, pick the generic C alternative when
b03fc1173c0c2b Alexander Lobakin 2022-06-24 43 * the arguments can be resolved at compile time. That expression itself is a
b03fc1173c0c2b Alexander Lobakin 2022-06-24 44 * constant and doesn't bring any functional changes to the rest of cases.
b03fc1173c0c2b Alexander Lobakin 2022-06-24 45 * The casts to `uintptr_t` are needed to mitigate `-Waddress` warnings when
b03fc1173c0c2b Alexander Lobakin 2022-06-24 46 * passing a bitmap from .bss or .data (-> `!!addr` is always true).
b03fc1173c0c2b Alexander Lobakin 2022-06-24 47 */
e69eb9c460f128 Alexander Lobakin 2022-06-24 48 #define bitop(op, nr, addr) \
b03fc1173c0c2b Alexander Lobakin 2022-06-24 49 ((__builtin_constant_p(nr) && \
b03fc1173c0c2b Alexander Lobakin 2022-06-24 50 __builtin_constant_p((uintptr_t)(addr) != (uintptr_t)NULL) && \
b03fc1173c0c2b Alexander Lobakin 2022-06-24 51 (uintptr_t)(addr) != (uintptr_t)NULL && \
b03fc1173c0c2b Alexander Lobakin 2022-06-24 @52 __builtin_constant_p(*(const unsigned long *)(addr))) ? \
b03fc1173c0c2b Alexander Lobakin 2022-06-24 53 const##op(nr, addr) : op(nr, addr))
e69eb9c460f128 Alexander Lobakin 2022-06-24 54

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki