Linux kernel staging patches
 help / color / mirror / Atom feed
* [PATCH] staging: greybus: audio: evaluate sscanf() return value directly
@ 2026-06-13 11:07 abdelnasser hussein
  2026-06-13 19:41 ` kernel test robot
  0 siblings, 1 reply; 2+ messages in thread
From: abdelnasser hussein @ 2026-06-13 11:07 UTC (permalink / raw)
  To: Vaibhav Agarwal, Mark Greer, Johan Hovold, Alex Elder,
	Greg Kroah-Hartman
  Cc: greybus-dev, linux-staging, linux-kernel, abdelnasser hussein

Smatch warns:
  drivers/staging/greybus/audio_codec.c:335 gbaudio_module_update()
  warn: sscanf doesn't return error codes

sscanf() returns the number of successfully matched input items, not a
negative error code. Do not store its return value in ret. Check it
directly instead.

Signed-off-by: abdelnasser hussein <abdelnasserhussein11@gmail.com>
---
 drivers/staging/greybus/audio_codec.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/greybus/audio_codec.c b/drivers/staging/greybus/audio_codec.c
index 720aa752e17e..295222ec0f1a 100644
--- a/drivers/staging/greybus/audio_codec.c
+++ b/drivers/staging/greybus/audio_codec.c
@@ -311,8 +311,7 @@ int gbaudio_module_update(struct gbaudio_codec_info *codec,
 	}
 
 	/* parse dai_id from AIF widget's stream_name */
-	ret = sscanf(w->sname, "%s %d %s", intf_name, &dai_id, dir);
-	if (ret < 3) {
+	if (sscanf(w->sname, "%s %d %s", intf_name, &dai_id, dir) != 3) {
 		dev_err(codec->dev, "Error while parsing dai_id for %s\n", w->name);
 		return -EINVAL;
 	}
-- 
2.52.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] staging: greybus: audio: evaluate sscanf() return value directly
  2026-06-13 11:07 [PATCH] staging: greybus: audio: evaluate sscanf() return value directly abdelnasser hussein
@ 2026-06-13 19:41 ` kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2026-06-13 19:41 UTC (permalink / raw)
  To: abdelnasser hussein, Vaibhav Agarwal, Mark Greer, Johan Hovold,
	Alex Elder, Greg Kroah-Hartman
  Cc: llvm, oe-kbuild-all, greybus-dev, linux-staging, linux-kernel,
	abdelnasser hussein

Hi abdelnasser,

kernel test robot noticed the following build warnings:

[auto build test WARNING on staging/staging-testing]

