Re: [patch] sound/usb/format: silence uninitialized variable warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At Sat, 14 Aug 2010 10:58:47 +0200,
Dan Carpenter wrote:
> 
> Gcc complains that ret might be used uninitialized:
> 
> sound/usb/format.c: In function ‘snd_usb_parse_audio_format’:
> sound/usb/format.c:354: warning: ‘ret’ may be used uninitialized in this function
> sound/usb/format.c:354: note: ‘ret’ was declared here
> sound/usb/format.c:414: warning: ‘ret’ may be used uninitialized in this function
> sound/usb/format.c:414: note: ‘ret’ was declared here
> 
> I suppose it could be if there is ever a UAC_VERSION_3 released. Anyway
> this patch is worthwhile if only to silence the gcc warning.

It's nice to catch such possible bugs.
But, it'd be even nicer if kernel gives messages what's wrong instead
of silent break-up. 
Could you add error messages and repost the revised patch?


thanks,

Takashi

> 
> Signed-off-by: Dan Carpenter <error27@xxxxxxxxx>
> 
> diff --git a/sound/usb/format.c b/sound/usb/format.c
> index 4387f54..1400174 100644
> --- a/sound/usb/format.c
> +++ b/sound/usb/format.c
> @@ -351,7 +351,8 @@ static int parse_audio_format_i(struct snd_usb_audio *chip,
>  {
>  	struct usb_interface_descriptor *altsd = get_iface_desc(iface);
>  	int protocol = altsd->bInterfaceProtocol;
> -	int pcm_format, ret;
> +	int pcm_format;
> +	int ret = -EINVAL;
>  
>  	if (fmt->bFormatType == UAC_FORMAT_TYPE_III) {
>  		/* FIXME: the format type is really IECxxx
> @@ -411,9 +412,10 @@ static int parse_audio_format_ii(struct snd_usb_audio *chip,
>  				 int format, void *_fmt,
>  				 struct usb_host_interface *iface)
>  {
> -	int brate, framesize, ret;
> +	int brate, framesize;
>  	struct usb_interface_descriptor *altsd = get_iface_desc(iface);
>  	int protocol = altsd->bInterfaceProtocol;
> +	int ret = -EINVAL;
>  
>  	switch (format) {
>  	case UAC_FORMAT_TYPE_II_AC3:
> 
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux