mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
HID: logitech-hidpp: initialize level variable
[ Upstream commit81c8bf9170] 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:be281368f2("hid-logitech-hidpp: read battery voltage from newer devices") Signed-off-by: Tom Rix <trix@redhat.com> Reviewed-by: Filipe Laíns <lains@riseup.net> Signed-off-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
4b1aba6536
commit
39b92726a3
@@ -1259,6 +1259,7 @@ static int hidpp20_battery_map_status_voltage(u8 data[3], int *voltage,
|
|||||||
int status;
|
int status;
|
||||||
|
|
||||||
long flags = (long) data[2];
|
long flags = (long) data[2];
|
||||||
|
*level = POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN;
|
||||||
|
|
||||||
if (flags & 0x80)
|
if (flags & 0x80)
|
||||||
switch (flags & 0x07) {
|
switch (flags & 0x07) {
|
||||||
|
|||||||
Reference in New Issue
Block a user