From: Bastien Nocera <hadess@hadess.net>
To: linux-usb@vger.kernel.org, linux-input@vger.kernel.org
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Alan Stern" <stern@rowland.harvard.edu>,
"Benjamin Tissoires" <benjamin.tissoires@redhat.com>,
"Filipe Laíns" <lains@riseup.net>,
"Nestor Lopez Casado" <nlopezcasad@logitech.com>
Subject: [PATCH v2 1/6] HID: logitech-hidpp: Simplify array length check
Date: Wed, 1 Mar 2023 13:23:05 +0100 [thread overview]
Message-ID: <20230301122310.3579-1-hadess@hadess.net> (raw)
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.
drivers/hid/hid-logitech-hidpp.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
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",
--
2.39.2
next reply other threads:[~2023-03-01 12:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-01 12:23 Bastien Nocera [this message]
2023-03-01 12:23 ` [PATCH v2 2/6] HID: logitech-hidpp: Add support for ADC measurement feature Bastien Nocera
2023-03-01 12:23 ` [PATCH v2 3/6] HID: logitech-hidpp: Add Logitech G935 headset Bastien Nocera
2023-03-01 12:23 ` [PATCH v2 4/6] USB: core: Add wireless_status sysfs attribute Bastien Nocera
2023-03-01 12:23 ` [PATCH v2 5/6] USB: core: Add API to change the wireless_status Bastien Nocera
2023-03-01 15:33 ` Alan Stern
2023-03-02 13:23 ` Bastien Nocera
2023-03-01 12:23 ` [PATCH v2 6/6] HID: logitech-hidpp: Set wireless_status for G935 receiver Bastien Nocera
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230301122310.3579-1-hadess@hadess.net \
--to=hadess@hadess.net \
--cc=benjamin.tissoires@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=lains@riseup.net \
--cc=linux-input@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=nlopezcasad@logitech.com \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox