Skip to contentSkip to conversation

sound: memalloc.c: Fix build warnings

PATCH In review Fabio Estevam 2 participants 3 messages Jan 16, 2012 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sound: memalloc.c: Fix build warnings

Fix the following build warnings:

sound/core/memalloc.c: In function ‘snd_mem_proc_write’:
sound/core/memalloc.c:426: warning: ‘vendor’ may be used uninitialized in this function sound/core/memalloc.c:426: warning: ‘device’ may be used uninitialized in this function sound/core/memalloc.c:426: warning: ‘size’ may be used uninitialized in this function sound/core/memalloc.c:426: warning: ‘buffers’ may be used uninitialized in this function sound/core/memalloc.c:427: warning: ‘mask’ may be used uninitialized in this function

---
 sound/core/memalloc.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
sound/core/memalloc.c +5 -2
index 6915692..7dbad80 100644
@@ -423,8 +423,11 @@ static ssize_t snd_mem_proc_write(struct file *file, const char __user * buffer,
 		return count;
 	if (strcmp(token, "add") == 0) {
 		char *endp;
-		int vendor, device, size, buffers;
-		long mask;
+		int vendor = 0;
+		int device = 0;
+		int size = 0; 
+		int buffers = 0;
+		long mask = 0;
 		int i, alloced;
 		struct pci_dev *pci;
 
Signature · 1 line
1.7.1
#1 lore raw

At Mon, 16 Jan 2012 01:02:02 -0200,

Quoted 9 lines · Fabio Estevam

Fix the following build warnings:

sound/core/memalloc.c: In function ‘snd_mem_proc_write’:
sound/core/memalloc.c:426: warning: ‘vendor’ may be used uninitialized in this function sound/core/memalloc.c:426: warning: ‘device’ may be used uninitialized in this function sound/core/memalloc.c:426: warning: ‘size’ may be used uninitialized in this function sound/core/memalloc.c:426: warning: ‘buffers’ may be used uninitialized in this function sound/core/memalloc.c:427: warning: ‘mask’ may be used uninitialized in this function

Hm, this must be a mis-detection by your compiler. Which gcc are you using?

In general, many people including me don't want to fix such a spot unless it's really a bug (or appearing in too many gcc versions).

thanks,

Takashi

Quoted 27 lines
---
 sound/core/memalloc.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
sound/core/memalloc.c +5 -2
index 6915692..7dbad80 100644
@@ -423,8 +423,11 @@ static ssize_t snd_mem_proc_write(struct file *file, const char __user * buffer,
 		return count;
 	if (strcmp(token, "add") == 0) {
 		char *endp;
-		int vendor, device, size, buffers;
-		long mask;
+		int vendor = 0;
+		int device = 0;
+		int size = 0; 
+		int buffers = 0;
+		long mask = 0;
 		int i, alloced;
 		struct pci_dev *pci;
 
Signature · 1 line
1.7.1

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#2 lore raw
Quoted 2 lines · Takashi Iwai

Hm, this must be a mis-detection by your compiler. Which gcc are you using?

gcc (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.

Regards,

Fabio Estevam