mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ceph: remove unnecessary IS_ERR() check in ceph_fname_to_usr()
@ 2023-09-29  9:12 Luis Henriques
  2023-10-02 11:02 ` Ilya Dryomov
  0 siblings, 1 reply; 2+ messages in thread
From: Luis Henriques @ 2023-09-29  9:12 UTC (permalink / raw)
  To: Xiubo Li, Ilya Dryomov, Jeff Layton
  Cc: ceph-devel, linux-kernel, Luis Henriques, kernel test robot,
	Dan Carpenter

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>
---
 fs/ceph/crypto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ceph/crypto.c b/fs/ceph/crypto.c
index e4d5cd56a80b..e19019209cf0 100644
--- a/fs/ceph/crypto.c
+++ b/fs/ceph/crypto.c
@@ -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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ceph: remove unnecessary IS_ERR() check in ceph_fname_to_usr()
  2023-09-29  9:12 [PATCH] ceph: remove unnecessary IS_ERR() check in ceph_fname_to_usr() Luis Henriques
@ 2023-10-02 11:02 ` Ilya Dryomov
  0 siblings, 0 replies; 2+ messages in thread
From: Ilya Dryomov @ 2023-10-02 11:02 UTC (permalink / raw)
  To: Luis Henriques
  Cc: Xiubo Li, Jeff Layton, ceph-devel, linux-kernel,
	kernel test robot, Dan Carpenter

On Fri, Sep 29, 2023 at 11:12 AM Luis Henriques <lhenriques@suse.de> wrote:
>
> 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>
> ---
>  fs/ceph/crypto.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ceph/crypto.c b/fs/ceph/crypto.c
> index e4d5cd56a80b..e19019209cf0 100644
> --- a/fs/ceph/crypto.c
> +++ b/fs/ceph/crypto.c
> @@ -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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-10-02 11:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-29  9:12 [PATCH] ceph: remove unnecessary IS_ERR() check in ceph_fname_to_usr() Luis Henriques
2023-10-02 11:02 ` Ilya Dryomov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®