mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: "'cgel.zte@gmail.com'" <cgel.zte@gmail.com>,
	"konishi.ryusuke@gmail.com" <konishi.ryusuke@gmail.com>
Cc: "linux-nilfs@vger.kernel.org" <linux-nilfs@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Minghao Chi <chi.minghao@zte.com.cn>,
	Zeal Robot <zealci@zte.com.cn>
Subject: RE: [PATCH] nilfs2: delete unnecessary checks before brelse()
Date: Fri, 19 Aug 2022 21:31:45 +0000	[thread overview]
Message-ID: <0d78d24dd26441818dbaedffde611485@AcuMS.aculab.com> (raw)
In-Reply-To: <20220819081700.96279-1-chi.minghao@zte.com.cn>

From: cgel.zte@gmail.com
> Sent: 19 August 2022 09:17
> 
> The brelse() function tests whether its argument is NULL
> and then returns immediately.
> Thus remove the tests which are not needed around the shown calls.

The test is the caller makes sense if it is a 'hot' path
and bh is normally NULL.

	David

> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
> ---
>  fs/nilfs2/btree.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/nilfs2/btree.c b/fs/nilfs2/btree.c
> index f544c22fff78..b3b5a46488c2 100644
> --- a/fs/nilfs2/btree.c
> +++ b/fs/nilfs2/btree.c
> @@ -1668,8 +1668,7 @@ static int nilfs_btree_check_delete(struct nilfs_bmap *btree, __u64 key)
>  	maxkey = nilfs_btree_node_get_key(node, nchildren - 1);
>  	nextmaxkey = (nchildren > 1) ?
>  		nilfs_btree_node_get_key(node, nchildren - 2) : 0;
> -	if (bh != NULL)
> -		brelse(bh);
> +	brelse(bh);
> 
>  	return (maxkey == key) && (nextmaxkey < NILFS_BMAP_LARGE_LOW);
>  }
> @@ -1717,8 +1716,7 @@ static int nilfs_btree_gather_data(struct nilfs_bmap *btree,
>  		ptrs[i] = le64_to_cpu(dptrs[i]);
>  	}
> 
> -	if (bh != NULL)
> -		brelse(bh);
> +	brelse(bh);
> 
>  	return nitems;
>  }
> --
> 2.25.1

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


  parent reply	other threads:[~2022-08-19 21:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-19  8:17 cgel.zte
2022-08-19  8:42 ` Ryusuke Konishi
2022-08-19 21:31 ` David Laight [this message]
2022-08-19 23:50   ` Ryusuke Konishi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0d78d24dd26441818dbaedffde611485@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=cgel.zte@gmail.com \
    --cc=chi.minghao@zte.com.cn \
    --cc=konishi.ryusuke@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nilfs@vger.kernel.org \
    --cc=zealci@zte.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®