[PATCH] HID: uhid: silence gcc warning

Subsystems: hid core layer, the rest, uhid userspace hid io driver

STALE5167d

2 messages, 2 authors, 2012-06-18 · open the first message on its own page

[PATCH] HID: uhid: silence gcc warning

From: Jiri Kosina <hidden>
Date: 2012-06-18 15:12:37

gcc is giving me:

drivers/hid/uhid.c: In function ‘uhid_hid_get_raw’:
drivers/hid/uhid.c:157: warning: ‘len’ may be used uninitialized in this function

which is clearly bogus, as

- when used as memcpy() argument, it's initialized properly
- the code is structured in a way that either 'ret' or 'len'
  is always initialized, so the return statement always has
  an initialized value.

Signed-off-by: Jiri Kosina <redacted>
---
David,

I have applied this on top of your uhid series in my tree.

 drivers/hid/uhid.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
index ea560bf..119b7e6 100644
--- a/drivers/hid/uhid.c
+++ b/drivers/hid/uhid.c
@@ -154,7 +154,7 @@ static int uhid_hid_get_raw(struct hid_device *hid, unsigned char rnum,
 	struct uhid_event *ev;
 	unsigned long flags;
 	int ret;
-	size_t len;
+	size_t uninitialized_var(len);
 	struct uhid_feature_answer_req *req;
 
 	if (!uhid->running)
-- 
Jiri Kosina
SUSE Labs

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Re: [PATCH] HID: uhid: silence gcc warning

From: David Herrmann <hidden>
Date: 2012-06-18 18:09:30

Hi Jiri

On Mon, Jun 18, 2012 at 5:12 PM, Jiri Kosina [off-list ref] wrote:
gcc is giving me:

drivers/hid/uhid.c: In function ‘uhid_hid_get_raw’:
drivers/hid/uhid.c:157: warning: ‘len’ may be used uninitialized in this function

which is clearly bogus, as

- when used as memcpy() argument, it's initialized properly
- the code is structured in a way that either 'ret' or 'len'
 is always initialized, so the return statement always has
 an initialized value.

Signed-off-by: Jiri Kosina <redacted>
---
David,

I have applied this on top of your uhid series in my tree.
Yes, looks totally bogus to me, too. I also don't get the warning with
gcc-4.7.0. Thanks for applying it, looks ok to me.

Regards
David
 drivers/hid/uhid.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help