From: Jani Nikula <jani.nikula@linux.intel.com>
To: Cong Liu <liucong2@kylinos.cn>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>
Cc: Cong Liu <liucong2@kylinos.cn>,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/modes: Replace deprecated simple_strtol with kstrtol
Date: Thu, 01 Feb 2024 12:03:15 +0200 [thread overview]
Message-ID: <87frych57g.fsf@intel.com> (raw)
In-Reply-To: <20240201070226.3292315-1-liucong2@kylinos.cn>
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 drm_modes.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/gpu/drm/drm_modes.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
> index 893f52ee4926..fce0fb1df9b2 100644
> --- a/drivers/gpu/drm/drm_modes.c
> +++ b/drivers/gpu/drm/drm_modes.c
> @@ -1942,7 +1942,7 @@ static int drm_mode_parse_cmdline_bpp(const char *str, char **end_ptr,
> return -EINVAL;
>
> str++;
> - bpp = simple_strtol(str, end_ptr, 10);
> + bpp = kstrtol(str, end_ptr, 10);
> if (*end_ptr == str)
> return -EINVAL;
>
> @@ -1961,7 +1961,7 @@ static int drm_mode_parse_cmdline_refresh(const char *str, char **end_ptr,
> return -EINVAL;
>
> str++;
> - refresh = simple_strtol(str, end_ptr, 10);
> + refresh = kstrtol(str, end_ptr, 10);
> if (*end_ptr == str)
> return -EINVAL;
>
> @@ -2033,7 +2033,7 @@ static int drm_mode_parse_cmdline_res_mode(const char *str, unsigned int length,
> int remaining, i;
> char *end_ptr;
>
> - xres = simple_strtol(str, &end_ptr, 10);
> + xres = kstrtol(str, &end_ptr, 10);
> if (end_ptr == str)
> return -EINVAL;
>
> @@ -2042,7 +2042,7 @@ static int drm_mode_parse_cmdline_res_mode(const char *str, unsigned int length,
> end_ptr++;
>
> str = end_ptr;
> - yres = simple_strtol(str, &end_ptr, 10);
> + yres = kstrtol(str, &end_ptr, 10);
> if (end_ptr == str)
> return -EINVAL;
>
> @@ -2100,7 +2100,7 @@ static int drm_mode_parse_cmdline_int(const char *delim, unsigned int *int_ret)
> return -EINVAL;
>
> value = delim + 1;
> - *int_ret = simple_strtol(value, &endp, 10);
> + *int_ret = kstrtol(value, &endp, 10);
>
> /* Make sure we have parsed something */
> if (endp == value)
--
Jani Nikula, Intel
next prev parent reply other threads:[~2024-02-01 10:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-01 7:02 [PATCH] drm/modes: Replace deprecated simple_strtol with kstrtol Cong Liu
2024-02-01 10:03 ` Jani Nikula [this message]
2024-02-02 8:56 ` Cong Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87frych57g.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=airlied@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liucong2@kylinos.cn \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox