From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: kernel test robot <lkp@intel.com>
Cc: "Jason A. Donenfeld" <zx2c4@kernel.org>,
kbuild-all@lists.01.org, linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Linux Memory Management List <linux-mm@kvack.org>
Subject: Re: [akpm-mm:mm-nonmm-unstable 36/41] include/linux/build_bug.h:16:51: error: negative width in bit-field '<anonymous>'
Date: Tue, 18 Oct 2022 23:40:13 +0300 [thread overview]
Message-ID: <Y08PLW4gmTV0GeUf@smile.fi.intel.com> (raw)
In-Reply-To: <202210190108.ESC3pc3D-lkp@intel.com>
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@intel.com>
>
> 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?
From 6b711ba6b1086795d2407db447ed817aaa791063 Mon Sep 17 00:00:00 2001
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: Tue, 18 Oct 2022 23:35:06 +0300
Subject: [PATCH 1/1] rt2x00: Avoid using 'char' for signed operations
The default Tx power is defined as 'short' in the data structure.
There is nothing prevents us to use 'short' in the
rt2800_txpower_to_dev(). With 'char' it's implementation defined
signedess and sometimes it may be tricky.
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>'
...
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);
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/net/wireless/ralink/rt2x00/rt2800lib.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
index cbbb1a4849cf..d7dffea6df82 100644
--- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
@@ -4035,23 +4035,22 @@ static void rt2800_iq_calibrate(struct rt2x00_dev *rt2x00dev, int channel)
rt2800_bbp_write(rt2x00dev, 159, cal != 0xff ? cal : 0);
}
-static char rt2800_txpower_to_dev(struct rt2x00_dev *rt2x00dev,
- unsigned int channel,
- char txpower)
+static short rt2800_txpower_to_dev(struct rt2x00_dev *rt2x00dev,
+ unsigned int channel, short txpower)
{
if (rt2x00_rt(rt2x00dev, RT3593) ||
rt2x00_rt(rt2x00dev, RT3883))
txpower = rt2x00_get_field8(txpower, EEPROM_TXPOWER_ALC);
if (channel <= 14)
- return clamp_t(char, txpower, MIN_G_TXPOWER, MAX_G_TXPOWER);
+ return clamp_t(short, txpower, MIN_G_TXPOWER, MAX_G_TXPOWER);
if (rt2x00_rt(rt2x00dev, RT3593) ||
rt2x00_rt(rt2x00dev, RT3883))
- return clamp_t(char, txpower, MIN_A_TXPOWER_3593,
+ return clamp_t(short, txpower, MIN_A_TXPOWER_3593,
MAX_A_TXPOWER_3593);
else
- return clamp_t(char, txpower, MIN_A_TXPOWER, MAX_A_TXPOWER);
+ return clamp_t(short, txpower, MIN_A_TXPOWER, MAX_A_TXPOWER);
}
static void rt3883_bbp_adjust(struct rt2x00_dev *rt2x00dev,
--
2.35.1
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2022-10-18 20:40 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-18 17:27 [akpm-mm:mm-nonmm-unstable 36/41] include/linux/build_bug.h:16:51: error: negative width in bit-field '<anonymous>' kernel test robot
2022-10-18 20:27 ` [PATCH] wifi: rt2x00: use explicitly signed type for clamping Jason A. Donenfeld
2022-10-18 20:40 ` Andy Shevchenko
2022-10-18 20:52 ` Jason A. Donenfeld
2022-10-18 20:57 ` Andy Shevchenko
2022-10-18 20:58 ` Jason A. Donenfeld
2022-10-18 21:10 ` Andy Shevchenko
2022-10-19 8:01 ` David Laight
2022-10-18 21:07 ` Andrew Morton
2022-10-19 8:14 ` [PATCH v2] wifi: rt2x00: use explicitly signed or unsigned types Jason A. Donenfeld
2022-10-19 9:00 ` Stanislaw Gruszka
2022-10-19 15:54 ` Jason A. Donenfeld
2022-10-19 15:55 ` [PATCH v3] " Jason A. Donenfeld
2022-10-20 10:29 ` Stanislaw Gruszka
2022-10-20 10:36 ` Kalle Valo
2022-10-21 6:48 ` Kalle Valo
2022-10-21 6:58 ` Kalle Valo
2022-10-21 7:00 ` Kalle Valo
2022-10-19 8:52 ` [PATCH] wifi: rt2x00: use explicitly signed type for clamping Stanislaw Gruszka
2022-10-19 11:04 ` Andy Shevchenko
2022-10-20 10:40 ` Stanislaw Gruszka
2022-10-18 20:40 ` Andy Shevchenko [this message]
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=Y08PLW4gmTV0GeUf@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=kbuild-all@lists.01.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lkp@intel.com \
--cc=zx2c4@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 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.