dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fbdev/core: Replace deprecated simple_strtol with kstrtol
@ 2024-02-01  7:02 Cong Liu
  2024-02-01 10:03 ` Jani Nikula
  0 siblings, 1 reply; 2+ messages in thread
From: Cong Liu @ 2024-02-01  7:02 UTC (permalink / raw)
  To: Daniel Vetter, Helge Deller
  Cc: linux-fbdev, Cong Liu, linux-kernel, dri-devel

This patch replaces the use of the deprecated simple_strtol [1] function
in the modedb.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 <liucong2@kylinos.cn>
---
 drivers/video/fbdev/core/modedb.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/video/fbdev/core/modedb.c b/drivers/video/fbdev/core/modedb.c
index 7196b055f2bd..eebbbc7e2aa3 100644
--- a/drivers/video/fbdev/core/modedb.c
+++ b/drivers/video/fbdev/core/modedb.c
@@ -661,7 +661,7 @@ int fb_find_mode(struct fb_var_screeninfo *var,
 				namelen = i;
 				if (!refresh_specified && !bpp_specified &&
 				    !yres_specified) {
-					refresh = simple_strtol(&name[i+1], NULL,
+					refresh = kstrtol(&name[i+1], NULL,
 								10);
 					refresh_specified = 1;
 					if (cvt || rb)
@@ -672,7 +672,7 @@ int fb_find_mode(struct fb_var_screeninfo *var,
 			case '-':
 				namelen = i;
 				if (!bpp_specified && !yres_specified) {
-					bpp = simple_strtol(&name[i+1], NULL,
+					bpp = kstrtol(&name[i+1], NULL,
 							    10);
 					bpp_specified = 1;
 					if (cvt || rb)
@@ -682,7 +682,7 @@ int fb_find_mode(struct fb_var_screeninfo *var,
 				break;
 			case 'x':
 				if (!yres_specified) {
-					yres = simple_strtol(&name[i+1], NULL,
+					yres = kstrtol(&name[i+1], NULL,
 							     10);
 					yres_specified = 1;
 				} else
@@ -719,7 +719,7 @@ int fb_find_mode(struct fb_var_screeninfo *var,
 			}
 		}
 		if (i < 0 && yres_specified) {
-			xres = simple_strtol(name, NULL, 10);
+			xres = kstrtol(name, NULL, 10);
 			res_specified = 1;
 		}
 done:
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] fbdev/core: Replace deprecated simple_strtol with kstrtol
  2024-02-01  7:02 [PATCH] fbdev/core: Replace deprecated simple_strtol with kstrtol Cong Liu
@ 2024-02-01 10:03 ` Jani Nikula
  0 siblings, 0 replies; 2+ messages in thread
From: Jani Nikula @ 2024-02-01 10:03 UTC (permalink / raw)
  To: Cong Liu, Daniel Vetter, Helge Deller
  Cc: linux-fbdev, Cong Liu, linux-kernel, dri-devel

On Thu, 01 Feb 2024, Cong Liu <liucong2@kylinos.cn> wrote:
> This patch replaces the use of the deprecated simple_strtol [1] function
> in the modedb.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 <liucong2@kylinos.cn>

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/core/modedb.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/video/fbdev/core/modedb.c b/drivers/video/fbdev/core/modedb.c
> index 7196b055f2bd..eebbbc7e2aa3 100644
> --- a/drivers/video/fbdev/core/modedb.c
> +++ b/drivers/video/fbdev/core/modedb.c
> @@ -661,7 +661,7 @@ int fb_find_mode(struct fb_var_screeninfo *var,
>  				namelen = i;
>  				if (!refresh_specified && !bpp_specified &&
>  				    !yres_specified) {
> -					refresh = simple_strtol(&name[i+1], NULL,
> +					refresh = kstrtol(&name[i+1], NULL,
>  								10);
>  					refresh_specified = 1;
>  					if (cvt || rb)
> @@ -672,7 +672,7 @@ int fb_find_mode(struct fb_var_screeninfo *var,
>  			case '-':
>  				namelen = i;
>  				if (!bpp_specified && !yres_specified) {
> -					bpp = simple_strtol(&name[i+1], NULL,
> +					bpp = kstrtol(&name[i+1], NULL,
>  							    10);
>  					bpp_specified = 1;
>  					if (cvt || rb)
> @@ -682,7 +682,7 @@ int fb_find_mode(struct fb_var_screeninfo *var,
>  				break;
>  			case 'x':
>  				if (!yres_specified) {
> -					yres = simple_strtol(&name[i+1], NULL,
> +					yres = kstrtol(&name[i+1], NULL,
>  							     10);
>  					yres_specified = 1;
>  				} else
> @@ -719,7 +719,7 @@ int fb_find_mode(struct fb_var_screeninfo *var,
>  			}
>  		}
>  		if (i < 0 && yres_specified) {
> -			xres = simple_strtol(name, NULL, 10);
> +			xres = kstrtol(name, NULL, 10);
>  			res_specified = 1;
>  		}
>  done:

-- 
Jani Nikula, Intel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-02-01 10:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-01  7:02 [PATCH] fbdev/core: Replace deprecated simple_strtol with kstrtol Cong Liu
2024-02-01 10:03 ` Jani Nikula

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).