linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests: mm: fix unused and uninitialized variable warning
@ 2024-04-16 16:26 Muhammad Usama Anjum
  2024-04-22 13:59 ` Zi Yan
  0 siblings, 1 reply; 2+ messages in thread
From: Muhammad Usama Anjum @ 2024-04-16 16:26 UTC (permalink / raw)
  To: Andrew Morton, Shuah Khan, Nathan Chancellor, Nick Desaulniers,
	Bill Wendling, Justin Stitt, Zi Yan
  Cc: Muhammad Usama Anjum, kernel, linux-mm, linux-kselftest,
	linux-kernel, llvm

Fix the warnings by initializing and marking the variable as unused.
I've caught the warnings by using clang.

split_huge_page_test.c:303:6: warning: variable 'dummy' set but not used [-Wunused-but-set-variable]
  303 |         int dummy;
      |             ^
split_huge_page_test.c:343:3: warning: variable 'dummy' is uninitialized when used here [-Wuninitialized]
  343 |                 dummy += *(*addr + i);
      |                 ^~~~~
split_huge_page_test.c:303:11: note: initialize the variable 'dummy' to silence this warning
  303 |         int dummy;
      |                  ^
      |                   = 0
2 warnings generated.

Fixes: fc4d182316bd ("mm: huge_memory: enable debugfs to split huge pages to any order")
Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 tools/testing/selftests/mm/split_huge_page_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
index 6c988bd2f3356..d3c7f5fb3e7b7 100644
--- a/tools/testing/selftests/mm/split_huge_page_test.c
+++ b/tools/testing/selftests/mm/split_huge_page_test.c
@@ -300,7 +300,7 @@ int create_pagecache_thp_and_fd(const char *testfile, size_t fd_size, int *fd,
 		char **addr)
 {
 	size_t i;
-	int dummy;
+	int __attribute__((unused)) dummy = 0;
 
 	srand(time(NULL));
 
-- 
2.39.2



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-22 14:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-16 16:26 [PATCH] selftests: mm: fix unused and uninitialized variable warning Muhammad Usama Anjum
2024-04-22 13:59 ` Zi Yan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox