ceph: remove unnecessary IS_ERR() check in ceph_fname_to_usr()
authorLuis Henriques <lhenriques@suse.de>
Fri, 29 Sep 2023 09:12:06 +0000 (10:12 +0100)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 9 Oct 2023 11:35:24 +0000 (13:35 +0200)
Before returning, function ceph_fname_to_usr() does a final IS_ERR() check
in 'dir':

if ((dir != fname->dir) && !IS_ERR(dir)) {...}

This check is unnecessary because, if the 'dir' variable has changed to
something other than 'fname->dir' (it's initial value), that error check has
been performed already and, if there was indeed an error, it would have
been returned immediately.

Besides, this useless IS_ERR() is also confusing static analysis tools.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202309282202.xZxGdvS3-lkp@intel.com/
Signed-off-by: Luis Henriques <lhenriques@suse.de>
Reviewed-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/crypto.c

index e1f31b8..5b5112c 100644 (file)
@@ -460,7 +460,7 @@ int ceph_fname_to_usr(const struct ceph_fname *fname, struct fscrypt_str *tname,
 out:
        fscrypt_fname_free_buffer(&_tname);
 out_inode:
-       if ((dir != fname->dir) && !IS_ERR(dir)) {
+       if (dir != fname->dir) {
                if ((dir->i_state & I_NEW))
                        discard_new_inode(dir);
                else