Skip to content

Commit d6fef93

Browse files
pobrnjwrdegoede
authored andcommitted
platform/x86: huawei-wmi: do not hard-code sizes
Use `sizeof()` and `ARRAY_SIZE()` instead of hard-coding buffer sizes and indices. Signed-off-by: Barnabás Pőcze <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Hans de Goede <[email protected]>
1 parent a77272c commit d6fef93

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/platform/x86/huawei-wmi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,12 +323,12 @@ static int huawei_wmi_battery_get(int *start, int *end)
323323
u8 ret[0x100];
324324
int err, i;
325325

326-
err = huawei_wmi_cmd(BATTERY_THRESH_GET, ret, 0x100);
326+
err = huawei_wmi_cmd(BATTERY_THRESH_GET, ret, sizeof(ret));
327327
if (err)
328328
return err;
329329

330330
/* Find the last two non-zero values. Return status is ignored. */
331-
i = 0xff;
331+
i = ARRAY_SIZE(ret) - 1;
332332
do {
333333
if (start)
334334
*start = ret[i-1];

0 commit comments

Comments
 (0)