oe-kbuild-all.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: "Geoffrey D. Bennett" <g@b4.vu>
Cc: oe-kbuild-all@lists.linux.dev
Subject: [geoffreybennett-scarlett-gen2:scarlett2 1/1] sound/usb/mixer_scarlett2.c:7962 scarlett2_update_spdif_mode() warn: always true condition '(*mode_values != -1) => (0-255 != (-1))'
Date: Sat, 11 May 2024 23:26:28 +0800	[thread overview]
Message-ID: <202405112311.pOVg45tK-lkp@intel.com> (raw)

tree:   https://github.com/geoffreybennett/scarlett-gen2.git scarlett2
head:   480eafc2d57158b29e8e5efa5b1ac8b5e5a01af8
commit: 480eafc2d57158b29e8e5efa5b1ac8b5e5a01af8 [1/1] ALSA: scarlett2: Add S/PDIF source selection controls
config: i386-randconfig-141-20240511 (https://download.01.org/0day-ci/archive/20240511/202405112311.pOVg45tK-lkp@intel.com/config)
compiler: gcc-8 (Ubuntu 8.4.0-3ubuntu2) 8.4.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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202405112311.pOVg45tK-lkp@intel.com/

New smatch warnings:
sound/usb/mixer_scarlett2.c:7962 scarlett2_update_spdif_mode() warn: always true condition '(*mode_values != -1) => (0-255 != (-1))'
sound/usb/mixer_scarlett2.c:7962 scarlett2_update_spdif_mode() warn: always true condition '(*mode_values != -1) => (0-255 != (-1))'
sound/usb/mixer_scarlett2.c:8016 scarlett2_spdif_mode_ctl_put() warn: impossible condition '(private->info->spdif_mode_values[i] == -1) => (0-255 == (-1))'

Old smatch warnings:
sound/usb/mixer_scarlett2.c:9224 scarlett2_ioctl_select_flash_segment() warn: potential spectre issue 'private->flash_segment_nums' [r] (local cap)
sound/usb/mixer_scarlett2.c:9225 scarlett2_ioctl_select_flash_segment() warn: possible spectre second half.  'segment_num'

vim +7962 sound/usb/mixer_scarlett2.c

  7944	
  7945	static int scarlett2_update_spdif_mode(struct usb_mixer_interface *mixer)
  7946	{
  7947		struct scarlett2_data *private = mixer->private_data;
  7948		int err, i;
  7949		u8 mode;
  7950		const u8 *mode_values = private->info->spdif_mode_values;
  7951	
  7952		if (!private->info->spdif_mode_control_name)
  7953			return 0;
  7954	
  7955		err = scarlett2_usb_get_config(mixer, SCARLETT2_CONFIG_SPDIF_MODE,
  7956					       1, &mode);
  7957		if (err < 0)
  7958			return err;
  7959	
  7960		private->spdif_mode = 0;
  7961	
> 7962		for (i = 0; *mode_values != -1; i++, mode_values++)
  7963			if (*mode_values == mode) {
  7964				private->spdif_mode = i;
  7965				break;
  7966			}
  7967	
  7968		return 0;
  7969	}
  7970	
  7971	static int scarlett2_spdif_mode_ctl_info(struct snd_kcontrol *kctl,
  7972						   struct snd_ctl_elem_info *uinfo)
  7973	{
  7974		struct usb_mixer_elem_info *elem = kctl->private_data;
  7975		struct scarlett2_data *private = elem->head.mixer->private_data;
  7976		const char * const *mode_texts = private->info->spdif_mode_texts;
  7977		int count = 0;
  7978	
  7979		while (*mode_texts++)
  7980			count++;
  7981	
  7982		return snd_ctl_enum_info(uinfo, 1, count,
  7983					 private->info->spdif_mode_texts);
  7984	}
  7985	
  7986	static int scarlett2_spdif_mode_ctl_get(struct snd_kcontrol *kctl,
  7987						  struct snd_ctl_elem_value *ucontrol)
  7988	{
  7989		struct usb_mixer_elem_info *elem = kctl->private_data;
  7990		struct scarlett2_data *private = elem->head.mixer->private_data;
  7991	
  7992		ucontrol->value.enumerated.item[0] = private->spdif_mode;
  7993		return 0;
  7994	}
  7995	
  7996	static int scarlett2_spdif_mode_ctl_put(struct snd_kcontrol *kctl,
  7997						  struct snd_ctl_elem_value *ucontrol)
  7998	{
  7999		struct usb_mixer_elem_info *elem = kctl->private_data;
  8000		struct usb_mixer_interface *mixer = elem->head.mixer;
  8001		struct scarlett2_data *private = mixer->private_data;
  8002		int oval, val, err = 0;
  8003		int i;
  8004	
  8005		mutex_lock(&private->data_mutex);
  8006	
  8007		oval = private->spdif_mode;
  8008		val = ucontrol->value.enumerated.item[0];
  8009	
  8010		if (val < 0) {
  8011			err = -EINVAL;
  8012			goto unlock;
  8013		}
  8014	
  8015		for (i = 0; i <= val; i++)
> 8016			if (private->info->spdif_mode_values[i] == -1) {
  8017				err = -EINVAL;
  8018				goto unlock;
  8019			}
  8020	
  8021		if (oval == val)
  8022			goto unlock;
  8023	
  8024		private->spdif_mode = val;
  8025	
  8026		err = scarlett2_usb_set_config(
  8027			mixer, SCARLETT2_CONFIG_SPDIF_MODE, 0,
  8028			private->info->spdif_mode_values[val]);
  8029		if (!err)
  8030			err = 1;
  8031	
  8032	unlock:
  8033		mutex_unlock(&private->data_mutex);
  8034		return err;
  8035	}
  8036	

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

                 reply	other threads:[~2024-05-11 15:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=202405112311.pOVg45tK-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=g@b4.vu \
    --cc=oe-kbuild-all@lists.linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).