Skip to content

Commit 7fc25c5

Browse files
sidharth-458kuba-moo
authored andcommitted
selftest: net: ovpn: Fix uninit return values
Fix functions that return undefined values. These issues were caught by running clang using LLVM=1 option. Clang warnings 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: 959bc33 ("testing/selftests: add test tool and scripts for ovpn module") Signed-off-by: Sidharth Seela <sidharthseela@gmail.com> Link: https://patch.msgid.link/20251001123107.96244-2-sidharthseela@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent bc9ea78 commit 7fc25c5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tools/testing/selftests/net/ovpn/ovpn-cli.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,6 +1586,7 @@ static int ovpn_listen_mcast(void)
15861586
sock = nl_socket_alloc();
15871587
if (!sock) {
15881588
fprintf(stderr, "cannot allocate netlink socket\n");
1589+
ret = -ENOMEM;
15891590
goto err_free;
15901591
}
15911592

@@ -2105,6 +2106,7 @@ static int ovpn_run_cmd(struct ovpn_ctx *ovpn)
21052106
ret = ovpn_listen_mcast();
21062107
break;
21072108
case CMD_INVALID:
2109+
ret = -EINVAL;
21082110
break;
21092111
}
21102112

0 commit comments

Comments
 (0)