Skip to content

Commit 81c8bf9

Browse files
Tom RixJiri Kosina
authored andcommitted
HID: logitech-hidpp: initialize level variable
Static analysis reports this representative problem hid-logitech-hidpp.c:1356:23: warning: Assigned value is garbage or undefined hidpp->battery.level = level; ^ ~~~~~ In some cases, 'level' is never set in hidpp20_battery_map_status_voltage() Since level is not available on all hw, initialize level to unknown. Fixes: be28136 ("hid-logitech-hidpp: read battery voltage from newer devices") Signed-off-by: Tom Rix <[email protected]> Reviewed-by: Filipe Laíns <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 31a4cf1 commit 81c8bf9

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/hid/hid-logitech-hidpp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,7 @@ static int hidpp20_battery_map_status_voltage(u8 data[3], int *voltage,
12631263
int status;
12641264

12651265
long flags = (long) data[2];
1266+
*level = POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN;
12661267

12671268
if (flags & 0x80)
12681269
switch (flags & 0x07) {

0 commit comments

Comments
 (0)