mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: kbuild test robot <lkp@intel.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: kbuild-all@01.org, linux-wireless@vger.kernel.org,
	linux-kernel@vger.kernel.org, John Garry <john.garry@huawei.com>,
	Johannes Berg <johannes.berg@intel.com>
Subject: Re: [PATCH] bitfield: use BUILD_BUG_ON_ZERO()
Date: Sat, 13 Oct 2018 09:22:44 +0800	[thread overview]
Message-ID: <201810130921.h77LERke%fengguang.wu@intel.com> (raw)
In-Reply-To: <20181012092104.2361-1-johannes@sipsolutions.net>

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

Hi Johannes,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v4.19-rc7 next-20181012]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Johannes-Berg/bitfield-use-BUILD_BUG_ON_ZERO/20181013-081047
config: x86_64-randconfig-s2-10130838 (attached as .config)
compiler: gcc-6 (Debian 6.4.0-9) 6.4.0 20171026
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   In file included from include/linux/kernel.h:15:0,
                    from include/linux/list.h:9,
                    from include/linux/resource_ext.h:17,
                    from include/linux/acpi.h:26,
                    from drivers/iio/chemical/bme680_core.c:11:
   drivers/iio/chemical/bme680_core.c: In function 'bme680_chip_config':
   include/linux/build_bug.h:29:45: error: bit-field '<anonymous>' width not an integer constant
    #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
                                                ^
