The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Guo Weikang <guoweikang.kernel@gmail.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fs:fc_log replace magic number 7 with ARRAY_SIZE()
Date: Mon, 2 Dec 2024 13:33:27 +0100	[thread overview]
Message-ID: <20241202123327.3cpmzegjaoh3rgrd@quack3> (raw)
In-Reply-To: <20241202081146.1031780-1-guoweikang.kernel@gmail.com>

On Mon 02-12-24 16:11:45, Guo Weikang wrote:
> Replace the hardcoded value `7` in `put_fc_log()` with `ARRAY_SIZE`.
> This improves maintainability by ensuring the loop adapts to changes
> in the buffer size.
> 
> Signed-off-by: Guo Weikang <guoweikang.kernel@gmail.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/fs_context.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/fs_context.c b/fs/fs_context.c
> index 98589aae5208..582d33e81117 100644
> --- a/fs/fs_context.c
> +++ b/fs/fs_context.c
> @@ -493,7 +493,7 @@ static void put_fc_log(struct fs_context *fc)
>  	if (log) {
>  		if (refcount_dec_and_test(&log->usage)) {
>  			fc->log.log = NULL;
> -			for (i = 0; i <= 7; i++)
> +			for (i = 0; i < ARRAY_SIZE(log->buffer) ; i++)
>  				if (log->need_free & (1 << i))
>  					kfree(log->buffer[i]);
>  			kfree(log);
> -- 
> 2.25.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

      parent reply	other threads:[~2024-12-02 12:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-02  8:11 [PATCH] fs:fc_log replace magic number 7 with ARRAY_SIZE() Guo Weikang
2024-12-02 12:02 ` [PATCH] fs: fc_log " Christian Brauner
2024-12-02 12:33 ` Jan Kara [this message]

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=20241202123327.3cpmzegjaoh3rgrd@quack3 \
    --to=jack@suse.cz \
    --cc=brauner@kernel.org \
    --cc=guoweikang.kernel@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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