mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 12:28:41 +08:00
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 <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>
This commit is contained in:
parent
a77272c160
commit
d6fef93258
@ -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];
|
||||
|
Loading…
Reference in New Issue
Block a user