2024-02-01 07:14:05

by Cong Liu

[permalink] [raw]
Subject: [PATCH] fbdev/sh_mobile_lcdcfb: Replace deprecated simple_strtol with kstrtol

This patch replaces the use of the deprecated simple_strtol [1] function
in the sh_mobile_lcdcfb.c file with the recommended kstrtol function.
This change improves error handling and boundary checks.

[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#simple-strtol-simple-strtoll-simple-strtoul-simple-strtoull

Signed-off-by: Cong Liu <[email protected]>
---
drivers/video/fbdev/sh_mobile_lcdcfb.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/sh_mobile_lcdcfb.c b/drivers/video/fbdev/sh_mobile_lcdcfb.c
index eb2297b37504..5fc7d74b273e 100644
--- a/drivers/video/fbdev/sh_mobile_lcdcfb.c
+++ b/drivers/video/fbdev/sh_mobile_lcdcfb.c
@@ -1278,11 +1278,11 @@ overlay_position_store(struct device *dev, struct device_attribute *attr,
int pos_x;
int pos_y;

- pos_x = simple_strtol(buf, &endp, 10);
+ pos_x = kstrtol(buf, &endp, 10);
if (*endp != ',')
return -EINVAL;

- pos_y = simple_strtol(endp + 1, &endp, 10);
+ pos_y = kstrtol(endp + 1, &endp, 10);
if (isspace(*endp))
endp++;

--
2.34.1



2024-02-01 10:04:39

by Jani Nikula

[permalink] [raw]
Subject: Re: [PATCH] fbdev/sh_mobile_lcdcfb: Replace deprecated simple_strtol with kstrtol

On Thu, 01 Feb 2024, Cong Liu <[email protected]> wrote:
> This patch replaces the use of the deprecated simple_strtol [1] function
> in the sh_mobile_lcdcfb.c file with the recommended kstrtol function.
> This change improves error handling and boundary checks.
>
> [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#simple-strtol-simple-strtoll-simple-strtoul-simple-strtoull
>
> Signed-off-by: Cong Liu <[email protected]>

This is completely wrong, and obviously not tested at all.

The recommended replacements are *not* drop-in replacements. Look into
the documentation of the functions.

BR,
Jani.

> ---
> drivers/video/fbdev/sh_mobile_lcdcfb.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/video/fbdev/sh_mobile_lcdcfb.c b/drivers/video/fbdev/sh_mobile_lcdcfb.c
> index eb2297b37504..5fc7d74b273e 100644
> --- a/drivers/video/fbdev/sh_mobile_lcdcfb.c
> +++ b/drivers/video/fbdev/sh_mobile_lcdcfb.c
> @@ -1278,11 +1278,11 @@ overlay_position_store(struct device *dev, struct device_attribute *attr,
> int pos_x;
> int pos_y;
>
> - pos_x = simple_strtol(buf, &endp, 10);
> + pos_x = kstrtol(buf, &endp, 10);
> if (*endp != ',')
> return -EINVAL;
>
> - pos_y = simple_strtol(endp + 1, &endp, 10);
> + pos_y = kstrtol(endp + 1, &endp, 10);
> if (isspace(*endp))
> endp++;

--
Jani Nikula, Intel