Message ID | 20250109125204.3668961-4-cezary.rojewski@intel.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | ALSA: hda: Compilation and firmware-loading fixes | expand |
On Thu, 09 Jan 2025 13:52:04 +0100, Cezary Rojewski wrote: > > strscpy() expects argument of type "char *", not "unsigned char *". > Found out by Coverity static analyzer. > > Fixes: 68fa05d4a82b ("ALSA: control: Introduce snd_ctl_find_id_mixer()") > Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> The conversion between char and unsigned char pointers isn't taken seriously in the kernel code. The compiler warning was disabled intentionally, too. In general, such an unnecessary cast is more harmful. thanks, Takashi > --- > include/sound/control.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/sound/control.h b/include/sound/control.h > index e07f6b960641..f7e18a1d144f 100644 > --- a/include/sound/control.h > +++ b/include/sound/control.h > @@ -161,7 +161,7 @@ snd_ctl_find_id_mixer(struct snd_card *card, const char *name) > struct snd_ctl_elem_id id = {}; > > id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; > - strscpy(id.name, name, sizeof(id.name)); > + strscpy((char *)id.name, name, sizeof(id.name)); > return snd_ctl_find_id(card, &id); > } > > -- > 2.25.1 >
On 2025-01-09 3:31 PM, Takashi Iwai wrote: > On Thu, 09 Jan 2025 13:52:04 +0100, > Cezary Rojewski wrote: >> >> strscpy() expects argument of type "char *", not "unsigned char *". >> Found out by Coverity static analyzer. >> >> Fixes: 68fa05d4a82b ("ALSA: control: Introduce snd_ctl_find_id_mixer()") >> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> > > The conversion between char and unsigned char pointers isn't taken > seriously in the kernel code. The compiler warning was disabled > intentionally, too. In general, such an unnecessary cast is more > harmful. Understood, will remove in v2 and squelch the analyzers on the intel side. >> --- >> include/sound/control.h | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/include/sound/control.h b/include/sound/control.h >> index e07f6b960641..f7e18a1d144f 100644 >> --- a/include/sound/control.h >> +++ b/include/sound/control.h >> @@ -161,7 +161,7 @@ snd_ctl_find_id_mixer(struct snd_card *card, const char *name) >> struct snd_ctl_elem_id id = {}; >> >> id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; >> - strscpy(id.name, name, sizeof(id.name)); >> + strscpy((char *)id.name, name, sizeof(id.name)); >> return snd_ctl_find_id(card, &id); >> } >> >> -- >> 2.25.1 >>
diff --git a/include/sound/control.h b/include/sound/control.h index e07f6b960641..f7e18a1d144f 100644 --- a/include/sound/control.h +++ b/include/sound/control.h @@ -161,7 +161,7 @@ snd_ctl_find_id_mixer(struct snd_card *card, const char *name) struct snd_ctl_elem_id id = {}; id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; - strscpy(id.name, name, sizeof(id.name)); + strscpy((char *)id.name, name, sizeof(id.name)); return snd_ctl_find_id(card, &id); }
strscpy() expects argument of type "char *", not "unsigned char *". Found out by Coverity static analyzer. Fixes: 68fa05d4a82b ("ALSA: control: Introduce snd_ctl_find_id_mixer()") Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> --- include/sound/control.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)