ceph: initialize pathlen variable in reconnect_caps_cb
authorXiubo Li <xiubli@redhat.com>
Tue, 30 Nov 2021 11:20:34 +0000 (19:20 +0800)
committerIlya Dryomov <idryomov@gmail.com>
Wed, 1 Dec 2021 16:08:26 +0000 (17:08 +0100)
The smatch static checker warned about an uninitialized symbol usage in
this function, in the case where ceph_mdsc_build_path returns an error.

It turns out that that case is harmless, but it just looks sketchy.
Initialize the variable at declaration time, and remove the unneeded
setting of it later.

Fixes: a33f6432b3a6 ("ceph: encode inodes' parent/d_name in cap reconnect message")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/mds_client.c

index 250aad330a1062a5cbfef584f8c60819ffb5a929..c30eefc0ac19346e086128e3872a8d1848ea1dc2 100644 (file)
@@ -3683,7 +3683,7 @@ static int reconnect_caps_cb(struct inode *inode, struct ceph_cap *cap,
        struct ceph_pagelist *pagelist = recon_state->pagelist;
        struct dentry *dentry;
        char *path;
-       int pathlen, err;
+       int pathlen = 0, err;
        u64 pathbase;
        u64 snap_follows;
 
@@ -3703,7 +3703,6 @@ static int reconnect_caps_cb(struct inode *inode, struct ceph_cap *cap,
                }
        } else {
                path = NULL;
-               pathlen = 0;
                pathbase = 0;
        }