public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
* [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

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