[alsa-devel] sound/pci/au88x0/au88x0_core.c: many calls to memset with not-plausible size ?

Takashi Iwai tiwai at suse.de
Sun May 8 11:30:41 CEST 2016


On Mon, 02 May 2016 16:43:15 +0200,
David Binderman wrote:
> 
> Hello there,
> 
> sound/pci/au88x0/au88x0_core.c:2153:6: warning: ‘memset’ used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size]
> 
> Source code is
> 
>                    memset(stream->resources, 0,
>                            sizeof(unsigned char) *
>                            VORTEX_RESOURCE_LAST);
> 
> but
> 
> sound/pci/au88x0/au88x0.h:    u32 resources[5];
> 
> Something like
> 
>                  memset(stream->resources, 0,
>                            sizeof(stream->resources[0]) *
>                            VORTEX_RESOURCE_LAST);
> 
> Some duplicates:
> 
> sound/pci/au88x0/au88x0_core.c:2163:7: warning: ‘memset’ used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size]
> sound/pci/au88x0/au88x0_core.c:2177:5: warning: ‘memset’ used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size]
> sound/pci/au88x0/au88x0_core.c:2292:5: warning: ‘memset’ used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size]
> sound/pci/au88x0/au88x0_core.c:2301:5: warning: ‘memset’ used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size]

Yes, indeed these look wrong.  But the simplest fix is just to write
like
	memset(stream->resources, 0, sizeof(stream->resources));

Care to send a fix patch?


thanks,

Takashi


More information about the Alsa-devel mailing list