Skip to contentSkip to conversation

ceph: remove unnecessary IS_ERR() check in ceph_fname_to_usr()

PATCH Applied Luis Henriques 2 participants 2 messages Sep 29, 2023 – Oct 2, 2023 Ceph client

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: remove unnecessary IS_ERR() check in ceph_fname_to_usr()

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.

---
 fs/ceph/crypto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ceph/crypto.c +1 -1
index e4d5cd56a80b..e19019209cf0 100644
@@ -462,7 +462,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
maintainer Applied
#1 lore raw
Quoted 26 lines · Luis Henriques

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.

---
 fs/ceph/crypto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ceph/crypto.c +0 -0
index e4d5cd56a80b..e19019209cf0 100644

fs/ceph/crypto.c int ceph_fname_to_usr(const struct ceph_fname *fname, struct fscrypt_str *tname, · line 468

Quoted 8 lines
fs/ceph/crypto.c +1 -1
@@ -462,7 +462,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

Applied.

Thanks,

Ilya