Skip to contentSkip to conversation

nfsd: Fix kernel test robot warning

PATCH In review Souptick Joarder 2 participants 2 messages Nov 28, 2020

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

PATCH 1/1 nfsd: Fix kernel test robot warning

Kernel test robot throws below warning -

Quoted 3 lines
Quoted 3 lines

fs/nfsd/nfs3xdr.c:299:6: warning: variable 'err' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]

           if (!v4 || !inode->i_sb->s_export_op->fetch_iversion)
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/nfsd/nfs3xdr.c:304:6: note: uninitialized use occurs here
           if (err) {
               ^~~
   fs/nfsd/nfs3xdr.c:299:2: note: remove the 'if' if its condition is
always true
           if (!v4 || !inode->i_sb->s_export_op->fetch_iversion)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/nfsd/nfs3xdr.c:293:12: note: initialize the variable 'err' to
silence this warning
           __be32 err;
                     ^
                      = 0

1 warning generated.

Initialize err = 0 to silence this warning.

---
 fs/nfsd/nfs3xdr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/nfs3xdr.c +1 -1
index abb1608..47aeaee 100644
@@ -290,7 +290,7 @@ void fill_post_wcc(struct svc_fh *fhp)
 {
 	bool v4 = (fhp->fh_maxsize == NFS4_FHSIZE);
 	struct inode *inode = d_inode(fhp->fh_dentry);
-	__be32 err;
+	__be32 err = 0;
 
 	if (fhp->fh_post_saved)
 		printk("nfsd: inode locked twice during operation.\n");
Signature · 1 line
1.9.1
#1 lore raw

Hello Souptick-

This looks like the same error that Coverity caught earlier this week. AFAIK Bruce intends to address this issue with a replacement patch:

https://lore.kernel.org/linux-nfs/[email protected]/

Quoted 47 lines · Souptick Joarder

Kernel test robot throws below warning -

Quoted 3 lines
Quoted 3 lines

fs/nfsd/nfs3xdr.c:299:6: warning: variable 'err' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]

          if (!v4 || !inode->i_sb->s_export_op->fetch_iversion)
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  fs/nfsd/nfs3xdr.c:304:6: note: uninitialized use occurs here
          if (err) {
              ^~~
  fs/nfsd/nfs3xdr.c:299:2: note: remove the 'if' if its condition is
always true
          if (!v4 || !inode->i_sb->s_export_op->fetch_iversion)
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  fs/nfsd/nfs3xdr.c:293:12: note: initialize the variable 'err' to
silence this warning
          __be32 err;
                    ^
                     = 0

1 warning generated.

Initialize err = 0 to silence this warning.

---
fs/nfsd/nfs3xdr.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/nfs3xdr.c +1 -1
index abb1608..47aeaee 100644
@@ -290,7 +290,7 @@ void fill_post_wcc(struct svc_fh *fhp)
 {
 	bool v4 = (fhp->fh_maxsize == NFS4_FHSIZE);
 	struct inode *inode = d_inode(fhp->fh_dentry);
-	__be32 err;
+	__be32 err = 0;
 
 	if (fhp->fh_post_saved)
 		printk("nfsd: inode locked twice during operation.\n");
Signature · 1 line
1.9.1

--
Chuck Lever