HID: logitech-hidpp: initialize level variable
authorTom Rix <trix@redhat.com>
Fri, 7 May 2021 19:18:19 +0000 (12:18 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Jun 2021 11:39:15 +0000 (13:39 +0200)
commit39b92726a38092c704c4e1bcc8262a8959ae978e
tree126affc5052424573e75a4fb7f238ed3ac950d85
parent4b1aba653642e469d954afefafa842025e10f00a
HID: logitech-hidpp: initialize level variable

[ Upstream commit 81c8bf9170477d453b24a6bc3300d201d641e645 ]

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: be281368f297 ("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>
drivers/hid/hid-logitech-hidpp.c