From 9de2818c18b2d0bb1cd85ac0b5ee3e4457ac6811 Mon Sep 17 00:00:00 2001 From: "chao.an" Date: Fri, 18 Mar 2022 23:47:00 +0800 Subject: [PATCH] fs/nfs: fix compile warning Signed-off-by: chao.an --- fs/nfs/nfs_vfsops.c | 6 +++--- fs/nfs/rpc_clnt.c | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/fs/nfs/nfs_vfsops.c b/fs/nfs/nfs_vfsops.c index 0277e57ab3..f3fcd464a6 100644 --- a/fs/nfs/nfs_vfsops.c +++ b/fs/nfs/nfs_vfsops.c @@ -903,7 +903,7 @@ static ssize_t nfs_read(FAR struct file *filep, FAR char *buffer, if (buflen > tmp) { buflen = tmp; - finfo("Read size truncated to %d\n", buflen); + finfo("Read size truncated to %zu\n", buflen); } /* Now loop until we fill the user buffer (or hit the end of the file) */ @@ -957,7 +957,7 @@ static ssize_t nfs_read(FAR struct file *filep, FAR char *buffer, /* Perform the read */ - finfo("Reading %d bytes\n", readsize); + finfo("Reading %zu bytes\n", readsize); nfs_statistics(NFSPROC_READ); ret = nfs_request(nmp, NFSPROC_READ, (FAR void *)&nmp->nm_msgbuffer.read, reqlen, @@ -2006,7 +2006,7 @@ static int nfs_bind(FAR struct inode *blkdriver, FAR const void *data, nmp->nm_rsize = nprmt.rsize; nmp->nm_readdirsize = nprmt.readdirsize; - strncpy(nmp->nm_path, argp->path, 90); + strlcpy(nmp->nm_path, argp->path, sizeof(nmp->nm_path)); memcpy(&nmp->nm_nam, &argp->addr, argp->addrlen); /* Create an instance of the rpc state structure */ diff --git a/fs/nfs/rpc_clnt.c b/fs/nfs/rpc_clnt.c index 41751e0444..569af8a64c 100644 --- a/fs/nfs/rpc_clnt.c +++ b/fs/nfs/rpc_clnt.c @@ -588,7 +588,8 @@ int rpcclnt_connect(FAR struct rpcclnt *rpc) /* Do RPC to mountd. */ - strncpy(request.mountd.mount.rpath, rpc->rc_path, 90); + strlcpy(request.mountd.mount.rpath, rpc->rc_path, + sizeof(request.mountd.mount.rpath)); request.mountd.mount.len = txdr_unsigned(sizeof(request.mountd.mount.rpath)); @@ -716,7 +717,8 @@ void rpcclnt_disconnect(FAR struct rpcclnt *rpc) /* Do RPC to umountd. */ - strncpy(request.mountd.umount.rpath, rpc->rc_path, 90); + strlcpy(request.mountd.umount.rpath, rpc->rc_path, + sizeof(request.mountd.umount.rpath)); request.mountd.umount.len = txdr_unsigned(sizeof(request.mountd.umount.rpath));