>> include/linux/bitfield.h:57:2: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
     BUILD_BUG_ON_ZERO(__builtin_constant_p(_val) ?   \
     ^~~~~~~~~~~~~~~~~
>> include/linux/bitfield.h:82:3: note: in expansion of macro '__BF_FIELD_CHECK'
     (__BF_FIELD_CHECK(_mask, 0ULL, _val) +    \
      ^~~~~~~~~~~~~~~~
>> drivers/iio/chemical/bme680_core.c:525:12: note: in expansion of macro 'FIELD_PREP'
     u8 osrs = FIELD_PREP(BME680_OSRS_HUMIDITY_MASK,
               ^~~~~~~~~~
   include/linux/build_bug.h:29:45: error: bit-field '<anonymous>' width not an integer constant
    #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
                                                ^
>> include/linux/bitfield.h:57:2: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
     BUILD_BUG_ON_ZERO(__builtin_constant_p(_val) ?   \
     ^~~~~~~~~~~~~~~~~
>> include/linux/bitfield.h:82:3: note: in expansion of macro '__BF_FIELD_CHECK'
     (__BF_FIELD_CHECK(_mask, 0ULL, _val) +    \
      ^~~~~~~~~~~~~~~~
   drivers/iio/chemical/bme680_core.c:547:9: note: in expansion of macro 'FIELD_PREP'
     osrs = FIELD_PREP(BME680_OSRS_TEMP_MASK, data->oversampling_temp + 1) |
            ^~~~~~~~~~
   include/linux/build_bug.h:29:45: error: bit-field '<anonymous>' width not an integer constant
    #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
                                                ^
>> include/linux/bitfield.h:57:2: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
     BUILD_BUG_ON_ZERO(__builtin_constant_p(_val) ?   \
     ^~~~~~~~~~~~~~~~~
>> include/linux/bitfield.h:82:3: note: in expansion of macro '__BF_FIELD_CHECK'
     (__BF_FIELD_CHECK(_mask, 0ULL, _val) +    \
      ^~~~~~~~~~~~~~~~
   drivers/iio/chemical/bme680_core.c:548:9: note: in expansion of macro 'FIELD_PREP'
            FIELD_PREP(BME680_OSRS_PRESS_MASK, data->oversampling_press + 1);
            ^~~~~~~~~~
--
   In file included from drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c:33:0:
   drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c: In function 'st_lsm6dsx_set_fifo_mode':
   include/linux/build_bug.h:29:45: error: bit-field '<anonymous>' width not an integer constant
    #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
                                                ^
   include/linux/regmap.h:77:42: note: in definition of macro 'regmap_update_bits'
     regmap_update_bits_base(map, reg, mask, val, NULL, false, false)
                                             ^~~
>> include/linux/bitfield.h:57:2: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
     BUILD_BUG_ON_ZERO(__builtin_constant_p(_val) ?   \
     ^~~~~~~~~~~~~~~~~
>> include/linux/bitfield.h:82:3: note: in expansion of macro '__BF_FIELD_CHECK'
     (__BF_FIELD_CHECK(_mask, 0ULL, _val) +    \
      ^~~~~~~~~~~~~~~~
>> drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c:166:6: note: in expansion of macro 'FIELD_PREP'
         FIELD_PREP(ST_LSM6DSX_FIFO_MODE_MASK,
         ^~~~~~~~~~
   drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c: In function 'st_lsm6dsx_set_fifo_odr':
   include/linux/build_bug.h:29:45: error: bit-field '<anonymous>' width not an integer constant
    #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
                                                ^
   include/linux/regmap.h:77:42: note: in definition of macro 'regmap_update_bits'
     regmap_update_bits_base(map, reg, mask, val, NULL, false, false)
                                             ^~~
>> include/linux/bitfield.h:57:2: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
     BUILD_BUG_ON_ZERO(__builtin_constant_p(_val) ?   \
     ^~~~~~~~~~~~~~~~~
>> include/linux/bitfield.h:82:3: note: in expansion of macro '__BF_FIELD_CHECK'
     (__BF_FIELD_CHECK(_mask, 0ULL, _val) +    \
      ^~~~~~~~~~~~~~~~
   drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c:185:6: note: in expansion of macro 'FIELD_PREP'
         FIELD_PREP(ST_LSM6DSX_FIFO_ODR_MASK, data));
         ^~~~~~~~~~
   drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c: In function 'st_lsm6dsx_fifo_setup':
   include/linux/build_bug.h:29:45: error: bit-field '<anonymous>' width not an integer constant
    #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
                                                ^
   include/linux/regmap.h:77:42: note: in definition of macro 'regmap_update_bits'
     regmap_update_bits_base(map, reg, mask, val, NULL, false, false)
                                             ^~~
>> include/linux/bitfield.h:57:2: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
     BUILD_BUG_ON_ZERO(__builtin_constant_p(_val) ?   \
     ^~~~~~~~~~~~~~~~~
>> include/linux/bitfield.h:82:3: note: in expansion of macro '__BF_FIELD_CHECK'
     (__BF_FIELD_CHECK(_mask, 0ULL, _val) +    \
      ^~~~~~~~~~~~~~~~
   drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c:529:6: note: in expansion of macro 'FIELD_PREP'
         FIELD_PREP(ST_LSM6DSX_REG_HLACTIVE_MASK,
         ^~~~~~~~~~
--
   In file included from include/linux/kernel.h:15:0,
                    from include/linux/list.h:9,
                    from include/linux/resource_ext.h:17,
                    from include/linux/acpi.h:26,
                    from drivers/iio//chemical/bme680_core.c:11:
   drivers/iio//chemical/bme680_core.c: In function 'bme680_chip_config':
   include/linux/build_bug.h:29:45: error: bit-field '<anonymous>' width not an integer constant
    #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
                                                ^
>> include/linux/bitfield.h:57:2: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
     BUILD_BUG_ON_ZERO(__builtin_constant_p(_val) ?   \
     ^~~~~~~~~~~~~~~~~
>> include/linux/bitfield.h:82:3: note: in expansion of macro '__BF_FIELD_CHECK'
     (__BF_FIELD_CHECK(_mask, 0ULL, _val) +    \
      ^~~~~~~~~~~~~~~~
   drivers/iio//chemical/bme680_core.c:525:12: note: in expansion of macro 'FIELD_PREP'
     u8 osrs = FIELD_PREP(BME680_OSRS_HUMIDITY_MASK,
               ^~~~~~~~~~
   include/linux/build_bug.h:29:45: error: bit-field '<anonymous>' width not an integer constant
    #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
                                                ^
>> include/linux/bitfield.h:57:2: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
     BUILD_BUG_ON_ZERO(__builtin_constant_p(_val) ?   \
     ^~~~~~~~~~~~~~~~~
>> include/linux/bitfield.h:82:3: note: in expansion of macro '__BF_FIELD_CHECK'
     (__BF_FIELD_CHECK(_mask, 0ULL, _val) +    \
      ^~~~~~~~~~~~~~~~
   drivers/iio//chemical/bme680_core.c:547:9: note: in expansion of macro 'FIELD_PREP'
     osrs = FIELD_PREP(BME680_OSRS_TEMP_MASK, data->oversampling_temp + 1) |
            ^~~~~~~~~~
   include/linux/build_bug.h:29:45: error: bit-field '<anonymous>' width not an integer constant
    #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
                                                ^
>> include/linux/bitfield.h:57:2: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
     BUILD_BUG_ON_ZERO(__builtin_constant_p(_val) ?   \
     ^~~~~~~~~~~~~~~~~
>> include/linux/bitfield.h:82:3: note: in expansion of macro '__BF_FIELD_CHECK'
     (__BF_FIELD_CHECK(_mask, 0ULL, _val) +    \
      ^~~~~~~~~~~~~~~~
   drivers/iio//chemical/bme680_core.c:548:9: note: in expansion of macro 'FIELD_PREP'
            FIELD_PREP(BME680_OSRS_PRESS_MASK, data->oversampling_press + 1);
            ^~~~~~~~~~
--
   In file included from drivers/iio//imu/st_lsm6dsx/st_lsm6dsx_buffer.c:33:0:
   drivers/iio//imu/st_lsm6dsx/st_lsm6dsx_buffer.c: In function 'st_lsm6dsx_set_fifo_mode':
   include/linux/build_bug.h:29:45: error: bit-field '<anonymous>' width not an integer constant
    #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
                                                ^
   include/linux/regmap.h:77:42: note: in definition of macro 'regmap_update_bits'
     regmap_update_bits_base(map, reg, mask, val, NULL, false, false)
                                             ^~~
>> include/linux/bitfield.h:57:2: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
     BUILD_BUG_ON_ZERO(__builtin_constant_p(_val) ?   \
     ^~~~~~~~~~~~~~~~~
>> include/linux/bitfield.h:82:3: note: in expansion of macro '__BF_FIELD_CHECK'
     (__BF_FIELD_CHECK(_mask, 0ULL, _val) +    \
      ^~~~~~~~~~~~~~~~
   drivers/iio//imu/st_lsm6dsx/st_lsm6dsx_buffer.c:166:6: note: in expansion of macro 'FIELD_PREP'
         FIELD_PREP(ST_LSM6DSX_FIFO_MODE_MASK,
         ^~~~~~~~~~
   drivers/iio//imu/st_lsm6dsx/st_lsm6dsx_buffer.c: In function 'st_lsm6dsx_set_fifo_odr':
   include/linux/build_bug.h:29:45: error: bit-field '<anonymous>' width not an integer constant
    #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
                                                ^
   include/linux/regmap.h:77:42: note: in definition of macro 'regmap_update_bits'
     regmap_update_bits_base(map, reg, mask, val, NULL, false, false)
                                             ^~~
>> include/linux/bitfield.h:57:2: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
     BUILD_BUG_ON_ZERO(__builtin_constant_p(_val) ?   \
     ^~~~~~~~~~~~~~~~~
>> include/linux/bitfield.h:82:3: note: in expansion of macro '__BF_FIELD_CHECK'
     (__BF_FIELD_CHECK(_mask, 0ULL, _val) +    \
      ^~~~~~~~~~~~~~~~
   drivers/iio//imu/st_lsm6dsx/st_lsm6dsx_buffer.c:185:6: note: in expansion of macro 'FIELD_PREP'
         FIELD_PREP(ST_LSM6DSX_FIFO_ODR_MASK, data));
         ^~~~~~~~~~
   drivers/iio//imu/st_lsm6dsx/st_lsm6dsx_buffer.c: In function 'st_lsm6dsx_fifo_setup':
   include/linux/build_bug.h:29:45: error: bit-field '<anonymous>' width not an integer constant
    #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); }))
                                                ^
   include/linux/regmap.h:77:42: note: in definition of macro 'regmap_update_bits'
     regmap_update_bits_base(map, reg, mask, val, NULL, false, false)
                                             ^~~
>> include/linux/bitfield.h:57:2: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
     BUILD_BUG_ON_ZERO(__builtin_constant_p(_val) ?   \
     ^~~~~~~~~~~~~~~~~
>> include/linux/bitfield.h:82:3: note: in expansion of macro '__BF_FIELD_CHECK'
     (__BF_FIELD_CHECK(_mask, 0ULL, _val) +    \
      ^~~~~~~~~~~~~~~~
   drivers/iio//imu/st_lsm6dsx/st_lsm6dsx_buffer.c:529:6: note: in expansion of macro 'FIELD_PREP'
         FIELD_PREP(ST_LSM6DSX_REG_HLACTIVE_MASK,
         ^~~~~~~~~~

vim +/BUILD_BUG_ON_ZERO +57 include/linux/bitfield.h

    53	
    54	#define __BF_FIELD_CHECK(_mask, _reg, _val)				\
    55		BUILD_BUG_ON_ZERO(!__builtin_constant_p(_mask)) +		\
    56		BUILD_BUG_ON_ZERO((_mask) == 0) +				\
  > 57		BUILD_BUG_ON_ZERO(__builtin_constant_p(_val) ?			\
    58					~((_mask) >> __bf_shf(_mask)) & (_val) : 0) + \
    59		BUILD_BUG_ON_ZERO((_mask) > (typeof(_reg))~0ull) +		\
    60		__BF_CHECK_POW2((_mask) + (1ULL << __bf_shf(_mask)))
    61	
    62	/**
    63	 * FIELD_FIT() - check if value fits in the field
    64	 * @_mask: shifted mask defining the field's length and position
    65	 * @_val:  value to test against the field
    66	 *
    67	 * Return: true if @_val can fit inside @_mask, false if @_val is too big.
    68	 */
    69	#define FIELD_FIT(_mask, _val)						\
    70		(__BF_FIELD_CHECK(_mask, 0ULL, _val) +				\
    71		 !((((typeof(_mask))_val) << __bf_shf(_mask)) & ~(_mask)))
    72	
    73	/**
    74	 * FIELD_PREP() - prepare a bitfield element
    75	 * @_mask: shifted mask defining the field's length and position
    76	 * @_val:  value to put in the field
    77	 *
    78	 * FIELD_PREP() masks and shifts up the value.  The result should
    79	 * be combined with other fields of the bitfield using logical OR.
    80	 */
    81	#define FIELD_PREP(_mask, _val)						\
  > 82		(__BF_FIELD_CHECK(_mask, 0ULL, _val) +				\
    83		 (((typeof(_mask))(_val) << __bf_shf(_mask)) & (_mask)))
    84	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

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

  parent reply	other threads:[~2018-10-13  1:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-12  9:21 Johannes Berg
2018-10-12 19:45 ` Johannes Berg
2018-10-13  1:22 ` kbuild test robot [this message]
2018-10-13  1:26 ` kbuild test robot

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=201810130921.h77LERke%fengguang.wu@intel.com \
    --to=lkp@intel.com \
    --cc=johannes.berg@intel.com \
    --cc=johannes@sipsolutions.net \
    --cc=john.garry@huawei.com \
    --cc=kbuild-all@01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®