From: Dan Carpenter <dan.carpenter@oracle.com>
To: Souptick Joarder <jrdr.linux@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Mike Kravetz <mike.kravetz@oracle.com>,
Shuah Khan <shuah@kernel.org>, Linux-MM <linux-mm@kvack.org>,
linux-kselftest <linux-kselftest@vger.kernel.org>,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] selftests/vm: silence uninitialized variable warning
Date: Thu, 21 Jul 2022 09:30:58 +0300 [thread overview]
Message-ID: <20220721063058.GJ2338@kadam> (raw)
In-Reply-To: <CAFqt6zY4+=LASCQRCEg_cjEeSw+gJtYMLJtJ1pWL6XPaPB0FOQ@mail.gmail.com>
On Thu, Jul 21, 2022 at 06:38:59AM +0530, Souptick Joarder wrote:
> On Tue, Jul 19, 2022 at 3:13 PM Dan Carpenter <dan.carpenter@oracle.com> 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.
What I mean is, the value of "tmp" was always nonsense but it doesn't
matter because we don't care. In other words, we're just reading but we
don't care about the actual data.
regards,
dan carpenter
>
> > 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>
>
> Acked-by: Souptick Joarder (HPE) <jrdr.linux@gmail.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
> >
> >
next prev parent reply other threads:[~2022-07-21 11:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2022-07-21 17:52 ` Mike Kravetz
2022-07-22 5:50 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220721063058.GJ2338@kadam \
--to=dan.carpenter@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=jrdr.linux@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mike.kravetz@oracle.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).