Re: [PATCH] selftests/vm: silence uninitialized variable warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 19, 2022 at 3:13 PM Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:
>
> This code just reads from memory without caring about the data itself.

The caller has put an attempt to at least validate the address read
from mmap() before
passing it to read_fault_pages() which looks correct. I think this
line is not needed.

> 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@xxxxxxxxxx>

Acked-by: Souptick Joarder (HPE) <jrdr.linux@xxxxxxxxx>

> ---
>  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
>
>




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux