Message ID | 20240201070226.3292315-1-liucong2@kylinos.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-47724-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:106:209c:c626 with SMTP id mn5csp263911dyc; Wed, 31 Jan 2024 23:13:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IGF3Fl4xYz8UymCHnzzXdpyrcqtssbhHOT4o+SHnFNuOrBHre5QkKEcUwPWW4Be6is32MW6 X-Received: by 2002:a05:620a:c04:b0:783:e054:a25e with SMTP id l4-20020a05620a0c0400b00783e054a25emr1728189qki.54.1706771613649; Wed, 31 Jan 2024 23:13:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706771613; cv=pass; d=google.com; s=arc-20160816; b=X3nkPdGMvMnxliwvHVlFJ8Oed76DuOkdHTHYwxDFM2HnhuAWzvHkWkNaJQFZVtelPX +J4c3JeH/nL720Iqquw4XO0OxbqL5c3PqSY4Gg/C2SxWABupaU37jgNPdt5KWlNnogBx 0boXAtLwNaTToyeFxI4+k3TzQhI8Us2X9EQQ1Sv4w4AWAzyPdlYpkhuEMLygIaADCu/M vBV1ra2iNCMPmMQiO61r4T8igeGG4TPMl5VlXYLJhkLHyxj+TAk7olFWT8NC2dh2lG6B SLqIY5aU/E+augPnQI6ksJ/d4VC61jJ1smaeplPa0m+2/TgFb9KIe7NmfOgnmz2VnH0T Hk8w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=BEfIGlniNPDSYajE32gglWn+/Rt/tEhrMLyEyCb09ok=; fh=mSkrVZobl4o2Psrpyyk8aORojxCpgLjrl+tleVR0BhM=; b=e3QsD0Sc0J/XlBUL8HAl9EZuTZJ7+PuppW5iNo/1aWPfXpOKzs30pnfVJ/LTsWwvQg MWDqNG/VyEqgYRIcCAkO2B52TfIZJzH3F3GYseMICr0xm30ooXSU+B8KSO3fYe9PYBBG DzDujiZeObTXyi+uTX3mmXvf78KJrLIAEqNXg9/HYNKwpSnHcG/aUPCZRiFsqWwegMJo RvLWO6t9GCgIWTx12uE0hVrce3MFX7NOCmBEH97wytEMrRA5o2mGM+PEOdkPOtSjdKwT ECAac3c1N1T4NoExTabv8+6CyXZWfUTQEhzfbHkTPgoFHwycI/KIWmbGLuyUzWj8+hSf vIMw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=kylinos.cn); spf=pass (google.com: domain of linux-kernel+bounces-47724-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47724-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCWfQaTq0TEnPX4C4WbswPV5fglZz8CXaHAPyCpQKj1Mb5I2p6ZB92Z1habBBP9pephz3Tixy6effR+OJp+M2uQsyYG6GA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id h26-20020a05620a21da00b00783fc517e95si8550883qka.413.2024.01.31.23.13.33 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 23:13:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47724-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=kylinos.cn); spf=pass (google.com: domain of linux-kernel+bounces-47724-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47724-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 59C261C23C78 for <ouuuleilei@gmail.com>; Thu, 1 Feb 2024 07:13:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E233B158D78; Thu, 1 Feb 2024 07:13:10 +0000 (UTC) Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1DB3157E9E for <linux-kernel@vger.kernel.org>; Thu, 1 Feb 2024 07:13:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706771589; cv=none; b=MPD7DNpyqmb1vT5rWD9k4iAXI0R/qzfpFHZoogIfkeJDHlkrbHMY49gQwjbl9GFuc1Q7z02pnovd5ACakftafr/EibwT5u1CQaXUoDr3EdB3nCVh9PQj035i7O6c61y5deVvoSzcwE3IsVBrb9Lw/81CDVvhoOdBRwpzm5LFxIE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706771589; c=relaxed/simple; bh=RpMnmw/an2pFxmoLlqNIiJawqVl2hGBpf8rsHawUFx8=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=iTbVGY6DSpiyVHB+rEcErg3wipFknyC543w8hfIyW4ZwWaCsEKC1AlD+eizTPJiG+n++pOunqiFlFZjd8YDXMEWH4TnGm1PKeuHSw9ewhRZgBkNtnoC55T+q0LuGh7yi1r8Jk5PQ4EKhMbaX3L9R5PVmxZpefzJkAPWgygd17Gg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 764c45ccbd574fcc909a3d5b5243e43a-20240201 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.35,REQID:91f91266-b94d-412b-b9d1-95986282e5bc,IP:15, URL:0,TC:0,Content:0,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:0 X-CID-INFO: VERSION:1.1.35,REQID:91f91266-b94d-412b-b9d1-95986282e5bc,IP:15,UR L:0,TC:0,Content:0,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:0 X-CID-META: VersionHash:5d391d7,CLOUDID:43717f83-8d4f-477b-89d2-1e3bdbef96d1,B ulkID:240201150228KA92BHID,BulkQuantity:0,Recheck:0,SF:19|44|66|38|24|17|1 02,TC:nil,Content:0,EDM:-3,IP:-2,URL:1,File:nil,Bulk:nil,QS:nil,BEC:nil,CO L:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_FAS,TF_CID_SPAM_FSD,TF_CID_SPAM_FSI, TF_CID_SPAM_ULS X-UUID: 764c45ccbd574fcc909a3d5b5243e43a-20240201 X-User: liucong2@kylinos.cn Received: from localhost.localdomain [(116.128.244.171)] by mailgw (envelope-from <liucong2@kylinos.cn>) (Generic MTA) with ESMTP id 1569227187; Thu, 01 Feb 2024 15:02:27 +0800 From: Cong Liu <liucong2@kylinos.cn> To: 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>, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/modes: Replace deprecated simple_strtol with kstrtol Date: Thu, 1 Feb 2024 15:02:25 +0800 Message-Id: <20240201070226.3292315-1-liucong2@kylinos.cn> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789679751393627205 X-GMAIL-MSGID: 1789679751393627205 |
Series |
drm/modes: Replace deprecated simple_strtol with kstrtol
|
|
Commit Message
Cong Liu
Feb. 1, 2024, 7:02 a.m. UTC
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>
---
drivers/gpu/drm/drm_modes.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
Comments
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)
Dear Jani, I want to apologize for the incorrect patch I submitted. You are right that the recommended replacements are not suitable drop-in replacements and I clearly did not test the changes thoroughly. The kstrtol function requires null-terminated strings, so it is not appropriate for the conversion needed here. Given the issues, it is best to maintain the original implementation for now. Best Regard. liucong On 2024/2/1 18:03, Jani Nikula wrote: > 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) >
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)