diff mbox series

fs:fc_log replace magic number 7 with ARRAY_SIZE()

Message ID 20241202081146.1031780-1-guoweikang.kernel@gmail.com (mailing list archive)
State New
Headers show
Series fs:fc_log replace magic number 7 with ARRAY_SIZE() | expand

Commit Message

Guo Weikang Dec. 2, 2024, 8:11 a.m. UTC
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>
---
 fs/fs_context.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Christian Brauner Dec. 2, 2024, 12:02 p.m. UTC | #1
On Mon, 02 Dec 2024 16:11:45 +0800, 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.
> 
> 

Applied to the vfs-6.14.misc branch of the vfs/vfs.git tree.
Patches in the vfs-6.14.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-6.14.misc

[1/1] fs:fc_log replace magic number 7 with ARRAY_SIZE()
      https://git.kernel.org/vfs/vfs/c/6814aad4d6ce
Jan Kara Dec. 2, 2024, 12:33 p.m. UTC | #2
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
>
diff mbox series

Patch

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);