[PATCH v2] hid: Fix uninitialized variable "size" in hid-wiimote-debug

Subsystems: hid core layer, the rest, wiimote hid driver

STALE5027d

3 messages, 3 authors, 2013-01-18 · open the first message on its own page

[PATCH v2] hid: Fix uninitialized variable "size" in hid-wiimote-debug

From: Simon Que <hidden>
Date: 2013-01-17 21:03:06

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]

Signed-off-by: Simon Que <redacted>
---
 drivers/hid/hid-wiimote-debug.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
index eec3291..90124ff 100644
--- a/drivers/hid/hid-wiimote-debug.c
+++ b/drivers/hid/hid-wiimote-debug.c
@@ -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

Re: [PATCH v2] hid: Fix uninitialized variable "size" in hid-wiimote-debug

From: David Herrmann <hidden>
Date: 2013-01-17 21:07:47

Hi Simon

On Thu, Jan 17, 2013 at 10:02 PM, Simon Que [off-list ref] wrote:
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!

Signed-off-by: David Herrmann <redacted>
quoted hunk
Signed-off-by: Simon Que <redacted>
---
 drivers/hid/hid-wiimote-debug.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
index eec3291..90124ff 100644
--- a/drivers/hid/hid-wiimote-debug.c
+++ b/drivers/hid/hid-wiimote-debug.c
@@ -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

Re: [PATCH v2] hid: Fix uninitialized variable "size" in hid-wiimote-debug

From: Jiri Kosina <hidden>
Date: 2013-01-18 10:00:01

On Thu, 17 Jan 2013, David Herrmann wrote:
quoted
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!

Signed-off-by: David Herrmann <redacted>
Applied, thanks!

-- 
Jiri Kosina
SUSE Labs
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help