linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests/vm: silence uninitialized variable warning
@ 2022-07-19  9:42 Dan Carpenter
  2022-07-21  1:08 ` Souptick Joarder
  2022-07-21 17:52 ` Mike Kravetz
  0 siblings, 2 replies; 5+ messages in thread
From: Dan Carpenter @ 2022-07-19  9:42 UTC (permalink / raw)
  To: Andrew Morton, Mike Kravetz
  Cc: Shuah Khan, linux-mm, linux-kselftest, kernel-janitors

This code just reads from memory without caring about the data itself.
However static checkers complain that "tmp" is never properly
initialized.  Initialize it to zero and change the name to "dummy" to
show that we don't care about the value stored in it.

Fixes: c4b6cb884011 ("selftests/vm: add hugetlb madvise MADV_DONTNEED MADV_REMOVE test")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 tools/testing/selftests/vm/hugetlb-madvise.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/vm/hugetlb-madvise.c b/tools/testing/selftests/vm/hugetlb-madvise.c
index 6c6af40f5747..3c9943131881 100644
--- a/tools/testing/selftests/vm/hugetlb-madvise.c
+++ b/tools/testing/selftests/vm/hugetlb-madvise.c
@@ -89,10 +89,11 @@ void write_fault_pages(void *addr, unsigned long nr_pages)
 
 void read_fault_pages(void *addr, unsigned long nr_pages)
 {
-	unsigned long i, tmp;
+	unsigned long dummy = 0;
+	unsigned long i;
 
 	for (i = 0; i < nr_pages; i++)
-		tmp += *((unsigned long *)(addr + (i * huge_page_size)));
+		dummy += *((unsigned long *)(addr + (i * huge_page_size)));
 }
 
 int main(int argc, char **argv)
-- 
2.35.1



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

end of thread, other threads:[~2022-07-22  5:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-19  9:42 [PATCH] selftests/vm: silence uninitialized variable warning Dan Carpenter
2022-07-21  1:08 ` Souptick Joarder
2022-07-21  6:30   ` Dan Carpenter
2022-07-21 17:52 ` Mike Kravetz
2022-07-22  5:50   ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).