netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v3] selftest:net: Fix uninit return values
@ 2025-09-29 21:12 Sidharth Seela
  2025-09-30  9:09 ` Simon Horman
  0 siblings, 1 reply; 4+ messages in thread
From: Sidharth Seela @ 2025-09-29 21:12 UTC (permalink / raw)
  To: antonio, sd, edumazet, kuba, pabeni, horms, shuah,
	willemdebruijn.kernel, kernelxing, nathan, nick.desaulniers+lkml,
	morbo, justinstitt
  Cc: netdev, linux-kselftest, linux-kernel, llvm, Sidharth Seela

Fix functions that return undefined values. These issues were caught by
running clang using LLVM=1 option; and are as follows:
--
ovpn-cli.c:1587:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
 1587 |         if (!sock) {
      |             ^~~~~
ovpn-cli.c:1635:9: note: uninitialized use occurs here
 1635 |         return ret;
      |                ^~~
ovpn-cli.c:1587:2: note: remove the 'if' if its condition is always false
 1587 |         if (!sock) {
      |         ^~~~~~~~~~~~
 1588 |                 fprintf(stderr, "cannot allocate netlink socket\n");
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1589 |                 goto err_free;
      |                 ~~~~~~~~~~~~~~
 1590 |         }
      |         ~
ovpn-cli.c:1584:15: note: initialize the variable 'ret' to silence this warning
 1584 |         int mcid, ret;
      |                      ^
      |                       = 0
ovpn-cli.c:2107:7: warning: variable 'ret' is used uninitialized whenever switch case is taken [-Wsometimes-uninitialized]
 2107 |         case CMD_INVALID:
      |              ^~~~~~~~~~~
ovpn-cli.c:2111:9: note: uninitialized use occurs here
 2111 |         return ret;
      |                ^~~
ovpn-cli.c:1939:12: note: initialize the variable 'ret' to silence this warning
 1939 |         int n, ret;
      |                   ^
      |
--
Fixes: 959bc330a439 ("testing/selftests: add test tool and scripts for ovpn module")
ovpn module")

v3:
	- Use prefix net.
	- Remove so_txtime fix as default case calls error().
	- Changelog before sign-off.
	- Three dashes after sign-off

v2:
	- Use subsystem name "net".
	- Add fixes tags.
	- Remove txtimestamp fix as default case calls error.
	- Assign constant error string instead of NULL.

Signed-off-by: Sidharth Seela <sidharthseela@gmail.com>
---

diff --git a/tools/testing/selftests/net/ovpn/ovpn-cli.c b/tools/testing/selftests/net/ovpn/ovpn-cli.c
index 9201f2905f2c..20d00378f34a 100644
--- a/tools/testing/selftests/net/ovpn/ovpn-cli.c
+++ b/tools/testing/selftests/net/ovpn/ovpn-cli.c
@@ -1581,7 +1581,7 @@ static int ovpn_listen_mcast(void)
 {
 	struct nl_sock *sock;
 	struct nl_cb *cb;
-	int mcid, ret;
+	int mcid, ret = -1;
 
 	sock = nl_socket_alloc();
 	if (!sock) {
@@ -1936,7 +1936,7 @@ static int ovpn_run_cmd(struct ovpn_ctx *ovpn)
 {
 	char peer_id[10], vpnip[INET6_ADDRSTRLEN], laddr[128], lport[10];
 	char raddr[128], rport[10];
-	int n, ret;
+	int n, ret = -1;
 	FILE *fp;
 
 	switch (ovpn->cmd) {
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net v3] selftest:net: Fix uninit return values
  2025-09-29 21:12 [PATCH net v3] selftest:net: Fix uninit return values Sidharth Seela
@ 2025-09-30  9:09 ` Simon Horman
  2025-09-30  9:47   ` Sidharth Seela
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Horman @ 2025-09-30  9:09 UTC (permalink / raw)
  To: Sidharth Seela
  Cc: antonio, sd, edumazet, kuba, pabeni, shuah, willemdebruijn.kernel,
	kernelxing, nathan, nick.desaulniers+lkml, morbo, justinstitt,
	netdev, linux-kselftest, linux-kernel, llvm

On Tue, Sep 30, 2025 at 02:42:42AM +0530, Sidharth Seela wrote:
> Fix functions that return undefined values. These issues were caught by
> running clang using LLVM=1 option; and are as follows:
> --

Hi,

I don't want to block progress.
But there are some format problems with the commit message.

Locally, git truncates the commit message at the line above ('--').
Which, omits a lot of useful information.
Most critically your Signed-off-by line.

There is also another '--' below. Just above the fixes tag.
Which would cause a similar problem.

And the v2/v3 information should go below the scissors ('---'),
below your signed-off by line.

Maybe the maintainers can fix this when applying,
given how close we are to the pull for v6.18-rc1.
And that I believe there has already been some
discussion of this patch with the maintainers.

> ovpn-cli.c:1587:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
>  1587 |         if (!sock) {
>       |             ^~~~~
> ovpn-cli.c:1635:9: note: uninitialized use occurs here
>  1635 |         return ret;
>       |                ^~~
> ovpn-cli.c:1587:2: note: remove the 'if' if its condition is always false
>  1587 |         if (!sock) {
>       |         ^~~~~~~~~~~~
>  1588 |                 fprintf(stderr, "cannot allocate netlink socket\n");
>       |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>  1589 |                 goto err_free;
>       |                 ~~~~~~~~~~~~~~
>  1590 |         }
>       |         ~
> ovpn-cli.c:1584:15: note: initialize the variable 'ret' to silence this warning
>  1584 |         int mcid, ret;
>       |                      ^
>       |                       = 0
> ovpn-cli.c:2107:7: warning: variable 'ret' is used uninitialized whenever switch case is taken [-Wsometimes-uninitialized]
>  2107 |         case CMD_INVALID:
>       |              ^~~~~~~~~~~
> ovpn-cli.c:2111:9: note: uninitialized use occurs here
>  2111 |         return ret;
>       |                ^~~
> ovpn-cli.c:1939:12: note: initialize the variable 'ret' to silence this warning
>  1939 |         int n, ret;
>       |                   ^
>       |
> --
> Fixes: 959bc330a439 ("testing/selftests: add test tool and scripts for ovpn module")
> ovpn module")
> 
> v3:
> 	- Use prefix net.
> 	- Remove so_txtime fix as default case calls error().
> 	- Changelog before sign-off.
> 	- Three dashes after sign-off
> 
> v2:
> 	- Use subsystem name "net".
> 	- Add fixes tags.
> 	- Remove txtimestamp fix as default case calls error.
> 	- Assign constant error string instead of NULL.
> 
> Signed-off-by: Sidharth Seela <sidharthseela@gmail.com>
> ---
> 

This is where the v2/v3 information should go.

...

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net v3] selftest:net: Fix uninit return values
  2025-09-30  9:09 ` Simon Horman
@ 2025-09-30  9:47   ` Sidharth Seela
  2025-10-01 15:19     ` Simon Horman
  0 siblings, 1 reply; 4+ messages in thread
From: Sidharth Seela @ 2025-09-30  9:47 UTC (permalink / raw)
  To: Simon Horman
  Cc: antonio, sd, edumazet, kuba, pabeni, shuah, willemdebruijn.kernel,
	kernelxing, nathan, nick.desaulniers+lkml, morbo, justinstitt,
	netdev, linux-kselftest, linux-kernel, llvm

On Tue, Sep 30, 2025 at 2:39 PM Simon Horman <horms@kernel.org> wrote:
> Hi,
>
> I don't want to block progress.
> But there are some format problems with the commit message.
>
> Locally, git truncates the commit message at the line above ('--').
> Which, omits a lot of useful information.
> Most critically your Signed-off-by line.
>
> There is also another '--' below. Just above the fixes tag.
> Which would cause a similar problem.
>
> And the v2/v3 information should go below the scissors ('---'),
> below your signed-off by line.
>
> Maybe the maintainers can fix this when applying,
> given how close we are to the pull for v6.18-rc1.
> And that I believe there has already been some
> discussion of this patch with the maintainers.
>
> > ovpn-cli.c:1587:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
> >  1587 |         if (!sock) {
> >       |             ^~~~~
> > ovpn-cli.c:1635:9: note: uninitialized use occurs here
> >  1635 |         return ret;
> >       |                ^~~
> > ovpn-cli.c:1587:2: note: remove the 'if' if its condition is always false
> >  1587 |         if (!sock) {
> >       |         ^~~~~~~~~~~~
> >  1588 |                 fprintf(stderr, "cannot allocate netlink socket\n");
> >       |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >  1589 |                 goto err_free;
> >       |                 ~~~~~~~~~~~~~~
> >  1590 |         }
> >       |         ~
> > ovpn-cli.c:1584:15: note: initialize the variable 'ret' to silence this warning
> >  1584 |         int mcid, ret;
> >       |                      ^
> >       |                       = 0
> > ovpn-cli.c:2107:7: warning: variable 'ret' is used uninitialized whenever switch case is taken [-Wsometimes-uninitialized]
> >  2107 |         case CMD_INVALID:
> >       |              ^~~~~~~~~~~
> > ovpn-cli.c:2111:9: note: uninitialized use occurs here
> >  2111 |         return ret;
> >       |                ^~~
> > ovpn-cli.c:1939:12: note: initialize the variable 'ret' to silence this warning
> >  1939 |         int n, ret;
> >       |                   ^
> >       |
> > --
> > Fixes: 959bc330a439 ("testing/selftests: add test tool and scripts for ovpn module")
> > ovpn module")
> >
> > v3:
> >       - Use prefix net.
> >       - Remove so_txtime fix as default case calls error().
> >       - Changelog before sign-off.
> >       - Three dashes after sign-off
> >
> > v2:
> >       - Use subsystem name "net".
> >       - Add fixes tags.
> >       - Remove txtimestamp fix as default case calls error.
> >       - Assign constant error string instead of NULL.
> >
> > Signed-off-by: Sidharth Seela <sidharthseela@gmail.com>
> > ---
> >
>
> This is where the v2/v3 information should go.
>
> ...

Thankyou Simon, I didn't know that double hyphen would cause
an issue. Although I need a logical separator between commit message
and warning log, may I ask what could be used instead?

-- 
Thanks,
Sidharth Seela
www.realtimedesign.org

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net v3] selftest:net: Fix uninit return values
  2025-09-30  9:47   ` Sidharth Seela
@ 2025-10-01 15:19     ` Simon Horman
  0 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2025-10-01 15:19 UTC (permalink / raw)
  To: Sidharth Seela
  Cc: antonio, sd, edumazet, kuba, pabeni, shuah, willemdebruijn.kernel,
	kernelxing, nathan, nick.desaulniers+lkml, morbo, justinstitt,
	netdev, linux-kselftest, linux-kernel, llvm

On Tue, Sep 30, 2025 at 03:17:02PM +0530, Sidharth Seela wrote:
> On Tue, Sep 30, 2025 at 2:39 PM Simon Horman <horms@kernel.org> wrote:
> > Hi,
> >
> > I don't want to block progress.
> > But there are some format problems with the commit message.
> >
> > Locally, git truncates the commit message at the line above ('--').
> > Which, omits a lot of useful information.
> > Most critically your Signed-off-by line.
> >
> > There is also another '--' below. Just above the fixes tag.
> > Which would cause a similar problem.
> >
> > And the v2/v3 information should go below the scissors ('---'),
> > below your signed-off by line.
> >
> > Maybe the maintainers can fix this when applying,
> > given how close we are to the pull for v6.18-rc1.
> > And that I believe there has already been some
> > discussion of this patch with the maintainers.
> >
> > > ovpn-cli.c:1587:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
> > >  1587 |         if (!sock) {
> > >       |             ^~~~~
> > > ovpn-cli.c:1635:9: note: uninitialized use occurs here
> > >  1635 |         return ret;
> > >       |                ^~~
> > > ovpn-cli.c:1587:2: note: remove the 'if' if its condition is always false
> > >  1587 |         if (!sock) {
> > >       |         ^~~~~~~~~~~~
> > >  1588 |                 fprintf(stderr, "cannot allocate netlink socket\n");
> > >       |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > >  1589 |                 goto err_free;
> > >       |                 ~~~~~~~~~~~~~~
> > >  1590 |         }
> > >       |         ~
> > > ovpn-cli.c:1584:15: note: initialize the variable 'ret' to silence this warning
> > >  1584 |         int mcid, ret;
> > >       |                      ^
> > >       |                       = 0
> > > ovpn-cli.c:2107:7: warning: variable 'ret' is used uninitialized whenever switch case is taken [-Wsometimes-uninitialized]
> > >  2107 |         case CMD_INVALID:
> > >       |              ^~~~~~~~~~~
> > > ovpn-cli.c:2111:9: note: uninitialized use occurs here
> > >  2111 |         return ret;
> > >       |                ^~~
> > > ovpn-cli.c:1939:12: note: initialize the variable 'ret' to silence this warning
> > >  1939 |         int n, ret;
> > >       |                   ^
> > >       |
> > > --
> > > Fixes: 959bc330a439 ("testing/selftests: add test tool and scripts for ovpn module")
> > > ovpn module")
> > >
> > > v3:
> > >       - Use prefix net.
> > >       - Remove so_txtime fix as default case calls error().
> > >       - Changelog before sign-off.
> > >       - Three dashes after sign-off
> > >
> > > v2:
> > >       - Use subsystem name "net".
> > >       - Add fixes tags.
> > >       - Remove txtimestamp fix as default case calls error.
> > >       - Assign constant error string instead of NULL.
> > >
> > > Signed-off-by: Sidharth Seela <sidharthseela@gmail.com>
> > > ---
> > >
> >
> > This is where the v2/v3 information should go.
> >
> > ...
> 
> Thankyou Simon, I didn't know that double hyphen would cause
> an issue. Although I need a logical separator between commit message
> and warning log, may I ask what could be used instead?

Good question. And, TBH, I didn't know that '--' does that either.

A blank line should certainly be safe.
Perhaps ~~ and == are too.

You can check by applying the resulting patch using git am.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-10-01 15:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-29 21:12 [PATCH net v3] selftest:net: Fix uninit return values Sidharth Seela
2025-09-30  9:09 ` Simon Horman
2025-09-30  9:47   ` Sidharth Seela
2025-10-01 15:19     ` Simon Horman

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