Skip to contentSkip to conversation

hid: Fix uninitialized variable "size" in hid-wiimote-debug

PATCH Applied Simon Que 3 participants 3 messages Jan 17, 2013 – Jan 18, 2013

Subsystems (2)
lore
Share & tools
lore

Simon Que

author
#0 lore raw

PATCH v2 1/1 hid: Fix uninitialized variable "size" in hid-wiimote-debug

This variable is initialized conditionally, based on whether a wiimote call succeeds. However, the logic is not obvious to the compiler so it throws a warning. Eliminate the warning by initializing "size" to 0.

The warning is:
files/drivers/hid/hid-wiimote-debug.c:69:18: warning: 'size' may be used uninitialized in this function [-Wmaybe-uninitialized]

---
 drivers/hid/hid-wiimote-debug.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/hid/hid-wiimote-debug.c +1 -1
index eec3291..90124ff 100644
@@ -31,7 +31,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
 	unsigned long flags;
 	ssize_t ret;
 	char buf[16];
-	__u16 size;
+	__u16 size = 0;
 
 	if (s == 0)
 		return -EINVAL;
Signature · 1 line
1.7.8.6
#1 lore raw

Hi Simon

Quoted 7 lines · Simon Que

This variable is initialized conditionally, based on whether a wiimote call succeeds. However, the logic is not obvious to the compiler so it throws a warning. Eliminate the warning by initializing "size" to 0.

The warning is:
files/drivers/hid/hid-wiimote-debug.c:69:18: warning: 'size' may be used uninitialized in this function [-Wmaybe-uninitialized]

Thanks!

Quoted 21 lines
---
 drivers/hid/hid-wiimote-debug.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/hid/hid-wiimote-debug.c +1 -2
index eec3291..90124ff 100644
@@ -31,7 +31,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
        unsigned long flags;
        ssize_t ret;
        char buf[16];
-       __u16 size;
+       __u16 size = 0;
 
        if (s == 0)
                return -EINVAL;
--

1.7.8.6

Applied
#2 lore raw
Quoted 11 lines · David Herrmann
Quoted 7 lines

This variable is initialized conditionally, based on whether a wiimote call succeeds. However, the logic is not obvious to the compiler so it throws a warning. Eliminate the warning by initializing "size" to 0.

The warning is:
files/drivers/hid/hid-wiimote-debug.c:69:18: warning: 'size' may be used uninitialized in this function [-Wmaybe-uninitialized]

Thanks!

Applied, thanks!

Signature · 2 lines
Jiri Kosina
SUSE Labs