All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Akshay Gupta <Akshay.Gupta@amd.com>
Cc: kbuild-all@lists.01.org,
	Naveen Krishna Chatradhi <nchatrad@amd.com>,
	"linux-hwmon@vger.kernel.org" <linux-hwmon@vger.kernel.org>
Subject: Re: [linux-next:master 3918/4407] drivers/hwmon/sbrmi.c:211:7: warning: variable 'ret' is used uninitialized whenever switch case is taken
Date: Fri, 30 Jul 2021 11:17:36 -0700	[thread overview]
Message-ID: <986da3fe-bae4-9532-c732-86731ac9a9e0@roeck-us.net> (raw)
In-Reply-To: <202107302120.M9mjOgXZ-lkp@intel.com>

On 7/30/21 6:03 AM, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> head:   4ccc9e2db7ac33f450a1ff6ce158a71e5a81ded9
> commit: 4f5b70eb322a2ab7efc7a60a572fa72e46c89f16 [3918/4407] hwmon: Add support for SB-RMI power module
> config: x86_64-buildonly-randconfig-r002-20210730 (attached as .config)
> compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 4f71f59bf3d9914188a11d0c41bedbb339d36ff5)
> 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
>          # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=4f5b70eb322a2ab7efc7a60a572fa72e46c89f16
>          git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
>          git fetch --no-tags linux-next master
>          git checkout 4f5b70eb322a2ab7efc7a60a572fa72e46c89f16
>          # 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@intel.com>
> 
> All warnings (new ones prefixed by >>):
> 
>>> drivers/hwmon/sbrmi.c:211:7: warning: variable 'ret' is used uninitialized whenever switch case is taken [-Wsometimes-uninitialized]
>             case hwmon_power_cap_max:
>                  ^~~~~~~~~~~~~~~~~~~
>     drivers/hwmon/sbrmi.c:217:6: note: uninitialized use occurs here
>             if (ret < 0)
>                 ^~~
>     drivers/hwmon/sbrmi.c:196:9: note: initialize the variable 'ret' to silence this warning
>             int ret;
>                    ^
>                     = 0
>     1 warning generated.
> 

There is no need to send an updated patch; I fixed this up.

Thanks,
Guenter

> 
> vim +/ret +211 drivers/hwmon/sbrmi.c
> 
>     190	
>     191	static int sbrmi_read(struct device *dev, enum hwmon_sensor_types type,
>     192			      u32 attr, int channel, long *val)
>     193	{
>     194		struct sbrmi_data *data = dev_get_drvdata(dev);
>     195		struct sbrmi_mailbox_msg msg = { 0 };
>     196		int ret;
>     197	
>     198		if (type != hwmon_power)
>     199			return -EINVAL;
>     200	
>     201		msg.read = true;
>     202		switch (attr) {
>     203		case hwmon_power_input:
>     204			msg.cmd = SBRMI_READ_PKG_PWR_CONSUMPTION;
>     205			ret = rmi_mailbox_xfer(data, &msg);
>     206			break;
>     207		case hwmon_power_cap:
>     208			msg.cmd = SBRMI_READ_PKG_PWR_LIMIT;
>     209			ret = rmi_mailbox_xfer(data, &msg);
>     210			break;
>   > 211		case hwmon_power_cap_max:
>     212			msg.data_out = data->pwr_limit_max;
>     213			break;
>     214		default:
>     215			return -EINVAL;
>     216		}
>     217		if (ret < 0)
>     218			return ret;
>     219		/* hwmon power attributes are in microWatt */
>     220		*val = (long)msg.data_out * 1000;
>     221		return ret;
>     222	}
>     223	
> 
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
> 


