Message ID | 20230302105555.51417-1-hadess@hadess.net |
---|---|
State | New |
Headers | show |
Series | [v3,1/6] HID: logitech-hidpp: Simplify array length check | expand |
On Thu, Mar 02, 2023 at 11:55:50AM +0100, Bastien Nocera wrote: > 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> > --- > New in v2, following a review comment in the 1f20 enablement patch. > No changes in v3. > > drivers/hid/hid-logitech-hidpp.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) These all look good to me, and probably should go through the HID tree, so I've acked the USB-specific ones to allow that. thanks, greg k-h
diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index ff1fcebf2ec7..f55b2233dbea 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -1356,7 +1356,7 @@ static int hidpp20_map_battery_capacity(struct hid_device *hid_dev, int voltage) * there are a few devices that use different battery technology. */ - static const int voltages[] = { + static const int voltages[100] = { 4186, 4156, 4143, 4133, 4122, 4113, 4103, 4094, 4086, 4075, 4067, 4059, 4051, 4043, 4035, 4027, 4019, 4011, 4003, 3997, 3989, 3983, 3976, 3969, 3961, 3955, 3949, 3942, 3935, 3929, @@ -1371,8 +1371,6 @@ static int hidpp20_map_battery_capacity(struct hid_device *hid_dev, int voltage) int i; - BUILD_BUG_ON(ARRAY_SIZE(voltages) != 100); - if (unlikely(voltage < 3500 || voltage >= 5000)) hid_warn_once(hid_dev, "%s: possibly using the wrong voltage curve\n",
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> --- New in v2, following a review comment in the 1f20 enablement patch. No changes in v3. drivers/hid/hid-logitech-hidpp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)