projects
/
linux.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
a77272c
)
platform/x86: huawei-wmi: do not hard-code sizes
author
Barnabás Pőcze
<pobrn@protonmail.com>
Wed, 5 Oct 2022 15:00:39 +0000
(15:00 +0000)
committer
Hans de Goede
<hdegoede@redhat.com>
Wed, 16 Nov 2022 07:48:18 +0000
(08:48 +0100)
Use `sizeof()` and `ARRAY_SIZE()` instead of
hard-coding buffer sizes and indices.
Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
Link:
https://lore.kernel.org/r/20221005150032.173198-1-pobrn@protonmail.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/platform/x86/huawei-wmi.c
patch
|
blob
|
history
diff --git
a/drivers/platform/x86/huawei-wmi.c
b/drivers/platform/x86/huawei-wmi.c
index 415ccb3a95decdfbc4c3f03257a6329599158ca7..2b48e86448b3ec85c349bb656dff5505c9811257 100644
(file)
--- a/
drivers/platform/x86/huawei-wmi.c
+++ b/
drivers/platform/x86/huawei-wmi.c
@@
-323,12
+323,12
@@
static int huawei_wmi_battery_get(int *start, int *end)
u8 ret[0x100];
int err, i;
- err = huawei_wmi_cmd(BATTERY_THRESH_GET, ret,
0x100
);
+ err = huawei_wmi_cmd(BATTERY_THRESH_GET, ret,
sizeof(ret)
);
if (err)
return err;
/* Find the last two non-zero values. Return status is ignored. */
- i =
0xff
;
+ i =
ARRAY_SIZE(ret) - 1
;
do {
if (start)
*start = ret[i-1];