Skip to content

Commit e013876

Browse files
hadessbentiss
authored andcommitted
HID: logitech-hidpp: Simplify array length check
Use the compiler to force a 100-length array, rather than check the length after the fact. Signed-off-by: Bastien Nocera <hadess@hadess.net> Link: https://lore.kernel.org/r/20230302105555.51417-1-hadess@hadess.net Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
1 parent 5b3691d commit e013876

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

drivers/hid/hid-logitech-hidpp.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,7 +1404,7 @@ static int hidpp20_map_battery_capacity(struct hid_device *hid_dev, int voltage)
14041404
* there are a few devices that use different battery technology.
14051405
*/
14061406

1407-
static const int voltages[] = {
1407+
static const int voltages[100] = {
14081408
4186, 4156, 4143, 4133, 4122, 4113, 4103, 4094, 4086, 4075,
14091409
4067, 4059, 4051, 4043, 4035, 4027, 4019, 4011, 4003, 3997,
14101410
3989, 3983, 3976, 3969, 3961, 3955, 3949, 3942, 3935, 3929,
@@ -1419,8 +1419,6 @@ static int hidpp20_map_battery_capacity(struct hid_device *hid_dev, int voltage)
14191419

14201420
int i;
14211421

1422-
BUILD_BUG_ON(ARRAY_SIZE(voltages) != 100);
1423-
14241422
if (unlikely(voltage < 3500 || voltage >= 5000))
14251423
hid_warn_once(hid_dev,
14261424
"%s: possibly using the wrong voltage curve\n",

0 commit comments

Comments
 (0)