[hwmon:hwmon-next 34/35] drivers/hwmon/pmbus/pmbus_core.c:903:13: warning: variable 'ret' is used uninitialized whenever 'if' condition is true

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
head:   4fc1c17042661fa31212b561e0a59e3507760258
commit: 33e7d4ebc983b2f56f8f92c5b1b6f03eb20789ca [34/35] hwmon: (pmbus) Stop caching register values
config: x86_64-randconfig-a013-20200909 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 0a5dc7effb191eff740e0e7ae7bd8e1f6bdb3ad9)
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 x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        git checkout 33e7d4ebc983b2f56f8f92c5b1b6f03eb20789ca
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

>> drivers/hwmon/pmbus/pmbus_core.c:903:13: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
           } else if (!s1 || !s2) {
                      ^~~~~~~~~~
   drivers/hwmon/pmbus/pmbus_core.c:923:9: note: uninitialized use occurs here
           return ret;
                  ^~~
   drivers/hwmon/pmbus/pmbus_core.c:903:9: note: remove the 'if' if its condition is always false
           } else if (!s1 || !s2) {
                  ^~~~~~~~~~~~~~~~~
>> drivers/hwmon/pmbus/pmbus_core.c:903:13: warning: variable 'ret' is used uninitialized whenever '||' condition is true [-Wsometimes-uninitialized]
           } else if (!s1 || !s2) {
                      ^~~
   drivers/hwmon/pmbus/pmbus_core.c:923:9: note: uninitialized use occurs here
           return ret;
                  ^~~
   drivers/hwmon/pmbus/pmbus_core.c:903:13: note: remove the '||' if its condition is always false
           } else if (!s1 || !s2) {
                      ^~~~~~
   drivers/hwmon/pmbus/pmbus_core.c:885:9: note: initialize the variable 'ret' to silence this warning
           int ret, status;
                  ^
                   = 0
   2 warnings generated.

# https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git/commit/?id=33e7d4ebc983b2f56f8f92c5b1b6f03eb20789ca
git remote add hwmon https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git
git fetch --no-tags hwmon hwmon-next
git checkout 33e7d4ebc983b2f56f8f92c5b1b6f03eb20789ca
vim +903 drivers/hwmon/pmbus/pmbus_core.c

442aba78728e77 drivers/hwmon/pmbus_core.c       Guenter Roeck   2011-01-26  852  
442aba78728e77 drivers/hwmon/pmbus_core.c       Guenter Roeck   2011-01-26  853  /*
442aba78728e77 drivers/hwmon/pmbus_core.c       Guenter Roeck   2011-01-26  854   * Return boolean calculated from converted data.
663834f3b796c0 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2013-01-20  855   * <index> defines a status register index and mask.
663834f3b796c0 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2013-01-20  856   * The mask is in the lower 8 bits, the register index is in bits 8..23.
442aba78728e77 drivers/hwmon/pmbus_core.c       Guenter Roeck   2011-01-26  857   *
663834f3b796c0 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2013-01-20  858   * The associated pmbus_boolean structure contains optional pointers to two
663834f3b796c0 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2013-01-20  859   * sensor attributes. If specified, those attributes are compared against each
663834f3b796c0 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2013-01-20  860   * other to determine if a limit has been exceeded.
442aba78728e77 drivers/hwmon/pmbus_core.c       Guenter Roeck   2011-01-26  861   *
663834f3b796c0 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2013-01-20  862   * If the sensor attribute pointers are NULL, the function returns true if
663834f3b796c0 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2013-01-20  863   * (status[reg] & mask) is true.
663834f3b796c0 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2013-01-20  864   *
663834f3b796c0 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2013-01-20  865   * If sensor attribute pointers are provided, a comparison against a specified
663834f3b796c0 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2013-01-20  866   * limit has to be performed to determine the boolean result.
442aba78728e77 drivers/hwmon/pmbus_core.c       Guenter Roeck   2011-01-26  867   * In this case, the function returns true if v1 >= v2 (where v1 and v2 are
663834f3b796c0 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2013-01-20  868   * sensor values referenced by sensor attribute pointers s1 and s2).
442aba78728e77 drivers/hwmon/pmbus_core.c       Guenter Roeck   2011-01-26  869   *
442aba78728e77 drivers/hwmon/pmbus_core.c       Guenter Roeck   2011-01-26  870   * To determine if an object exceeds upper limits, specify <s1,s2> = <v,limit>.
442aba78728e77 drivers/hwmon/pmbus_core.c       Guenter Roeck   2011-01-26  871   * To determine if an object exceeds lower limits, specify <s1,s2> = <limit,v>.
442aba78728e77 drivers/hwmon/pmbus_core.c       Guenter Roeck   2011-01-26  872   *
442aba78728e77 drivers/hwmon/pmbus_core.c       Guenter Roeck   2011-01-26  873   * If a negative value is stored in any of the referenced registers, this value
442aba78728e77 drivers/hwmon/pmbus_core.c       Guenter Roeck   2011-01-26  874   * reflects an error code which will be returned.
442aba78728e77 drivers/hwmon/pmbus_core.c       Guenter Roeck   2011-01-26  875   */
33e7d4ebc983b2 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2020-09-04  876  static int pmbus_get_boolean(struct i2c_client *client, struct pmbus_boolean *b,
663834f3b796c0 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2013-01-20  877  			     int index)
442aba78728e77 drivers/hwmon/pmbus_core.c       Guenter Roeck   2011-01-26  878  {
33e7d4ebc983b2 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2020-09-04  879  	struct pmbus_data *data = i2c_get_clientdata(client);
663834f3b796c0 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2013-01-20  880  	struct pmbus_sensor *s1 = b->s1;
663834f3b796c0 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2013-01-20  881  	struct pmbus_sensor *s2 = b->s2;
33e7d4ebc983b2 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2020-09-04  882  	u16 mask = pb_index_to_mask(index);
33e7d4ebc983b2 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2020-09-04  883  	u8 page = pb_index_to_page(index);
33e7d4ebc983b2 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2020-09-04  884  	u16 reg = pb_index_to_reg(index);
d7ee11157f1fce drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2012-03-28  885  	int ret, status;
a66a6eb9db10bd drivers/hwmon/pmbus/pmbus_core.c Edward A. James 2017-08-10  886  	u16 regval;
442aba78728e77 drivers/hwmon/pmbus_core.c       Guenter Roeck   2011-01-26  887  
33e7d4ebc983b2 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2020-09-04  888  	mutex_lock(&data->update_lock);
33e7d4ebc983b2 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2020-09-04  889  	status = pmbus_get_status(client, page, reg);
33e7d4ebc983b2 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2020-09-04  890  	if (status < 0) {
33e7d4ebc983b2 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2020-09-04  891  		ret = status;
33e7d4ebc983b2 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2020-09-04  892  		goto unlock;
33e7d4ebc983b2 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2020-09-04  893  	}
33e7d4ebc983b2 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2020-09-04  894  
33e7d4ebc983b2 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2020-09-04  895  	if (s1)
33e7d4ebc983b2 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2020-09-04  896  		pmbus_update_sensor_data(client, s1);
33e7d4ebc983b2 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2020-09-04  897  	if (s2)
33e7d4ebc983b2 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2020-09-04  898  		pmbus_update_sensor_data(client, s2);
442aba78728e77 drivers/hwmon/pmbus_core.c       Guenter Roeck   2011-01-26  899  
442aba78728e77 drivers/hwmon/pmbus_core.c       Guenter Roeck   2011-01-26  900  	regval = status & mask;
663834f3b796c0 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2013-01-20  901  	if (!s1 && !s2) {
d7ee11157f1fce drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2012-03-28  902  		ret = !!regval;
663834f3b796c0 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2013-01-20 @903  	} else if (!s1 || !s2) {
af78fdf4a61827 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2013-09-13  904  		WARN(1, "Bad boolean descriptor %p: s1=%p, s2=%p\n", b, s1, s2);
663834f3b796c0 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2013-01-20  905  	} else {
8ba75b20284967 drivers/hwmon/pmbus/pmbus_core.c Josh Lehan      2020-06-25  906  		s64 v1, v2;
442aba78728e77 drivers/hwmon/pmbus_core.c       Guenter Roeck   2011-01-26  907  
33e7d4ebc983b2 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2020-09-04  908  		if (s1->data < 0) {
33e7d4ebc983b2 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2020-09-04  909  			ret = s1->data;
33e7d4ebc983b2 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2020-09-04  910  			goto unlock;
33e7d4ebc983b2 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2020-09-04  911  		}
33e7d4ebc983b2 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2020-09-04  912  		if (s2->data < 0) {
33e7d4ebc983b2 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2020-09-04  913  			ret = s2->data;
33e7d4ebc983b2 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2020-09-04  914  			goto unlock;
33e7d4ebc983b2 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2020-09-04  915  		}
442aba78728e77 drivers/hwmon/pmbus_core.c       Guenter Roeck   2011-01-26  916  
663834f3b796c0 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2013-01-20  917  		v1 = pmbus_reg2data(data, s1);
663834f3b796c0 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2013-01-20  918  		v2 = pmbus_reg2data(data, s2);
d7ee11157f1fce drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2012-03-28  919  		ret = !!(regval && v1 >= v2);
442aba78728e77 drivers/hwmon/pmbus_core.c       Guenter Roeck   2011-01-26  920  	}
33e7d4ebc983b2 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2020-09-04  921  unlock:
33e7d4ebc983b2 drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2020-09-04  922  	mutex_unlock(&data->update_lock);
d7ee11157f1fce drivers/hwmon/pmbus/pmbus_core.c Guenter Roeck   2012-03-28  923  	return ret;
442aba78728e77 drivers/hwmon/pmbus_core.c       Guenter Roeck   2011-01-26  924  }
442aba78728e77 drivers/hwmon/pmbus_core.c       Guenter Roeck   2011-01-26  925  

:::::: The code at line 903 was first introduced by commit
:::::: 663834f3b796c0a118b84cf18c759f2c2aa537b6 hwmon: (pmbus) Improve boolean handling

:::::: TO: Guenter Roeck <linux@xxxxxxxxxxxx>
:::::: CC: Guenter Roeck <linux@xxxxxxxxxxxx>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux