Re: [akpm-mm:mm-nonmm-unstable 36/41] include/linux/build_bug.h:16:51: error: negative width in bit-field '<anonymous>'

From: Andy Shevchenko
Date: Tue Oct 18 2022 - 16:41:15 EST


On Wed, Oct 19, 2022 at 01:27:05AM +0800, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-nonmm-unstable
> head: c05e49b87cb71437bbc18a6c16dd8113623d7778
> commit: 20b6f49e6024be96a0a729839f7a127600d08740 [36/41] minmax: sanity check constant bounds when clamping
> config: arm-defconfig
> compiler: arm-linux-gnueabi-gcc (GCC) 12.1.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
> # https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git/commit/?id=20b6f49e6024be96a0a729839f7a127600d08740
> git remote add akpm-mm https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git
> git fetch --no-tags akpm-mm mm-nonmm-unstable
> git checkout 20b6f49e6024be96a0a729839f7a127600d08740
> # save the config file
> mkdir build_dir && cp config build_dir/.config
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/net/wireless/ralink/rt2x00/
>
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <lkp@xxxxxxxxx>
>
> All errors (new ones prefixed by >>):
>
> In file included from include/linux/container_of.h:5,
> from include/linux/kernel.h:21,
> from drivers/net/wireless/ralink/rt2x00/rt2800lib.c:25:
> drivers/net/wireless/ralink/rt2x00/rt2800lib.c: In function 'rt2800_txpower_to_dev':
> >> include/linux/build_bug.h:16:51: error: negative width in bit-field '<anonymous>'
> 16 | #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); })))
> | ^
> include/linux/minmax.h:50:10: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
> 50 | (BUILD_BUG_ON_ZERO(__builtin_choose_expr( \
> | ^~~~~~~~~~~~~~~~~
> include/linux/minmax.h:54:9: note: in expansion of macro '__clamp_input_check'
> 54 | __clamp_input_check(lo, hi) + \
> | ^~~~~~~~~~~~~~~~~~~
> include/linux/minmax.h:146:36: note: in expansion of macro '__careful_clamp'
> 146 | #define clamp_t(type, val, lo, hi) __careful_clamp((type)(val), (type)(lo), (type)(hi))
> | ^~~~~~~~~~~~~~~
> drivers/net/wireless/ralink/rt2x00/rt2800lib.c:4054:24: note: in expansion of macro 'clamp_t'
> 4054 | return clamp_t(char, txpower, MIN_A_TXPOWER, MAX_A_TXPOWER);
> | ^~~~~~~

Because char is heck broken in C standard, it may be signed or unsigned
depending on the compiler (IIRC), so perhaps fixing it to signed char will fix
it?