Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp702451rdb; Fri, 2 Feb 2024 00:58:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IF6qs2KyiHNdoYF8GtQBnYPYNPnJYvhqoFfq2KzDQXujdSx5WM0Z3mnAC+oSEhXfs0YSrgM X-Received: by 2002:a05:622a:316:b0:42b:e19c:4091 with SMTP id q22-20020a05622a031600b0042be19c4091mr1640079qtw.40.1706864285988; Fri, 02 Feb 2024 00:58:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706864285; cv=pass; d=google.com; s=arc-20160816; b=1KWzU7askCts8VxGZfXul8LSjN/MUaWDY3tTgu256dYWmbbr9GzRfOnXls8RoEefnB qJyUABqxNzi4/5rnEZ287vFvsX4cwDRsmupRsDpSY/BtsF8DkcvXdr/ocYKL8IATV/4H 0Pjo5/oIBpIndQjEUOyvfLjRXspjYZ8KAxpsT10fc423jLCMCxp7a9UwPbe9tUQGdO94 vK1yR/XD+lSDjJWcFw5zMZEdzyNPV7O2+j7arwCtu6bq97pkwJkJaVkYmpZ2ulRJEyOP sqDEqy75bcIhJw/49ie969Gi2FeOi202QiJGLeYAU9/r8d7ofbJN3omLYbVFgrB2Gl+K xcCg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=6VSWdQR2oOo+K7nY8YKZK5hBFR2v6Qan3Oa+EnBtIDo=; fh=G42Safpz31GIv2HWOvHatSOXXhrLTboVH+KECVJi3Ro=; b=x2Ht1EwyIxW/e3k5z6oDAkBlDKQiJkryM/fNFoBx5sO2eqF6NLhUT0s2xWU0wb03NC I4g7k4SNW6Mu143AB/rp+rsSJb7o1LZHVlwEi8DJKDgotaAPgtjaLvXg1e6ugjOjYvre /Job79cymdHzwQllFMHoIM38ShCHCiFwYI83dbKz2LHRweNrsJ2/2X57fUy0aQkLHpbM 3/CFCgm63TKdrw83sJZNtCEUvYvpbVKVK4u/ai9dAOq3q+5oQWjSrdcW9XwuAqAHC47C VSKfh5xrtxvsDS8TXCx9PxoQJA15FqU94Zzftd2ZduFf2mM9cY3+3cgtYOym9WYPxAt8 kHTQ==; 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-49519-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49519-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCW4J16R0+gWyXrHIvngOvELq4E+OvChjN6Y5o1lEgQDwGl+v92M8z/DW7FRkrsUoRrC5UoYHxS44xgAHSiLHX6RIr9lFGMs+I5CkNsf2g== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id s20-20020ac85cd4000000b00429b91ea4e5si1497641qta.458.2024.02.02.00.58.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 00:58:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49519-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=kylinos.cn); spf=pass (google.com: domain of linux-kernel+bounces-49519-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49519-linux.lists.archive=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 AADD51C27686 for ; Fri, 2 Feb 2024 08:57:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1696363099; Fri, 2 Feb 2024 08:56:39 +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 718F45FEFA for ; Fri, 2 Feb 2024 08:56:33 +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=1706864198; cv=none; b=OZpqhwwAxo6hxk9gCJogkbPEA1BBnnP+25EsWdMPq6l9E9BiSaXHZpXiFpcbfgAbbMkq0yGudaRwHwq8hcvqLideIAXMdM33Yk9nJExX/MjpVfrgv2HkX1HPoiPI0qek2eQhyUC7Idv9pTYdhupzYwKh7luDqhS1RDDN3xkTC78= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706864198; c=relaxed/simple; bh=xe+JE2pdIoDLOLwdHNVYHPenxo3SxPEsnW0bL9LPUys=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=tZXJ1hQiTY+KAPaBZuQl18Gd3DnolK2cJiHE2ZTXNPPkt4m5wA4YNHFu8xi7RE7v9ICkoQaq1bIXwIHvH89ZQvUd15s6hvxCkwV6i3xtXeAzozeF251Q5Es0OJJNQbq10yDkpZChWi4RgZwtK2CWo4cPJDeuQxmVtD35TEOjpHY= 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: 638e4e337349431f968ddb1bd3276d02-20240202 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.35,REQID:af666be1-41cc-499d-a5fe-c88955d0c6b4,IP:15, URL:0,TC:0,Content:-5,EDM:0,RT:0,SF:-9,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:1 X-CID-INFO: VERSION:1.1.35,REQID:af666be1-41cc-499d-a5fe-c88955d0c6b4,IP:15,UR L:0,TC:0,Content:-5,EDM:0,RT:0,SF:-9,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:1 X-CID-META: VersionHash:5d391d7,CLOUDID:9a210c80-4f93-4875-95e7-8c66ea833d57,B ulkID:240201180336II1JTY5D,BulkQuantity:18,Recheck:0,SF:66|38|24|17|19|43| 74|64|102,TC:nil,Content:0,EDM:-3,IP:-2,URL:1,File:nil,Bulk:40,QS:nil,BEC: nil,COL: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_OBB,TF_CID_SPAM_ULS X-UUID: 638e4e337349431f968ddb1bd3276d02-20240202 X-User: liucong2@kylinos.cn Received: from [172.21.15.119] [(116.128.244.171)] by mailgw (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES128-GCM-SHA256 128/128) with ESMTP id 497483932; Fri, 02 Feb 2024 16:56:30 +0800 Message-ID: <24a001cb-5170-4a7d-b004-651e5da4d84e@kylinos.cn> Date: Fri, 2 Feb 2024 16:56:25 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] drm/modes: Replace deprecated simple_strtol with kstrtol Content-Language: en-US To: Jani Nikula , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org References: <20240201070226.3292315-1-liucong2@kylinos.cn> <87frych57g.fsf@intel.com> From: Cong Liu In-Reply-To: <87frych57g.fsf@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 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 > > 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) >