]> git.baikalelectronics.ru Git - kernel.git/commit
hwmon: (pmbus) Move boolean error condition check to generating code
authorGuenter Roeck <linux@roeck-us.net>
Thu, 10 Sep 2020 10:09:49 +0000 (03:09 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Wed, 23 Sep 2020 16:42:41 +0000 (09:42 -0700)
commitd2b9d8a47e7d8c9de89cba3c48f07261a78083aa
tree390f337accb406402aec9b0daed5ce2c4fbdbed4
parentc210a5c26d6563115ccec68e2c94b2ee747ceaa0
hwmon: (pmbus) Move boolean error condition check to generating code

0-day rightfully complains about a sometimes uninitialized variable
in pmbus_get_boolean().

drivers/hwmon/pmbus/pmbus_core.c:903:13: warning:
variable 'ret' is used uninitialized whenever 'if' condition is true
} else if (!s1 || !s2) {

While that is technically true, it won't be hit in the field since the
condition indicates a programming error. Move the check of that condition
into the code generating the attribute entry, and refuse generating the
attribute if the condition is true. Swap the condition check in
pmbus_get_boolean() to ensure that static analyzers don't get a hiccup
(because we check if s1 and s2 are NULL, static analyzers may believe
that they can be NULL independently of each other).

Reported-by: kernel test robot <lkp@intel.com>
Cc: Alex Qiu <xqiu@google.com>
Reviewed-by: Alex Qiu <xqiu@google.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/pmbus/pmbus_core.c