From nobody Fri Apr 10 21:56:15 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1228CC00140 for ; Thu, 18 Aug 2022 21:12:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344347AbiHRVML (ORCPT ); Thu, 18 Aug 2022 17:12:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346657AbiHRVKN (ORCPT ); Thu, 18 Aug 2022 17:10:13 -0400 Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF9D1D86FF for ; Thu, 18 Aug 2022 14:04:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=sang-engineering.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=k1; bh=jRyrpCZtAgM720E9sAhYYGK7zHt 9aYLQHRPHFke59pA=; b=S+tvBFl6hqxkX0tIH6Lbz0IhjCO+JbrNgEaPoNIx0L+ p0hTb9K1xZ1DO2HDe2Xhg1LwYLQ8cNGm1KInvzIhT4FvDaRo/yBKy2lKMtNVN+6T QHy6Z5+4PeLVs+1hjzVFldPaUWGCyB8HlpakpMQV/xOnWzLRL1rEuBiUomzZNF3c = Received: (qmail 3962418 invoked from network); 18 Aug 2022 23:01:48 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 18 Aug 2022 23:01:48 +0200 X-UD-Smtp-Session: l3s3148p1@xMgySormSaQucref From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: Wolfram Sang , Trond Myklebust , Anna Schumaker , linux-nfs@vger.kernel.org Subject: [PATCH] NFS: move from strlcpy with unused retval to strscpy Date: Thu, 18 Aug 2022 23:01:47 +0200 Message-Id: <20220818210148.7987-1-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Follow the advice of the below link and prefer 'strscpy' in this subsystem. Conversion is 1:1 because the return value is not used. Generated by a coccinelle script. Link: https://lore.kernel.org/r/CAHk-=3DwgfRnXz0W3D37d01q3JFkr_i_uTL=3DV6A6= G1oUZcprmknw@mail.gmail.com/ Signed-off-by: Wolfram Sang --- fs/nfs/nfs4client.c | 2 +- fs/nfs/nfsroot.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c index 3c5678aec006..7a5162afa5c0 100644 --- a/fs/nfs/nfs4client.c +++ b/fs/nfs/nfs4client.c @@ -254,7 +254,7 @@ struct nfs_client *nfs4_alloc_client(const struct nfs_c= lient_initdata *cl_init) goto error; ip_addr =3D (const char *)buf; } - strlcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr)); + strscpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr)); =20 err =3D nfs_idmap_new(clp); if (err < 0) { diff --git a/fs/nfs/nfsroot.c b/fs/nfs/nfsroot.c index fa148308822c..620329b7e6ae 100644 --- a/fs/nfs/nfsroot.c +++ b/fs/nfs/nfsroot.c @@ -139,7 +139,7 @@ static int __init nfs_root_setup(char *line) ROOT_DEV =3D Root_NFS; =20 if (line[0] =3D=3D '/' || line[0] =3D=3D ',' || (line[0] >=3D '0' && line= [0] <=3D '9')) { - strlcpy(nfs_root_parms, line, sizeof(nfs_root_parms)); + strscpy(nfs_root_parms, line, sizeof(nfs_root_parms)); } else { size_t n =3D strlen(line) + sizeof(NFS_ROOT) - 1; if (n >=3D sizeof(nfs_root_parms)) --=20 2.35.1