Re: [PATCH] fs:fc_log replace magic number 7 with ARRAY_SIZE()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

								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@xxxxxxxx>
SUSE Labs, CR




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux