2024-01-02 12:55:59

by Julia Lawall

[permalink] [raw]
Subject: sound/soc/codecs/tas2781-i2c.c:255:26-27: WARNING opportunity for min() (fwd)



---------- Forwarded message ----------
Date: Tue, 2 Jan 2024 19:53:21 +0800
From: kernel test robot <[email protected]>
To: [email protected]
Cc: [email protected], Julia Lawall <[email protected]>
Subject: sound/soc/codecs/tas2781-i2c.c:255:26-27: WARNING opportunity for min()

BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Shenghao Ding <[email protected]>
CC: Mark Brown <[email protected]>

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 610a9b8f49fbcf1100716370d3b5f6f884a2835a
commit: ef3bcde75d06d65f78ba38a30d5a87fb83a5cdae ASoC: tas2781: Add tas2781 driver
date: 7 months ago
:::::: branch date: 2 days ago
:::::: commit date: 7 months ago
config: sparc64-randconfig-r051-20240102 (https://download.01.org/0day-ci/archive/20240102/[email protected]/config)
compiler: sparc64-linux-gcc (GCC) 13.2.0

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 <[email protected]>
| Reported-by: Julia Lawall <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

cocci warnings: (new ones prefixed by >>)
>> sound/soc/codecs/tas2781-i2c.c:255:26-27: WARNING opportunity for min()
sound/soc/codecs/tas2781-i2c.c:365:14-15: WARNING opportunity for min()

vim +255 sound/soc/codecs/tas2781-i2c.c

ef3bcde75d06d6 Shenghao Ding 2023-06-18 223
ef3bcde75d06d6 Shenghao Ding 2023-06-18 224 static int tasdevice_create_control(struct tasdevice_priv *tas_priv)
ef3bcde75d06d6 Shenghao Ding 2023-06-18 225 {
ef3bcde75d06d6 Shenghao Ding 2023-06-18 226 struct snd_kcontrol_new *prof_ctrls;
ef3bcde75d06d6 Shenghao Ding 2023-06-18 227 int nr_controls = 1;
ef3bcde75d06d6 Shenghao Ding 2023-06-18 228 int mix_index = 0;
ef3bcde75d06d6 Shenghao Ding 2023-06-18 229 int ret;
ef3bcde75d06d6 Shenghao Ding 2023-06-18 230 char *name;
ef3bcde75d06d6 Shenghao Ding 2023-06-18 231
ef3bcde75d06d6 Shenghao Ding 2023-06-18 232 prof_ctrls = devm_kcalloc(tas_priv->dev, nr_controls,
ef3bcde75d06d6 Shenghao Ding 2023-06-18 233 sizeof(prof_ctrls[0]), GFP_KERNEL);
ef3bcde75d06d6 Shenghao Ding 2023-06-18 234 if (!prof_ctrls) {
ef3bcde75d06d6 Shenghao Ding 2023-06-18 235 ret = -ENOMEM;
ef3bcde75d06d6 Shenghao Ding 2023-06-18 236 goto out;
ef3bcde75d06d6 Shenghao Ding 2023-06-18 237 }
ef3bcde75d06d6 Shenghao Ding 2023-06-18 238
ef3bcde75d06d6 Shenghao Ding 2023-06-18 239 /* Create a mixer item for selecting the active profile */
ef3bcde75d06d6 Shenghao Ding 2023-06-18 240 name = devm_kzalloc(tas_priv->dev, SNDRV_CTL_ELEM_ID_NAME_MAXLEN,
ef3bcde75d06d6 Shenghao Ding 2023-06-18 241 GFP_KERNEL);
ef3bcde75d06d6 Shenghao Ding 2023-06-18 242 if (!name) {
ef3bcde75d06d6 Shenghao Ding 2023-06-18 243 ret = -ENOMEM;
ef3bcde75d06d6 Shenghao Ding 2023-06-18 244 goto out;
ef3bcde75d06d6 Shenghao Ding 2023-06-18 245 }
ef3bcde75d06d6 Shenghao Ding 2023-06-18 246 scnprintf(name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, "Speaker Profile Id");
ef3bcde75d06d6 Shenghao Ding 2023-06-18 247 prof_ctrls[mix_index].name = name;
ef3bcde75d06d6 Shenghao Ding 2023-06-18 248 prof_ctrls[mix_index].iface = SNDRV_CTL_ELEM_IFACE_MIXER;
ef3bcde75d06d6 Shenghao Ding 2023-06-18 249 prof_ctrls[mix_index].info = tasdevice_info_profile;
ef3bcde75d06d6 Shenghao Ding 2023-06-18 250 prof_ctrls[mix_index].get = tasdevice_get_profile_id;
ef3bcde75d06d6 Shenghao Ding 2023-06-18 251 prof_ctrls[mix_index].put = tasdevice_set_profile_id;
ef3bcde75d06d6 Shenghao Ding 2023-06-18 252 mix_index++;
ef3bcde75d06d6 Shenghao Ding 2023-06-18 253
ef3bcde75d06d6 Shenghao Ding 2023-06-18 254 ret = snd_soc_add_component_controls(tas_priv->codec,
ef3bcde75d06d6 Shenghao Ding 2023-06-18 @255 prof_ctrls, nr_controls < mix_index ? nr_controls : mix_index);
ef3bcde75d06d6 Shenghao Ding 2023-06-18 256
ef3bcde75d06d6 Shenghao Ding 2023-06-18 257 out:
ef3bcde75d06d6 Shenghao Ding 2023-06-18 258 return ret;
ef3bcde75d06d6 Shenghao Ding 2023-06-18 259 }
ef3bcde75d06d6 Shenghao Ding 2023-06-18 260

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