* [PATCH] NFSD: Remove redundant assignment to variable host_err
@ 2022-10-10 20:24 Colin Ian King
2022-10-10 23:15 ` Jeff Layton
2022-10-11 14:06 ` Chuck Lever III
0 siblings, 2 replies; 3+ messages in thread
From: Colin Ian King @ 2022-10-10 20:24 UTC (permalink / raw)
To: Chuck Lever, Jeff Layton, linux-nfs; +Cc: kernel-janitors, linux-kernel
Variable host_err is assigned a value that is never read, it is being
re-assigned a value in every different execution path in the following
switch statement. The assignment is redundant and can be removed.
Cleans up clang-scan warning:
warning: Value stored to 'host_err' is never read [deadcode.DeadStores]
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
fs/nfsd/vfs.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index f650afedd67f..5093ae788f53 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -1304,7 +1304,6 @@ nfsd_create_locked(struct svc_rqst *rqstp, struct svc_fh *fhp,
iap->ia_mode &= ~current_umask();
err = 0;
- host_err = 0;
switch (type) {
case S_IFREG:
host_err = vfs_create(&init_user_ns, dirp, dchild, iap->ia_mode, true);
--
2.37.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] NFSD: Remove redundant assignment to variable host_err
2022-10-10 20:24 [PATCH] NFSD: Remove redundant assignment to variable host_err Colin Ian King
@ 2022-10-10 23:15 ` Jeff Layton
2022-10-11 14:06 ` Chuck Lever III
1 sibling, 0 replies; 3+ messages in thread
From: Jeff Layton @ 2022-10-10 23:15 UTC (permalink / raw)
To: Colin Ian King, Chuck Lever, linux-nfs; +Cc: kernel-janitors, linux-kernel
On Mon, 2022-10-10 at 21:24 +0100, Colin Ian King wrote:
> Variable host_err is assigned a value that is never read, it is being
> re-assigned a value in every different execution path in the following
> switch statement. The assignment is redundant and can be removed.
>
> Cleans up clang-scan warning:
> warning: Value stored to 'host_err' is never read [deadcode.DeadStores]
>
The warning is a bit odd since it _is_ read at the bottom of the
function:
err = nfserrno(host_err);
...but, all of the switch cases end up setting host_err, so the
initialization isn't needed.
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
> fs/nfsd/vfs.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
> index f650afedd67f..5093ae788f53 100644
> --- a/fs/nfsd/vfs.c
> +++ b/fs/nfsd/vfs.c
> @@ -1304,7 +1304,6 @@ nfsd_create_locked(struct svc_rqst *rqstp, struct svc_fh *fhp,
> iap->ia_mode &= ~current_umask();
>
> err = 0;
> - host_err = 0;
> switch (type) {
> case S_IFREG:
> host_err = vfs_create(&init_user_ns, dirp, dchild, iap->ia_mode, true);
Reviewed-by: Jeff Layton <jlayton@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] NFSD: Remove redundant assignment to variable host_err
2022-10-10 20:24 [PATCH] NFSD: Remove redundant assignment to variable host_err Colin Ian King
2022-10-10 23:15 ` Jeff Layton
@ 2022-10-11 14:06 ` Chuck Lever III
1 sibling, 0 replies; 3+ messages in thread
From: Chuck Lever III @ 2022-10-11 14:06 UTC (permalink / raw)
To: Colin Ian King
Cc: Jeff Layton, Linux NFS Mailing List, kernel-janitors, linux-kernel
> On Oct 10, 2022, at 4:24 PM, Colin Ian King <colin.i.king@gmail.com> wrote:
>
> Variable host_err is assigned a value that is never read, it is being
> re-assigned a value in every different execution path in the following
> switch statement. The assignment is redundant and can be removed.
>
> Cleans up clang-scan warning:
> warning: Value stored to 'host_err' is never read [deadcode.DeadStores]
>
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Applying this for nfsd's for-next (not yet public). Thanks!
> ---
> fs/nfsd/vfs.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
> index f650afedd67f..5093ae788f53 100644
> --- a/fs/nfsd/vfs.c
> +++ b/fs/nfsd/vfs.c
> @@ -1304,7 +1304,6 @@ nfsd_create_locked(struct svc_rqst *rqstp, struct svc_fh *fhp,
> iap->ia_mode &= ~current_umask();
>
> err = 0;
> - host_err = 0;
> switch (type) {
> case S_IFREG:
> host_err = vfs_create(&init_user_ns, dirp, dchild, iap->ia_mode, true);
> --
> 2.37.3
>
--
Chuck Lever
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-11 14:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-10 20:24 [PATCH] NFSD: Remove redundant assignment to variable host_err Colin Ian King
2022-10-10 23:15 ` Jeff Layton
2022-10-11 14:06 ` Chuck Lever III
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).