sound/core/control_led.c:492:22: sparse: sparse: incorrect type in assignment (different base types)

From: kernel test robot
Date: Fri Nov 19 2021 - 21:22:48 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: a90af8f15bdc9449ee2d24e1d73fa3f7e8633f81
commit: a135dfb5de1501327895729b4f513370d2555b4d ALSA: led control - add sysfs kcontrol LED marking layer
date: 8 months ago
config: sparc64-randconfig-s031-20211116 (attached as .config)
compiler: sparc64-linux-gcc (GCC) 11.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a135dfb5de1501327895729b4f513370d2555b4d
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout a135dfb5de1501327895729b4f513370d2555b4d
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=sparc64

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


sparse warnings: (new ones prefixed by >>)
>> sound/core/control_led.c:492:22: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int @@ got restricted snd_ctl_elem_iface_t [usertype] @@
sound/core/control_led.c:492:22: sparse: expected unsigned int
sound/core/control_led.c:492:22: sparse: got restricted snd_ctl_elem_iface_t [usertype]
sound/core/control_led.c:494:22: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int @@ got restricted snd_ctl_elem_iface_t [usertype] @@
sound/core/control_led.c:494:22: sparse: expected unsigned int
sound/core/control_led.c:494:22: sparse: got restricted snd_ctl_elem_iface_t [usertype]
>> sound/core/control_led.c:523:49: sparse: sparse: incorrect type in argument 2 (different base types) @@ expected unsigned int *val @@ got restricted snd_ctl_elem_iface_t * @@
sound/core/control_led.c:523:49: sparse: expected unsigned int *val
sound/core/control_led.c:523:49: sparse: got restricted snd_ctl_elem_iface_t *

vim +492 sound/core/control_led.c

488
489 static char *parse_iface(char *s, unsigned int *val)
490 {
491 if (!strncasecmp(s, "card", 4))
> 492 *val = SNDRV_CTL_ELEM_IFACE_CARD;
493 else if (!strncasecmp(s, "mixer", 5))
494 *val = SNDRV_CTL_ELEM_IFACE_MIXER;
495 return find_eos(s);
496 }
497
498 /*
499 * These types of input strings are accepted:
500 *
501 * unsigned integer - numid (equivaled to numid=UINT)
502 * string - basic mixer name (equivalent to iface=MIXER,name=STR)
503 * numid=UINT
504 * [iface=MIXER,][device=UINT,][subdevice=UINT,]name=STR[,index=UINT]
505 */
506 static ssize_t set_led_id(struct snd_ctl_led_card *led_card, const char *buf, size_t count,
507 bool attach)
508 {
509 char buf2[256], *s;
510 size_t len = max(sizeof(s) - 1, count);
511 struct snd_ctl_elem_id id;
512 int err;
513
514 strncpy(buf2, buf, len);
515 buf2[len] = '\0';
516 memset(&id, 0, sizeof(id));
517 id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
518 s = buf2;
519 while (*s) {
520 if (!strncasecmp(s, "numid=", 6)) {
521 s = parse_uint(s + 6, &id.numid);
522 } else if (!strncasecmp(s, "iface=", 6)) {
> 523 s = parse_iface(s + 6, &id.iface);
524 } else if (!strncasecmp(s, "device=", 7)) {
525 s = parse_uint(s + 7, &id.device);
526 } else if (!strncasecmp(s, "subdevice=", 10)) {
527 s = parse_uint(s + 10, &id.subdevice);
528 } else if (!strncasecmp(s, "name=", 5)) {
529 s = parse_string(s + 5, id.name, sizeof(id.name));
530 } else if (!strncasecmp(s, "index=", 6)) {
531 s = parse_uint(s + 6, &id.index);
532 } else if (s == buf2) {
533 while (*s) {
534 if (*s < '0' || *s > '9')
535 break;
536 s++;
537 }
538 if (*s == '\0')
539 parse_uint(buf2, &id.numid);
540 else {
541 for (; *s >= ' '; s++);
542 *s = '\0';
543 strlcpy(id.name, buf2, sizeof(id.name));
544 }
545 break;
546 }
547 if (*s == ',')
548 s++;
549 }
550
551 err = snd_ctl_led_set_id(led_card->number, &id, led_card->led->group, attach);
552 if (err < 0)
553 return err;
554
555 return count;
556 }
557

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

Attachment: .config.gz
Description: application/gzip