linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Anshuman Khandual <anshuman.khandual@arm.com>, linux-mm@kvack.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Shuah Khan <shuah@kernel.org>,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] selftests/mm: Fix compiler -Wmaybe-uninitialized warning
Date: Wed, 9 Apr 2025 11:57:51 +0200	[thread overview]
Message-ID: <9da46633-e9c1-42a7-b52b-16cf89836abc@redhat.com> (raw)
In-Reply-To: <20250409095006.1422620-1-anshuman.khandual@arm.com>

On 09.04.25 11:50, Anshuman Khandual wrote:
> Following build warning comes up for cow test as 'transferred' variable has
> not been initialized. Fix the warning via zero init for the variable.
> 
>    CC       cow
> cow.c: In function ‘do_test_vmsplice_in_parent’:
> cow.c:365:61: warning: ‘transferred’ may be used uninitialized [-Wmaybe-uninitialized]
>    365 |                 cur = read(fds[0], new + total, transferred - total);
>        |                                                 ~~~~~~~~~~~~^~~~~~~
> cow.c:296:29: note: ‘transferred’ was declared here
>    296 |         ssize_t cur, total, transferred;
>        |                             ^~~~~~~~~~~
>    CC       compaction_test
>    CC       gup_longterm
> 
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Shuah Khan <shuah@kernel.org>
> Cc: linux-mm@kvack.org
> Cc: linux-kselftest@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
>   tools/testing/selftests/mm/cow.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/mm/cow.c b/tools/testing/selftests/mm/cow.c
> index f0cb14ea8608..b6cfe0a4b7df 100644
> --- a/tools/testing/selftests/mm/cow.c
> +++ b/tools/testing/selftests/mm/cow.c
> @@ -293,7 +293,7 @@ static void do_test_vmsplice_in_parent(char *mem, size_t size,
>   		.iov_base = mem,
>   		.iov_len = size,
>   	};
> -	ssize_t cur, total, transferred;
> +	ssize_t cur, total, transferred = 0;
>   	struct comm_pipes comm_pipes;
>   	char *old, *new;
>   	int ret, fds[2];


if (before_fork) {
	transferred = vmsplice(fds[1], &iov, 1, 0);
...

if (!before_fork) {
	transferred = vmsplice(fds[1], &iov, 1, 0);
...

for (total = 0; total < transferred; total += cur) {
...


And I don't see any jump label that could jump to code that would ve 
using transferred.

What am I missing?

-- 
Cheers,

David / dhildenb



  reply	other threads:[~2025-04-09  9:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-09  9:50 Anshuman Khandual
2025-04-09  9:57 ` David Hildenbrand [this message]
2025-04-09 10:09   ` Anshuman Khandual
2025-04-09 10:21     ` David Hildenbrand
2025-04-09 10:25       ` Anshuman Khandual
2025-04-09 10:31         ` David Hildenbrand
2025-04-09 10:36           ` David Hildenbrand

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=9da46633-e9c1-42a7-b52b-16cf89836abc@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=anshuman.khandual@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --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