All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Jaroslav Kysela <perex@perex.cz>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
	alsa-devel@alsa-project.org, Takashi Iwai <tiwai@suse.de>,
	Clemens Ladisch <clemens@ladisch.de>,
	kernel-janitors@vger.kernel.org
Subject: [patch] sound/usb/format: silence uninitialized variable warnings
Date: Sat, 14 Aug 2010 10:58:47 +0200	[thread overview]
Message-ID: <20100814085846.GV645@bicker> (raw)

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.

Signed-off-by: Dan Carpenter <error27@gmail.com>

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:
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <error27@gmail.com>
To: Jaroslav Kysela <perex@perex.cz>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
	alsa-devel@alsa-project.org, Takashi Iwai <tiwai@suse.de>,
	Clemens Ladisch <clemens@ladisch.de>,
	kernel-janitors@vger.kernel.org
Subject: [patch] sound/usb/format: silence uninitialized variable warnings
Date: Sat, 14 Aug 2010 08:58:47 +0000	[thread overview]
Message-ID: <20100814085846.GV645@bicker> (raw)

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.

Signed-off-by: Dan Carpenter <error27@gmail.com>

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:

             reply	other threads:[~2010-08-14  8:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-14  8:58 Dan Carpenter [this message]
2010-08-14  8:58 ` [patch] sound/usb/format: silence uninitialized variable warnings Dan Carpenter
2010-08-14 14:24 ` Takashi Iwai
2010-08-14 14:24   ` Takashi Iwai
2010-08-14 17:29   ` [patch v2] " Dan Carpenter
2010-08-14 17:29     ` [patch v2] sound/usb/format: silence uninitialized variable Dan Carpenter
2010-08-14 17:38     ` [patch v2] sound/usb/format: silence uninitialized variable warnings Daniel Mack
2010-08-14 17:38       ` [patch v2] sound/usb/format: silence uninitialized variable Daniel Mack
2010-08-15 12:38     ` [patch v2] sound/usb/format: silence uninitialized variable warnings Takashi Iwai
2010-08-15 12:38       ` Takashi Iwai

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=20100814085846.GV645@bicker \
    --to=error27@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=sfr@canb.auug.org.au \
    --cc=tiwai@suse.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.