From: kernel test robot <lkp@intel.com>
To: Alexander Stein <alexander.stein@ew.tq-group.com>
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
linux-hwmon@vger.kernel.org, Guenter Roeck <linux@roeck-us.net>
Subject: [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 10:11:26 +0800 [thread overview]
Message-ID: <202504091047.biuX8Kl2-lkp@intel.com> (raw)
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.
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>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
next reply other threads:[~2025-04-09 2:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-09 2:11 kernel test robot [this message]
2025-04-09 2:51 ` [groeck-staging:hwmon-next 13/13] drivers/hwmon/gpio-fan.c:250:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is false Guenter Roeck
2025-04-09 6:50 ` Alexander Stein
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=202504091047.biuX8Kl2-lkp@intel.com \
--to=lkp@intel.com \
--cc=alexander.stein@ew.tq-group.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux@roeck-us.net \
--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