url:    https://github.com/intel-lab-lkp/linux/commits/abdelnasser-hussein/staging-greybus-audio-evaluate-sscanf-return-value-directly/20260613-191253
base:   staging/staging-testing
patch link:    https://lore.kernel.org/r/20260613110748.13497-1-abdelnasserhussein11%40gmail.com
patch subject: [PATCH] staging: greybus: audio: evaluate sscanf() return value directly
config: riscv-allyesconfig (https://download.01.org/0day-ci/archive/20260614/202606140347.gGVWDnbi-lkp@intel.com/config)
compiler: clang version 23.0.0git (https://github.com/llvm/llvm-project 305faf498a4e0b52b40742c927af63ab2082e1a9)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260614/202606140347.gGVWDnbi-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/202606140347.gGVWDnbi-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/staging/greybus/audio_codec.c:325:13: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
     325 |         } else if (w->id == snd_soc_dapm_aif_out) {
         |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/staging/greybus/audio_codec.c:334:9: note: uninitialized use occurs here
     334 |         return ret;
         |                ^~~
   drivers/staging/greybus/audio_codec.c:325:9: note: remove the 'if' if its condition is always true
     325 |         } else if (w->id == snd_soc_dapm_aif_out) {
         |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/staging/greybus/audio_codec.c:302:17: note: initialize the variable 'ret' to silence this warning
     302 |         int dai_id, ret;
         |                        ^
         |                         = 0
   1 warning generated.


vim +325 drivers/staging/greybus/audio_codec.c

6dd67645f22cfe Vaibhav Agarwal     2016-03-29  297  
6dd67645f22cfe Vaibhav Agarwal     2016-03-29  298  int gbaudio_module_update(struct gbaudio_codec_info *codec,
4ffca62a051c3e Vaibhav Agarwal     2016-08-04  299  			  struct snd_soc_dapm_widget *w,
6dd67645f22cfe Vaibhav Agarwal     2016-03-29  300  			  struct gbaudio_module_info *module, int enable)
6dd67645f22cfe Vaibhav Agarwal     2016-03-29  301  {
60e7327d54b270 Vaibhav Agarwal     2016-08-04  302  	int dai_id, ret;
60e7327d54b270 Vaibhav Agarwal     2016-08-04  303  	char intf_name[NAME_SIZE], dir[NAME_SIZE];
6dd67645f22cfe Vaibhav Agarwal     2016-03-29  304  
60e7327d54b270 Vaibhav Agarwal     2016-08-04  305  	dev_dbg(module->dev, "%s:Module update %s sequence\n", w->name,
6dd67645f22cfe Vaibhav Agarwal     2016-03-29  306  		enable ? "Enable" : "Disable");
6dd67645f22cfe Vaibhav Agarwal     2016-03-29  307  
487dcbd6ba4654 Vaibhav Agarwal     2016-08-04  308  	if ((w->id != snd_soc_dapm_aif_in) && (w->id != snd_soc_dapm_aif_out)) {
60e7327d54b270 Vaibhav Agarwal     2016-08-04  309  		dev_dbg(codec->dev, "No action required for %s\n", w->name);
6dd67645f22cfe Vaibhav Agarwal     2016-03-29  310  		return 0;
6dd67645f22cfe Vaibhav Agarwal     2016-03-29  311  	}
6dd67645f22cfe Vaibhav Agarwal     2016-03-29  312  
60e7327d54b270 Vaibhav Agarwal     2016-08-04  313  	/* parse dai_id from AIF widget's stream_name */
034351c29c6494 abdelnasser hussein 2026-06-13  314  	if (sscanf(w->sname, "%s %d %s", intf_name, &dai_id, dir) != 3) {
620d28440c10b8 Deepak R Varma      2020-10-22  315  		dev_err(codec->dev, "Error while parsing dai_id for %s\n", w->name);
60e7327d54b270 Vaibhav Agarwal     2016-08-04  316  		return -EINVAL;
60e7327d54b270 Vaibhav Agarwal     2016-08-04  317  	}
60e7327d54b270 Vaibhav Agarwal     2016-08-04  318  
aaef32a6cc552d Vaibhav Agarwal     2016-08-04  319  	mutex_lock(&codec->lock);
487dcbd6ba4654 Vaibhav Agarwal     2016-08-04  320  	if (w->id == snd_soc_dapm_aif_in) {
6dd67645f22cfe Vaibhav Agarwal     2016-03-29  321  		if (enable)
60e7327d54b270 Vaibhav Agarwal     2016-08-04  322  			ret = gbaudio_module_enable_tx(codec, module, dai_id);
6dd67645f22cfe Vaibhav Agarwal     2016-03-29  323  		else
60e7327d54b270 Vaibhav Agarwal     2016-08-04  324  			ret = gbaudio_module_disable_tx(module, dai_id);
487dcbd6ba4654 Vaibhav Agarwal     2016-08-04 @325  	} else if (w->id == snd_soc_dapm_aif_out) {
094c4302c11889 Vaibhav Agarwal     2016-03-29  326  		if (enable)
60e7327d54b270 Vaibhav Agarwal     2016-08-04  327  			ret = gbaudio_module_enable_rx(codec, module, dai_id);
094c4302c11889 Vaibhav Agarwal     2016-03-29  328  		else
60e7327d54b270 Vaibhav Agarwal     2016-08-04  329  			ret = gbaudio_module_disable_rx(module, dai_id);
094c4302c11889 Vaibhav Agarwal     2016-03-29  330  	}
487dcbd6ba4654 Vaibhav Agarwal     2016-08-04  331  
aaef32a6cc552d Vaibhav Agarwal     2016-08-04  332  	mutex_unlock(&codec->lock);
6dd67645f22cfe Vaibhav Agarwal     2016-03-29  333  
6dd67645f22cfe Vaibhav Agarwal     2016-03-29  334  	return ret;
6dd67645f22cfe Vaibhav Agarwal     2016-03-29  335  }
6dd67645f22cfe Vaibhav Agarwal     2016-03-29  336  EXPORT_SYMBOL(gbaudio_module_update);
6dd67645f22cfe Vaibhav Agarwal     2016-03-29  337  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-13 19:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-13 11:07 [PATCH] staging: greybus: audio: evaluate sscanf() return value directly abdelnasser hussein
2026-06-13 19:41 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox