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:
Barnabás Pőcze 2022-10-05 15:00:39 +00:00 committed by Hans de Goede
parent a77272c160
commit d6fef93258

View File

@ -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];