Skip to contentSkip to conversation

ceph: fix uninitialized return code

PATCH In review Arnd Bergmann 3 participants 3 messages Jul 8, 2019 Ceph client

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: fix uninitialized return code

clang points out a -Wsometimed-uninitized bug in the modified ceph_real_mount() function:

fs/ceph/super.c:850:6: error: variable 'err' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]

        if (!fsc->sb->s_root) {
            ^~~~~~~~~~~~~~~~
fs/ceph/super.c:885:9: note: uninitialized use occurs here
        return err;
               ^~~
fs/ceph/super.c:850:2: note: remove the 'if' if its condition is always true
        if (!fsc->sb->s_root) {
        ^~~~~~~~~~~~~~~~~~~~~~
fs/ceph/super.c:843:9: note: initialize the variable 'err' to silence this warning
        int err;
               ^
                = 0

Set it to zero if the condition is false.

Fixes 108f95bfaa56 ("vfs: Convert ceph to use the new mount API")
---
 fs/ceph/super.c | 2 ++
 1 file changed, 2 insertions(+)
fs/ceph/super.c +2 -0
index 0d23903ddfa5..d663aa1286f6 100644
@@ -876,6 +876,8 @@ static int ceph_real_mount(struct fs_context *fc, struct ceph_fs_client *fsc)
 			goto out;
 		}
 		fsc->sb->s_root = root;
+	} else {
+		err = 0;
 	}
 
 	fc->root = dget(fsc->sb->s_root);
Signature · 1 line
2.20.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · Arnd Bergmann

clang points out a -Wsometimed-uninitized bug in the modified ceph_real_mount() function:

fs/ceph/super.c:850:6: error: variable 'err' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]

        if (!fsc->sb->s_root) {
            ^~~~~~~~~~~~~~~~
fs/ceph/super.c:885:9: note: uninitialized use occurs here
        return err;
               ^~~
fs/ceph/super.c:850:2: note: remove the 'if' if its condition is always true
        if (!fsc->sb->s_root) {
        ^~~~~~~~~~~~~~~~~~~~~~
fs/ceph/super.c:843:9: note: initialize the variable 'err' to silence this warning
        int err;
               ^
                = 0
Quoted 4 lines

Set it to zero if the condition is false.

Fixes 108f95bfaa56 ("vfs: Convert ceph to use the new mount API")

Thanks for the patch!

Reviewed-by on v1 1/1
#2 lore raw
In reply to Arnd Bergmann
Quoted 30 lines · Arnd Bergmann

clang points out a -Wsometimed-uninitized bug in the modified ceph_real_mount() function:

fs/ceph/super.c:850:6: error: variable 'err' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]

        if (!fsc->sb->s_root) {
            ^~~~~~~~~~~~~~~~
fs/ceph/super.c:885:9: note: uninitialized use occurs here
        return err;
               ^~~
fs/ceph/super.c:850:2: note: remove the 'if' if its condition is always true
        if (!fsc->sb->s_root) {
        ^~~~~~~~~~~~~~~~~~~~~~
fs/ceph/super.c:843:9: note: initialize the variable 'err' to silence this warning
        int err;
               ^
                = 0

Set it to zero if the condition is false.

Fixes 108f95bfaa56 ("vfs: Convert ceph to use the new mount API")
---
 fs/ceph/super.c | 2 ++
 1 file changed, 2 insertions(+)
fs/ceph/super.c +0 -0
index 0d23903ddfa5..d663aa1286f6 100644

fs/ceph/super.c static int ceph_real_mount(struct fs_context *fc, struct ceph_fs_client *fsc) · line 883

Quoted 8 lines
fs/ceph/super.c +2 -0
@@ -876,6 +876,8 @@ static int ceph_real_mount(struct fs_context *fc, struct ceph_fs_client *fsc)
 			goto out;
 		}
 		fsc->sb->s_root = root;
+	} else {
+		err = 0;
 	}
 
 	fc->root = dget(fsc->sb->s_root);

I see 108f95bfaa56 linux-next, but this hasn't been merged into the ceph kclient tree yet. It'd be ideal if Al just squashed this in before sending the PR to Linus.

In any case, patch looks fine: