From: Alexander Stein <alexander.stein@ew.tq-group.com>
To: kernel test robot <lkp@intel.com>, Guenter Roeck <linux@roeck-us.net>
Cc: 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, 09 Apr 2025 08:50:14 +0200 [thread overview]
Message-ID: <2368483.ElGaqSPkdT@steina-w> (raw)
In-Reply-To: <82d98804-e9b6-458e-bb39-3a48c10e9f70@roeck-us.net>
Hi Guenter,
Am Mittwoch, 9. April 2025, 04:51:35 CEST schrieb Guenter Roeck:
> Alexander,
>
> On 4/8/25 19:11, kernel test robot wrote:
> > tree: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
> > head: d6b1492c9c2e7f2659b63a165ea45ab556c0df0c
> > commit: d6b1492c9c2e7f2659b63a165ea45ab556c0df0c [13/13] hwmon: (gpio-fan) Add regulator support
> > config: riscv-randconfig-001-20250409 (https://download.01.org/0day-ci/archive/20250409/202504091047.biuX8Kl2-lkp@intel.com/config)
> > compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project 92c93f5286b9ff33f27ff694d2dc33da1c07afdd)
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250409/202504091047.biuX8Kl2-lkp@intel.com/reproduce)
> >
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202504091047.biuX8Kl2-lkp@intel.com/
> >
> > 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.
Thanks and best regards
Alexander
> Thanks,
> Guenter
> >
> > vim +250 drivers/hwmon/gpio-fan.c
> >
> > d6fe1360f42e86 Simon Guinot 2010-10-22 230
> > c490c63e9505a3 Julia Lawall 2016-12-22 231 static ssize_t pwm1_enable_store(struct device *dev,
> > c490c63e9505a3 Julia Lawall 2016-12-22 232 struct device_attribute *attr,
> > d6fe1360f42e86 Simon Guinot 2010-10-22 233 const char *buf, size_t count)
> > d6fe1360f42e86 Simon Guinot 2010-10-22 234 {
> > d6fe1360f42e86 Simon Guinot 2010-10-22 235 struct gpio_fan_data *fan_data = dev_get_drvdata(dev);
> > d6fe1360f42e86 Simon Guinot 2010-10-22 236 unsigned long val;
> > d6b1492c9c2e7f Alexander Stein 2025-04-08 237 int ret;
> > d6fe1360f42e86 Simon Guinot 2010-10-22 238
> > 179c4fdb565dd2 Frans Meulenbroeks 2012-01-04 239 if (kstrtoul(buf, 10, &val) || val > 1)
> > d6fe1360f42e86 Simon Guinot 2010-10-22 240 return -EINVAL;
> > d6fe1360f42e86 Simon Guinot 2010-10-22 241
> > d6fe1360f42e86 Simon Guinot 2010-10-22 242 if (fan_data->pwm_enable == val)
> > d6fe1360f42e86 Simon Guinot 2010-10-22 243 return count;
> > d6fe1360f42e86 Simon Guinot 2010-10-22 244
> > d6fe1360f42e86 Simon Guinot 2010-10-22 245 mutex_lock(&fan_data->lock);
> > d6fe1360f42e86 Simon Guinot 2010-10-22 246
> > d6fe1360f42e86 Simon Guinot 2010-10-22 247 fan_data->pwm_enable = val;
> > d6fe1360f42e86 Simon Guinot 2010-10-22 248
> > d6fe1360f42e86 Simon Guinot 2010-10-22 249 /* Disable manual control mode: set fan at full speed. */
> > d6fe1360f42e86 Simon Guinot 2010-10-22 @250 if (val == 0)
> > d6b1492c9c2e7f Alexander Stein 2025-04-08 251 ret = set_fan_speed(fan_data, fan_data->num_speed - 1);
> > d6fe1360f42e86 Simon Guinot 2010-10-22 252
> > d6fe1360f42e86 Simon Guinot 2010-10-22 253 mutex_unlock(&fan_data->lock);
> > d6fe1360f42e86 Simon Guinot 2010-10-22 254
> > d6b1492c9c2e7f Alexander Stein 2025-04-08 255 return ret ? ret : count;
> > d6fe1360f42e86 Simon Guinot 2010-10-22 256 }
> > d6fe1360f42e86 Simon Guinot 2010-10-22 257
> >
> > :::::: The code at line 250 was first introduced by commit
> > :::::: d6fe1360f42e86262153927986dea6502daff703 hwmon: add generic GPIO fan driver
> >
> > :::::: TO: Simon Guinot <sguinot@lacie.com>
> > :::::: CC: Guenter Roeck <guenter.roeck@ericsson.com>
> >
>
>
--
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/
next prev parent reply other threads:[~2025-04-09 6:50 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 [this message]
2025-04-09 16:02 ` Nathan Chancellor
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=2368483.ElGaqSPkdT@steina-w \
--to=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 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.