All of lore.kernel.org
 help / color / mirror / Atom feed
* [arnd-playground:warnings-5.10-2 49/55] include/linux/bitmap.h:636:18: warning: array subscript 1 is outside array bounds of 'long unsigned
@ 2020-11-24 20:40 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2020-11-24 20:40 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 10466 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git warnings-5.10-2
head:   6bf755201c867bd34e151e90a111722f74bd91cf
commit: bc440d869326e303a9e77f5b9369b9b2636caf67 [49/55] Kbuild: enable more warnings by default
config: x86_64-randconfig-s021-20201124 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.3-151-g540c2c4b-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git/commit/?id=bc440d869326e303a9e77f5b9369b9b2636caf67
        git remote add arnd-playground https://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git
        git fetch --no-tags arnd-playground warnings-5.10-2
        git checkout bc440d869326e303a9e77f5b9369b9b2636caf67
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64 

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

All warnings (new ones prefixed by >>):

   In file included from include/linux/cpumask.h:12,
                    from include/linux/smp.h:13,
                    from include/linux/lockdep.h:14,
                    from include/linux/mutex.h:17,
                    from include/linux/notifier.h:14,
                    from include/linux/clk.h:14,
                    from drivers/gpio/gpio-xilinx.c:9:
   drivers/gpio/gpio-xilinx.c: In function 'xgpio_set_multiple':
>> include/linux/bitmap.h:636:18: warning: array subscript 1 is outside array bounds of 'long unsigned int[1]' [-Warray-bounds]
     636 |   map[index + 1] &= ~BITMAP_LAST_WORD_MASK(start + nbits);
         |                  ^~
   In file included from include/linux/kasan-checks.h:5,
                    from include/asm-generic/rwonce.h:26,
                    from ./arch/x86/include/generated/asm/rwonce.h:1,
                    from include/linux/compiler.h:246,
                    from include/linux/build_bug.h:5,
                    from include/linux/bits.h:22,
                    from include/linux/bitops.h:6,
                    from drivers/gpio/gpio-xilinx.c:8:
   drivers/gpio/gpio-xilinx.c:147:17: note: while referencing 'old'
     147 |  DECLARE_BITMAP(old, 64);
         |                 ^~~
   include/linux/types.h:11:16: note: in definition of macro 'DECLARE_BITMAP'
      11 |  unsigned long name[BITS_TO_LONGS(bits)]
         |                ^~~~
   In file included from include/linux/cpumask.h:12,
                    from include/linux/smp.h:13,
                    from include/linux/lockdep.h:14,
                    from include/linux/mutex.h:17,
                    from include/linux/notifier.h:14,
                    from include/linux/clk.h:14,
                    from drivers/gpio/gpio-xilinx.c:9:
   include/linux/bitmap.h:637:18: warning: array subscript 1 is outside array bounds of 'long unsigned int[1]' [-Warray-bounds]
     637 |   map[index + 1] |= value >> space;
         |   ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
   In file included from include/linux/kasan-checks.h:5,
                    from include/asm-generic/rwonce.h:26,
                    from ./arch/x86/include/generated/asm/rwonce.h:1,
                    from include/linux/compiler.h:246,
                    from include/linux/build_bug.h:5,
                    from include/linux/bits.h:22,
                    from include/linux/bitops.h:6,
                    from drivers/gpio/gpio-xilinx.c:8:
   drivers/gpio/gpio-xilinx.c:147:17: note: while referencing 'old'
     147 |  DECLARE_BITMAP(old, 64);
         |                 ^~~
   include/linux/types.h:11:16: note: in definition of macro 'DECLARE_BITMAP'
      11 |  unsigned long name[BITS_TO_LONGS(bits)]
         |                ^~~~
   In file included from include/linux/cpumask.h:12,
                    from include/linux/smp.h:13,
                    from include/linux/lockdep.h:14,
                    from include/linux/mutex.h:17,
                    from include/linux/notifier.h:14,
                    from include/linux/clk.h:14,
                    from drivers/gpio/gpio-xilinx.c:9:
   include/linux/bitmap.h:636:18: warning: array subscript [1, 67108864] is outside array bounds of 'long unsigned int[1]' [-Warray-bounds]
     636 |   map[index + 1] &= ~BITMAP_LAST_WORD_MASK(start + nbits);
         |                  ^~
   In file included from include/linux/kasan-checks.h:5,
                    from include/asm-generic/rwonce.h:26,
                    from ./arch/x86/include/generated/asm/rwonce.h:1,
                    from include/linux/compiler.h:246,
                    from include/linux/build_bug.h:5,
                    from include/linux/bits.h:22,
                    from include/linux/bitops.h:6,
                    from drivers/gpio/gpio-xilinx.c:8:
   drivers/gpio/gpio-xilinx.c:147:17: note: while referencing 'old'
     147 |  DECLARE_BITMAP(old, 64);
         |                 ^~~
   include/linux/types.h:11:16: note: in definition of macro 'DECLARE_BITMAP'
      11 |  unsigned long name[BITS_TO_LONGS(bits)]
         |                ^~~~
   In file included from include/linux/cpumask.h:12,
                    from include/linux/smp.h:13,
                    from include/linux/lockdep.h:14,
                    from include/linux/mutex.h:17,
                    from include/linux/notifier.h:14,
                    from include/linux/clk.h:14,
                    from drivers/gpio/gpio-xilinx.c:9:
   include/linux/bitmap.h:637:18: warning: array subscript [1, 67108864] is outside array bounds of 'long unsigned int[1]' [-Warray-bounds]
     637 |   map[index + 1] |= value >> space;
         |   ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
   In file included from include/linux/kasan-checks.h:5,
                    from include/asm-generic/rwonce.h:26,
                    from ./arch/x86/include/generated/asm/rwonce.h:1,
                    from include/linux/compiler.h:246,
                    from include/linux/build_bug.h:5,
                    from include/linux/bits.h:22,
                    from include/linux/bitops.h:6,
                    from drivers/gpio/gpio-xilinx.c:8:
   drivers/gpio/gpio-xilinx.c:147:17: note: while referencing 'old'
     147 |  DECLARE_BITMAP(old, 64);
         |                 ^~~
   include/linux/types.h:11:16: note: in definition of macro 'DECLARE_BITMAP'
      11 |  unsigned long name[BITS_TO_LONGS(bits)]
         |                ^~~~
   In file included from include/linux/cpumask.h:12,
                    from include/linux/smp.h:13,
                    from include/linux/lockdep.h:14,
                    from include/linux/mutex.h:17,
                    from include/linux/notifier.h:14,
                    from include/linux/clk.h:14,
                    from drivers/gpio/gpio-xilinx.c:9:
   include/linux/bitmap.h:591:19: warning: array subscript [1, 67108864] is outside array bounds of 'long unsigned int[1]' [-Warray-bounds]
     591 |   value_high = map[index + 1] & BITMAP_LAST_WORD_MASK(start + nbits);
         |                ~~~^~~~~~~~~~~
   In file included from include/linux/kasan-checks.h:5,
                    from include/asm-generic/rwonce.h:26,

