All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Shuah Khan <skhan@linuxfoundation.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	kernel test robot <lkp@intel.com>,
	llvm@lists.linux.dev, kbuild-all@lists.01.org,
	linux-kernel@vger.kernel.org
Subject: Re: [char-misc:char-misc-linus 3/3] drivers/misc/cardreader/rtsx_usb.c:639:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true
Date: Fri, 1 Jul 2022 08:39:13 -0700	[thread overview]
Message-ID: <Yr8VIT2vjvGYrbmR@dev-arch.thelio-3990X> (raw)
In-Reply-To: <67a09516-ec1f-d0b6-c027-fd52159318ed@linuxfoundation.org>

On Fri, Jul 01, 2022 at 08:48:11AM -0600, Shuah Khan wrote:
> On 7/1/22 2:59 AM, Greg Kroah-Hartman wrote:
> > On Fri, Jul 01, 2022 at 04:49:50PM +0800, kernel test robot wrote:
> > > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git char-misc-linus
> > > head:   3776c78559853fd151be7c41e369fd076fb679d5
> > > commit: 3776c78559853fd151be7c41e369fd076fb679d5 [3/3] misc: rtsx_usb: use separate command and response buffers
> > > config: arm-buildonly-randconfig-r006-20220629 (https://download.01.org/0day-ci/archive/20220701/202207011658.rHJFVLWA-lkp@intel.com/config)
> > > compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project a9119143a2d1f4d0d0bc1fe0d819e5351b4e0deb)
> > > 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 arm cross compiling tool for clang build
> > >          # apt-get install binutils-arm-linux-gnueabi
> > >          # https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git/commit/?id=3776c78559853fd151be7c41e369fd076fb679d5
> > >          git remote add char-misc https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
> > >          git fetch --no-tags char-misc char-misc-linus
> > >          git checkout 3776c78559853fd151be7c41e369fd076fb679d5
> > >          # 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=arm SHELL=/bin/bash drivers/misc/cardreader/
> > > 
> > > If you fix the issue, kindly add following tag where applicable
> > > Reported-by: kernel test robot <lkp@intel.com>
> > > 
> > > All warnings (new ones prefixed by >>):
> > > 
> > > > > drivers/misc/cardreader/rtsx_usb.c:639:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
> > >             if (!ucr->rsp_buf)
> > >                 ^~~~~~~~~~~~~
> > >     drivers/misc/cardreader/rtsx_usb.c:678:9: note: uninitialized use occurs here
> > >             return ret;
> > >                    ^~~
> > >     drivers/misc/cardreader/rtsx_usb.c:639:2: note: remove the 'if' if its condition is always false
> > >             if (!ucr->rsp_buf)
> > >             ^~~~~~~~~~~~~~~~~~
> > >     drivers/misc/cardreader/rtsx_usb.c:622:9: note: initialize the variable 'ret' to silence this warning
> > >             int ret;
> > >                    ^
> > >                     = 0
> > >     1 warning generated.
> > 
> > Odd, gcc doesn't show this for me.  Shuah, can you send a follow-on
> > patch to fix this?  The warning does look correct.
> > 
> 
> gcc didn't complain when I compiled either. I will send a follow-on patch.

