Skip to contentSkip to conversation

NFSD: Remove redundant assignment to variable host_err

PATCH In review Colin Ian King 3 participants 3 messages Oct 10, 2022 – Oct 11, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NFSD: Remove redundant assignment to variable host_err

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]

---
 fs/nfsd/vfs.c | 1 -
 1 file changed, 1 deletion(-)
fs/nfsd/vfs.c +0 -1
index f650afedd67f..5093ae788f53 100644
@@ -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);
Signature · 1 line
2.37.3
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Colin Ian King

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.

Quoted 10 lines
---
 fs/nfsd/vfs.c | 1 -
 1 file changed, 1 deletion(-)
fs/nfsd/vfs.c +0 -0
index f650afedd67f..5093ae788f53 100644

fs/nfsd/vfs.c nfsd_create_locked(struct svc_rqst *rqstp, struct svc_fh *fhp, · line 1309

Quoted 7 lines
fs/nfsd/vfs.c +0 -1
@@ -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 lore raw
In reply to Colin Ian King
Quoted 12 lines · Colin Ian King

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]

Applying this for nfsd's for-next (not yet public). Thanks!

Quoted 19 lines

---
fs/nfsd/vfs.c | 1 -

1 file changed, 1 deletion(-)
fs/nfsd/vfs.c +0 -1
index f650afedd67f..5093ae788f53 100644
@@ -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);
Signature · 1 line
2.37.3

--
Chuck Lever