Re: drivers/net/wireless/ralink/rt2x00/rt2800lib.c:9439:15: warning: result of comparison of constant -7 with expression of type 'char' is always false

From: Kalle Valo
Date: Thu Oct 20 2022 - 01:26:57 EST


"Jason A. Donenfeld" <Jason@xxxxxxxxx> writes:

> On Wed, Oct 19, 2022 at 2:02 AM Jason A. Donenfeld <Jason@xxxxxxxxx> wrote:
>>
>> On Wed, Oct 19, 2022 at 1:59 AM Jason A. Donenfeld <Jason@xxxxxxxxx> wrote:
>> >
>> > On Wed, Oct 19, 2022 at 1:55 AM Kalle Valo <kvalo@xxxxxxxxxx> wrote:
>> > >
>> > > + jason, linux-wireless
>> > >
>> > > kernel test robot <lkp@xxxxxxxxx> writes:
>> > >
>> > > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
>> > > > head: aae703b02f92bde9264366c545e87cec451de471
>> > > > commit: dab902fe1d29dc0fa1dccc8d13dc89ffbf633881 wifi: rt2x00: add TX
>> > > > LOFT calibration for MT7620
>> > > > date: 4 weeks ago
>> > > > config: arm64-allmodconfig
>> > > > compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project
>> > > > 791a7ae1ba3efd6bca96338e10ffde557ba83920)
>> > > > 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
>> > > > # install arm64 cross compiling tool for clang build
>> > > > # apt-get install binutils-aarch64-linux-gnu
>> > > > #
>> > > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=dab902fe1d29dc0fa1dccc8d13dc89ffbf633881
>> > > > git remote add linus
>> > > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>> > > > git fetch --no-tags linus master
>> > > > git checkout dab902fe1d29dc0fa1dccc8d13dc89ffbf633881
>> > > > # save the config file
>> > > > mkdir build_dir && cp config build_dir/.config
>> > > > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1
>> > > > O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/gpu/drm/amd/amdgpu/
>> > > > drivers/net/wireless/ralink/rt2x00/ drivers/staging/media/
>> > > >
>> > > > If you fix the issue, kindly add following tag where applicable
>> > > > | Reported-by: kernel test robot <lkp@xxxxxxxxx>
>> > > >
>> > > > All warnings (new ones prefixed by >>):
>> > > >
>> > > >>> drivers/net/wireless/ralink/rt2x00/rt2800lib.c:9439:15: warning:
>> > > >> result of comparison of constant -7 with expression of type 'char'
>> > > >> is always false [-Wtautological-constant-out-of-range-compare]
>> > > > gerr = (gerr < -0x07) ? -0x07 : (gerr > 0x05) ? 0x05 : gerr;
>> > > > ~~~~ ^ ~~~~~
>> > > > drivers/net/wireless/ralink/rt2x00/rt2800lib.c:9443:15: warning: result of comparison of constant -31 with expression of type 'char' is always false [-Wtautological-constant-out-of-range-compare]
>> > > > perr = (perr < -0x1f) ? -0x1f : (perr > 0x1d) ? 0x1d : perr;
>> > > > ~~~~ ^ ~~~~~
>> > > > 2 warnings generated.
>> > >
>> > > I believe this patch should fix it:
>> > >
>> > > https://patchwork.kernel.org/project/linux-wireless/patch/20221018202734.140489-1-Jason@xxxxxxxxx/
>> > >
>> > > Jason, is my understanding correct?
>> >
>> > That's a different bug caused by the same pitfall: assuming char is
>> > signed. I'll send a patch for that function too.
>>
>>
>> Actually, maybe I should fix the whole file? Patch incoming.
>
> Okay here's a v2 that handles it driver-wide:
> https://lore.kernel.org/linux-wireless/20221019081417.3402284-1-Jason@xxxxxxxxx/
> (Might take a few minutes to hit lore.)

Great, thanks Jason.

--
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches