Skip to content

Commit

Permalink
tools/testing/selftests/vm/hugetlb-madvise.c: silence uninitialized v…
Browse files Browse the repository at this point in the history
…ariable warning

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: c4b6cb8 ("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>
  • Loading branch information
Dan Carpenter authored and akpm committed Jul 30, 2022
1 parent 6d97cf8 commit 3d5367a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tools/testing/selftests/vm/hugetlb-madvise.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3d5367a

Please sign in to comment.