From: Simon Horman <horms@kernel.org>
To: Alessandro Zanni <alessandro.zanni87@gmail.com>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, shuah@kernel.org, netdev@vger.kernel.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] selftest: net: prevent use of uninitialized variable
Date: Wed, 22 Oct 2025 15:33:33 +0100 [thread overview]
Message-ID: <aPjrPehLi14L9zuQ@horms.kernel.org> (raw)
In-Reply-To: <20251021165451.32984-1-alessandro.zanni87@gmail.com>
On Tue, Oct 21, 2025 at 06:54:33PM +0200, Alessandro Zanni wrote:
> Fix to avoid the usage of the `ret` variable uninitialized in the
> following macro expansions.
>
> It solves the following warning:
>
> In file included from netlink-dumps.c:21:
> netlink-dumps.c: In function ‘dump_extack’:
> ../kselftest_harness.h:788:35: warning: ‘ret’ may be used uninitialized [-Wmaybe-uninitialized]
> 788 | intmax_t __exp_print = (intmax_t)__exp; \
> | ^~~~~~~~~~~
> ../kselftest_harness.h:631:9: note: in expansion of macro ‘__EXPECT’
> 631 | __EXPECT(expected, #expected, seen, #seen, ==, 0)
> | ^~~~~~~~
> netlink-dumps.c:169:9: note: in expansion of macro ‘EXPECT_EQ’
> 169 | EXPECT_EQ(ret, FOUND_EXTACK);
> | ^~~~~~~~~
>
> The issue can be reproduced, building the tests, with the command:
> make -C tools/testing/selftests TARGETS=net
>
> Signed-off-by: Alessandro Zanni <alessandro.zanni87@gmail.com>
> ---
> tools/testing/selftests/net/netlink-dumps.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/net/netlink-dumps.c b/tools/testing/selftests/net/netlink-dumps.c
> index 7618ebe528a4..8ebb8b1b9c5c 100644
> --- a/tools/testing/selftests/net/netlink-dumps.c
> +++ b/tools/testing/selftests/net/netlink-dumps.c
> @@ -112,7 +112,7 @@ static const struct {
> TEST(dump_extack)
> {
> int netlink_sock;
> - int i, cnt, ret;
> + int i, cnt, ret = 0;
Hi Alessandro,
I suggest moving this line so that reverse xmas tree order - longest
line to shortest - is preserved.
> char buf[8192];
> int one = 1;
> ssize_t n;
> --
> 2.43.0
>
prev parent reply other threads:[~2025-10-22 14:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-21 16:54 [PATCH] selftest: net: prevent use of uninitialized variable Alessandro Zanni
2025-10-22 14:33 ` Simon Horman [this message]
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=aPjrPehLi14L9zuQ@horms.kernel.org \
--to=horms@kernel.org \
--cc=alessandro.zanni87@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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).