WARNING: multiple messages have this Message-ID (diff)
From: Guenter Roeck <linux@roeck-us.net>
To: kbuild-all@lists.01.org
Subject: Re: [linux-next:master 3918/4407] drivers/hwmon/sbrmi.c:211:7: warning: variable 'ret' is used uninitialized whenever switch case is taken
Date: Fri, 30 Jul 2021 11:17:36 -0700	[thread overview]
Message-ID: <986da3fe-bae4-9532-c732-86731ac9a9e0@roeck-us.net> (raw)
In-Reply-To: <202107302120.M9mjOgXZ-lkp@intel.com>

[-- Attachment #1: Type: text/plain, Size: 3268 bytes --]

On 7/30/21 6:03 AM, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> head:   4ccc9e2db7ac33f450a1ff6ce158a71e5a81ded9
> commit: 4f5b70eb322a2ab7efc7a60a572fa72e46c89f16 [3918/4407] hwmon: Add support for SB-RMI power module
> config: x86_64-buildonly-randconfig-r002-20210730 (attached as .config)
> compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 4f71f59bf3d9914188a11d0c41bedbb339d36ff5)
> 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
>          # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=4f5b70eb322a2ab7efc7a60a572fa72e46c89f16
>          git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
>          git fetch --no-tags linux-next master
>          git checkout 4f5b70eb322a2ab7efc7a60a572fa72e46c89f16
>          # 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@intel.com>
> 
> All warnings (new ones prefixed by >>):
> 
>>> drivers/hwmon/sbrmi.c:211:7: warning: variable 'ret' is used uninitialized whenever switch case is taken [-Wsometimes-uninitialized]
>             case hwmon_power_cap_max:
>                  ^~~~~~~~~~~~~~~~~~~
>     drivers/hwmon/sbrmi.c:217:6: note: uninitialized use occurs here
>             if (ret < 0)
>                 ^~~
>     drivers/hwmon/sbrmi.c:196:9: note: initialize the variable 'ret' to silence this warning
>             int ret;
>                    ^
>                     = 0
>     1 warning generated.
> 

There is no need to send an updated patch; I fixed this up.

Thanks,
Guenter

> 
> vim +/ret +211 drivers/hwmon/sbrmi.c
> 
>     190	
>     191	static int sbrmi_read(struct device *dev, enum hwmon_sensor_types type,
>     192			      u32 attr, int channel, long *val)
>     193	{
>     194		struct sbrmi_data *data = dev_get_drvdata(dev);
>     195		struct sbrmi_mailbox_msg msg = { 0 };
>     196		int ret;
>     197	
>     198		if (type != hwmon_power)
>     199			return -EINVAL;
>     200	
>     201		msg.read = true;
>     202		switch (attr) {
>     203		case hwmon_power_input:
>     204			msg.cmd = SBRMI_READ_PKG_PWR_CONSUMPTION;
>     205			ret = rmi_mailbox_xfer(data, &msg);
>     206			break;
>     207		case hwmon_power_cap:
>     208			msg.cmd = SBRMI_READ_PKG_PWR_LIMIT;
>     209			ret = rmi_mailbox_xfer(data, &msg);
>     210			break;
>   > 211		case hwmon_power_cap_max:
>     212			msg.data_out = data->pwr_limit_max;
>     213			break;
>     214		default:
>     215			return -EINVAL;
>     216		}
>     217		if (ret < 0)
>     218			return ret;
>     219		/* hwmon power attributes are in microWatt */
>     220		*val = (long)msg.data_out * 1000;
>     221		return ret;
>     222	}
>     223	
> 
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
> 

  reply	other threads:[~2021-07-30 18:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-30 13:03 [linux-next:master 3918/4407] drivers/hwmon/sbrmi.c:211:7: warning: variable 'ret' is used uninitialized whenever switch case is taken kernel test robot
2021-07-30 13:03 ` kernel test robot
2021-07-30 18:17 ` Guenter Roeck [this message]
2021-07-30 18:17   ` Guenter Roeck
2021-07-30 18:52   ` Naveen Krishna Ch

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=986da3fe-bae4-9532-c732-86731ac9a9e0@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=Akshay.Gupta@amd.com \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=nchatrad@amd.com \
    /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.