Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Alexander Stein <alexander.stein@ew.tq-group.com>
Cc: kernel test robot <lkp@intel.com>,
	Guenter Roeck <linux@roeck-us.net>,
	llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
	linux-hwmon@vger.kernel.org
Subject: Re: [groeck-staging:hwmon-next 13/13] drivers/hwmon/gpio-fan.c:250:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is false
Date: Wed, 9 Apr 2025 09:02:50 -0700	[thread overview]
Message-ID: <20250409160250.GB1506425@ax162> (raw)
In-Reply-To: <2368483.ElGaqSPkdT@steina-w>

On Wed, Apr 09, 2025 at 08:50:14AM +0200, Alexander Stein wrote:
> Am Mittwoch, 9. April 2025, 04:51:35 CEST schrieb Guenter Roeck:
> > On 4/8/25 19:11, kernel test robot wrote:
> > > All warnings (new ones prefixed by >>):
> > > 
> > >>> drivers/hwmon/gpio-fan.c:250:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
> > >       250 |         if (val == 0)
> > >           |             ^~~~~~~~
> > >     drivers/hwmon/gpio-fan.c:255:9: note: uninitialized use occurs here
> > >       255 |         return ret ? ret : count;
> > >           |                ^~~
> > >     drivers/hwmon/gpio-fan.c:250:2: note: remove the 'if' if its condition is always true
> > >       250 |         if (val == 0)
> > >           |         ^~~~~~~~~~~~~
> > >       251 |                 ret = set_fan_speed(fan_data, fan_data->num_speed - 1);
> > >     drivers/hwmon/gpio-fan.c:237:9: note: initialize the variable 'ret' to silence this warning
> > >       237 |         int ret;
> > >           |                ^
> > >           |                 = 0
> > >     1 warning generated.
> > > 
> > 
> > I dropped the patch from linux-next. Please fix and make sure there are no
> > such problems before resubmitting.
> 
> Oh, surprising. A W=1 build on my machine doesn't raise this warning. I'm not
> sure if this is specific to riscv or clang. Nevertheless this is correct and
> I'll send a fixed one.

Unfortunately, the kernel disabled GCC's version, -Wmaybe-uninitialized,
several years ago in commit 78a5255ffb6a ("Stop the ad-hoc games with
-Wno-maybe-initialized"), so you either need to add it yourself via
KCFLAGS or just do a quick pass with Clang's slightly weaker but more
reliable -Wsometimes-uninitialized. I have fast versions of clang
available on kernel.org to make doing this testing a little easier:
https://mirrors.edge.kernel.org/pub/tools/llvm/

Cheers,
Nathan

  reply	other threads:[~2025-04-09 16:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-09  2:11 [groeck-staging:hwmon-next 13/13] drivers/hwmon/gpio-fan.c:250:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is false kernel test robot
2025-04-09  2:51 ` Guenter Roeck
2025-04-09  6:50   ` Alexander Stein
2025-04-09 16:02     ` Nathan Chancellor [this message]
2025-04-10  8:35       ` Dan Carpenter

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=20250409160250.GB1506425@ax162 \
    --to=nathan@kernel.org \
    --cc=alexander.stein@ew.tq-group.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=lkp@intel.com \
    --cc=llvm@lists.linux.dev \
    --cc=oe-kbuild-all@lists.linux.dev \
    /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