vim +636 include/linux/bitmap.h

169c474fb22d8a5 William Breathitt Gray 2019-12-04  611  
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  612  /**
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  613   * bitmap_set_value - set n-bit value within a memory region
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  614   * @map: address to the bitmap memory region
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  615   * @value: value of nbits
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  616   * @start: bit offset of the n-bit value
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  617   * @nbits: size of value in bits (must be between 1 and BITS_PER_LONG inclusive).
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  618   */
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  619  static inline void bitmap_set_value(unsigned long *map,
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  620  				    unsigned long value,
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  621  				    unsigned long start, unsigned long nbits)
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  622  {
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  623  	const size_t index = BIT_WORD(start);
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  624  	const unsigned long offset = start % BITS_PER_LONG;
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  625  	const unsigned long ceiling = round_up(start + 1, BITS_PER_LONG);
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  626  	const unsigned long space = ceiling - start;
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  627  
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  628  	value &= GENMASK(nbits - 1, 0);
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  629  
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  630  	if (space >= nbits) {
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  631  		map[index] &= ~(GENMASK(nbits - 1, 0) << offset);
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  632  		map[index] |= value << offset;
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  633  	} else {
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  634  		map[index + 0] &= ~BITMAP_FIRST_WORD_MASK(start);
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  635  		map[index + 0] |= value << offset;
3acfc95acd57710 Syed Nayyar Waris      2020-11-24 @636  		map[index + 1] &= ~BITMAP_LAST_WORD_MASK(start + nbits);
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  637  		map[index + 1] |= value >> space;
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  638  	}
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  639  }
3acfc95acd57710 Syed Nayyar Waris      2020-11-24  640  

:::::: The code at line 636 was first introduced by commit
:::::: 3acfc95acd57710ccc4f65d150295af1475bdc3e bitops: introduce the for_each_set_clump macro

:::::: TO: Syed Nayyar Waris <syednwaris@gmail.com>
:::::: CC: Stephen Rothwell <sfr@canb.auug.org.au>

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

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 28990 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-11-24 20:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-24 20:40 [arnd-playground:warnings-5.10-2 49/55] include/linux/bitmap.h:636:18: warning: array subscript 1 is outside array bounds of 'long unsigned kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.