hid: Fix uninitialized variable "size" in hid-wiimote-debug
Subsystems (2)
PATCH 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.
--- drivers/hid/hid-wiimote-debug.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/hid/hid-wiimote-debug.c +1 -1
@@ -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
Hi Simon
Quoted 3 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.
Hm, I think it says:
54 ret = wiimote_cmd_wait(wdata); 55 if (!ret) 56 size = wdata->state.cmd_read_size;
...not touching "size" or "ret" inbetween...
64 if (ret)
65 return ret;
...using "size" below...
Weird that gcc cannot figure that out that there is no path to line 66 where "size" is uninitialized. Anyway, I am fine with this fix. We test for "size == 0" anyway.
Next time please copy the gcc-warning message verbatim into the commit-message so we can more easily reproduce this and see which line is affected.
Thanks for the patch
David
CC'ing Jiri so he can apply it to hid-next.
Quoted 32 lines · David Herrmann
Hi Simon
Quoted 3 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.
Hm, I think it says:
54 ret = wiimote_cmd_wait(wdata); 55 if (!ret) 56 size = wdata->state.cmd_read_size;...not touching "size" or "ret" inbetween...
64 if (ret)
65 return ret;...using "size" below...
Weird that gcc cannot figure that out that there is no path to line 66 where "size" is uninitialized. Anyway, I am fine with this fix. We test for "size == 0" anyway.
Signed-off-by David Herrmann <[email protected]>Next time please copy the gcc-warning message verbatim into the commit-message so we can more easily reproduce this and see which line is affected.
Thanks for the patch
David