Re: [PATCH v2 3/3] platform/x86: dell-laptop: Parse the charge end threshold as an int
From: Ilpo Järvinen
Date: Mon Nov 23 2026 - 03:33:02 EST
On Fri, 20 Nov 2026, Rosen Penev wrote:
> charge_control_end_threshold_store() passes a pointer to an int to
> kstrtouint(), which only builds because the kernel disables
> -Wpointer-sign, and makes the following "end < 0" check dead code.
> Use kstrtoint() like charge_control_start_threshold_store(). Values
> outside 0 to 100 are rejected either way.
Why the <0 check has to be kept on the driver side?
Why not change the variable type instead and remove the then dead code
check?
It's somewhat disappointing this even has to be pointed out by review.
> Signed-off-by: Rosen Penev <rosenp@xxxxxxxxx>
> ---
> drivers/platform/x86/dell/dell-laptop.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/dell/dell-laptop.c b/drivers/platform/x86/dell/dell-laptop.c
> index eca348497ac3..c512267be4c4 100644
> --- a/drivers/platform/x86/dell/dell-laptop.c
> +++ b/drivers/platform/x86/dell/dell-laptop.c
> @@ -2382,7 +2382,7 @@ static ssize_t charge_control_end_threshold_store(struct device *dev,
> {
> int ret, end;
>
> - ret = kstrtouint(buf, 10, &end);
> + ret = kstrtoint(buf, 10, &end);
> if (ret)
> return ret;
> if (end < 0 || end > 100)
>
--
i.