* [PATCH] fs:fc_log replace magic number 7 with ARRAY_SIZE()
@ 2024-12-02 8:11 Guo Weikang
2024-12-02 12:02 ` [PATCH] fs: fc_log " Christian Brauner
2024-12-02 12:33 ` [PATCH] fs:fc_log " Jan Kara
0 siblings, 2 replies; 3+ messages in thread
From: Guo Weikang @ 2024-12-02 8:11 UTC (permalink / raw)
To: Alexander Viro, Christian Brauner, Jan Kara
Cc: Guo Weikang, linux-fsdevel, linux-kernel
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(-)
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] fs: fc_log replace magic number 7 with ARRAY_SIZE()
2024-12-02 8:11 [PATCH] fs:fc_log replace magic number 7 with ARRAY_SIZE() Guo Weikang
@ 2024-12-02 12:02 ` Christian Brauner
2024-12-02 12:33 ` [PATCH] fs:fc_log " Jan Kara
1 sibling, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2024-12-02 12:02 UTC (permalink / raw)
To: Guo Weikang
Cc: Christian Brauner, linux-fsdevel, linux-kernel, Alexander Viro,
Jan Kara
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fs:fc_log replace magic number 7 with ARRAY_SIZE()
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
1 sibling, 0 replies; 3+ messages in thread
From: Jan Kara @ 2024-12-02 12:33 UTC (permalink / raw)
To: Guo Weikang
Cc: Alexander Viro, Christian Brauner, Jan Kara, linux-fsdevel,
linux-kernel
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-12-02 12:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH] fs:fc_log " Jan Kara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox