tools/testing/selftests/vm/hugetlb-madvise.c: silence uninitialized variable warning
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 19 Jul 2022 09:42:48 +0000 (12:42 +0300)
committerakpm <akpm@linux-foundation.org>
Sat, 30 Jul 2022 01:07:16 +0000 (18:07 -0700)
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.

Link: https://lkml.kernel.org/r/YtZ8mKJmktA2GaHB@kili
Fixes: c4b6cb884011 ("selftests/vm: add hugetlb madvise MADV_DONTNEED MADV_REMOVE test")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Souptick Joarder (HPE) <jrdr.linux@gmail.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
tools/testing/selftests/vm/hugetlb-madvise.c

index 6c6af40f57478f691b9e3f0cfd61c08672cc1634..3c9943131881eb0041457fcdb93f875902fb1286 100644 (file)
@@ -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)