NFS: move from strlcpy with unused retval to strscpy
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Thu, 18 Aug 2022 21:01:15 +0000 (23:01 +0200)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Mon, 3 Oct 2022 15:26:36 +0000 (11:26 -0400)
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-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
fs/nfs/nfs4client.c
fs/nfs/nfsroot.c

index 3c5678aec006fce1dc315e7624772f2399172c4a..7a5162afa5c0dc33336a36d51fc2a5f0ca32aebb 100644 (file)
@@ -254,7 +254,7 @@ struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *cl_init)
                        goto error;
                ip_addr = (const char *)buf;
        }
-       strlcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr));
+       strscpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr));
 
        err = nfs_idmap_new(clp);
        if (err < 0) {
index fa148308822cc8d4b02ee29772c0ba40843f1fe2..620329b7e6aeb18eac2a5512e20592ef344ad506 100644 (file)
@@ -139,7 +139,7 @@ static int __init nfs_root_setup(char *line)
        ROOT_DEV = Root_NFS;
 
        if (line[0] == '/' || line[0] == ',' || (line[0] >= '0' && line[0] <= '9')) {
-               strlcpy(nfs_root_parms, line, sizeof(nfs_root_parms));
+               strscpy(nfs_root_parms, line, sizeof(nfs_root_parms));
        } else {
                size_t n = strlen(line) + sizeof(NFS_ROOT) - 1;
                if (n >= sizeof(nfs_root_parms))