Unfortunately, GCC won't warn for most uninitialized variables by
default after 5.7, which included commit 78a5255ffb6a ("Stop the ad-hoc
games with -Wno-maybe-initialized"). They will potentially show up at
W=2 or with an explicit KCFLAGS=-Wmaybe-uninitialized (it does in this
case):

| drivers/misc/cardreader/rtsx_usb.c: In function ‘rtsx_usb_probe’:
| drivers/misc/cardreader/rtsx_usb.c:678:16: error: ‘ret’ may be used uninitialized [-Werror=maybe-uninitialized]
|   678 |         return ret;
|       |                ^~~
| drivers/misc/cardreader/rtsx_usb.c:622:13: note: ‘ret’ was declared here
|   622 |         int ret;
|       |             ^~~
| cc1: all warnings being treated as errors

Cheers,
Nathan

WARNING: multiple messages have this Message-ID (diff)
From: Nathan Chancellor <nathan@kernel.org>
To: kbuild-all@lists.01.org
Subject: Re: [char-misc:char-misc-linus 3/3] drivers/misc/cardreader/rtsx_usb.c:639:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true
Date: Fri, 01 Jul 2022 08:39:13 -0700	[thread overview]
Message-ID: <Yr8VIT2vjvGYrbmR@dev-arch.thelio-3990X> (raw)
In-Reply-To: <67a09516-ec1f-d0b6-c027-fd52159318ed@linuxfoundation.org>

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

On Fri, Jul 01, 2022 at 08:48:11AM -0600, Shuah Khan wrote:
> On 7/1/22 2:59 AM, Greg Kroah-Hartman wrote:
> > On Fri, Jul 01, 2022 at 04:49:50PM +0800, kernel test robot wrote:
> > > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git char-misc-linus
> > > head:   3776c78559853fd151be7c41e369fd076fb679d5
> > > commit: 3776c78559853fd151be7c41e369fd076fb679d5 [3/3] misc: rtsx_usb: use separate command and response buffers
> > > config: arm-buildonly-randconfig-r006-20220629 (https://download.01.org/0day-ci/archive/20220701/202207011658.rHJFVLWA-lkp(a)intel.com/config)
> > > compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project a9119143a2d1f4d0d0bc1fe0d819e5351b4e0deb)
> > > 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 arm cross compiling tool for clang build
> > >          # apt-get install binutils-arm-linux-gnueabi
> > >          # https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git/commit/?id=3776c78559853fd151be7c41e369fd076fb679d5
> > >          git remote add char-misc https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
> > >          git fetch --no-tags char-misc char-misc-linus
> > >          git checkout 3776c78559853fd151be7c41e369fd076fb679d5
> > >          # 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=arm SHELL=/bin/bash drivers/misc/cardreader/
> > > 
> > > If you fix the issue, kindly add following tag where applicable
> > > Reported-by: kernel test robot <lkp@intel.com>
> > > 
> > > All warnings (new ones prefixed by >>):
> > > 
> > > > > drivers/misc/cardreader/rtsx_usb.c:639:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
> > >             if (!ucr->rsp_buf)
> > >                 ^~~~~~~~~~~~~
> > >     drivers/misc/cardreader/rtsx_usb.c:678:9: note: uninitialized use occurs here
> > >             return ret;
> > >                    ^~~
> > >     drivers/misc/cardreader/rtsx_usb.c:639:2: note: remove the 'if' if its condition is always false
> > >             if (!ucr->rsp_buf)
> > >             ^~~~~~~~~~~~~~~~~~
> > >     drivers/misc/cardreader/rtsx_usb.c:622:9: note: initialize the variable 'ret' to silence this warning
> > >             int ret;
> > >                    ^
> > >                     = 0
> > >     1 warning generated.
> > 
> > Odd, gcc doesn't show this for me.  Shuah, can you send a follow-on
> > patch to fix this?  The warning does look correct.
> > 
> 
> gcc didn't complain when I compiled either. I will send a follow-on patch.

Unfortunately, GCC won't warn for most uninitialized variables by
default after 5.7, which included commit 78a5255ffb6a ("Stop the ad-hoc
games with -Wno-maybe-initialized"). They will potentially show up at
W=2 or with an explicit KCFLAGS=-Wmaybe-uninitialized (it does in this
case):

| drivers/misc/cardreader/rtsx_usb.c: In function ‘rtsx_usb_probe’:
| drivers/misc/cardreader/rtsx_usb.c:678:16: error: ‘ret’ may be used uninitialized [-Werror=maybe-uninitialized]
|   678 |         return ret;
|       |                ^~~
| drivers/misc/cardreader/rtsx_usb.c:622:13: note: ‘ret’ was declared here
|   622 |         int ret;
|       |             ^~~
| cc1: all warnings being treated as errors

Cheers,
Nathan

  reply	other threads:[~2022-07-01 15:39 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-01  8:49 [char-misc:char-misc-linus 3/3] drivers/misc/cardreader/rtsx_usb.c:639:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true kernel test robot
2022-07-01  8:59 ` Greg Kroah-Hartman
2022-07-01  8:59   ` Greg Kroah-Hartman
2022-07-01 14:48   ` Shuah Khan
2022-07-01 14:48     ` Shuah Khan
2022-07-01 15:39     ` Nathan Chancellor [this message]
2022-07-01 15:39       ` Nathan Chancellor
2022-07-01 15:52       ` Shuah Khan
2022-07-01 15:52         ` Shuah Khan
2022-07-01 16:09         ` Shuah Khan
2022-07-01 16:09           ` Shuah Khan
2022-07-01 16:27           ` Nathan Chancellor
2022-07-01 16:27             ` Nathan Chancellor
2022-07-01 16:59             ` Shuah Khan
2022-07-01 16:59               ` Shuah Khan

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=Yr8VIT2vjvGYrbmR@dev-arch.thelio-3990X \
    --to=nathan@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=llvm@lists.linux.dev \
    --cc=skhan@linuxfoundation.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.