All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Yury Norov <yury.norov@gmail.com>
Cc: oe-kbuild-all@lists.linux.dev
Subject: [norov:unload-bitmap 6/8] include/linux/bitmap.h:613:25: warning: array subscript 0 is outside array bounds of 'const long unsigned int[0]'
Date: Wed, 18 Oct 2023 20:54:03 +0800	[thread overview]
Message-ID: <202310182030.NH54Diui-lkp@intel.com> (raw)

tree:   https://github.com/norov/linux unload-bitmap
head:   d12b2cd2f2cace0c68638a2c474e4d0a32b533e5
commit: fe8066a1c1d802a28b2a805e80e908daea9a6ffe [6/8] lib/bitmap: add bitmap_{read,write}()
config: i386-randconfig-002-20231018 (https://download.01.org/0day-ci/archive/20231018/202310182030.NH54Diui-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231018/202310182030.NH54Diui-lkp@intel.com/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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202310182030.NH54Diui-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from lib/test_bitmap.c:8:
   In function 'bitmap_write',
       inlined from 'test_bitmap_read_write' at lib/test_bitmap.c:1312:2:
   include/linux/bitmap.h:666:12: warning: array subscript 0 is outside array bounds of 'long unsigned int[0]' [-Warray-bounds]
     666 |         map[index + 1] &= ~BITMAP_LAST_WORD_MASK(start + nbits);
         |         ~~~^~~~~~~~~~~
   include/linux/bitmap.h:666:24: warning: array subscript 0 is outside array bounds of 'long unsigned int[0]' [-Warray-bounds]
     666 |         map[index + 1] &= ~BITMAP_LAST_WORD_MASK(start + nbits);
         |                        ^~
   include/linux/bitmap.h:667:12: warning: array subscript 0 is outside array bounds of 'long unsigned int[0]' [-Warray-bounds]
     667 |         map[index + 1] |= (value >> space);
         |         ~~~^~~~~~~~~~~
   In function 'bitmap_read',
       inlined from 'test_bitmap_read_write' at lib/test_bitmap.c:1314:2:
>> include/linux/bitmap.h:613:25: warning: array subscript 0 is outside array bounds of 'const long unsigned int[0]' [-Warray-bounds]
     613 |         value_high = map[index + 1] & BITMAP_LAST_WORD_MASK(start + nbits);
         |                      ~~~^~~~~~~~~~~


vim +613 include/linux/bitmap.h

   589	
   590	/**
   591	 * bitmap_read - read a value of n-bits from the memory region
   592	 * @map: address to the bitmap memory region
   593	 * @start: bit offset of the n-bit value
   594	 * @nbits: size of value in bits, nonzero, up to BITS_PER_LONG
   595	 *
   596	 * Returns: value of nbits located at the @start bit offset within the @map
   597	 * memory region.
   598	 */
   599	static inline unsigned long bitmap_read(const unsigned long *map,
   600						unsigned long start,
   601						unsigned long nbits)
   602	{
   603		size_t index = BIT_WORD(start);
   604		unsigned long offset = start % BITS_PER_LONG;
   605		unsigned long space = BITS_PER_LONG - offset;
   606		unsigned long value_low, value_high;
   607	
   608		if (unlikely(!nbits))
   609			return 0;
   610		if (space >= nbits)
   611			return (map[index] >> offset) & GENMASK(nbits - 1, 0);
   612		value_low = map[index] & BITMAP_FIRST_WORD_MASK(start);
 > 613		value_high = map[index + 1] & BITMAP_LAST_WORD_MASK(start + nbits);
   614		return (value_low >> offset) | (value_high << space);
   615	}
   616	

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

                 reply	other threads:[~2023-10-18 12:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=202310182030.NH54Diui-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=yury.norov@gmail.com \
    /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 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.