Skip to content

Commit

Permalink
fix maybe-uninitialized errors
Browse files Browse the repository at this point in the history
Set {listen,server}_sock to -1 when needed as already done in
src/manager.c by commit ecf1fcc to
avoid the following build failure:

local.c: In function 'create_and_bind':
local.c:218:12: error: 'listen_sock' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  218 |     return listen_sock;
      |            ^~~~~~~~~~~

Fixes:
 - http://autobuild.buildroot.org/results/27471a878ff52a972ac087d534e44fb0c50808f6

Signed-off-by: Fabrice Fontaine <[email protected]>
  • Loading branch information
ffontaine authored and Max Lv committed Apr 11, 2022
1 parent 46382c2 commit 0c23224
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/local.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ create_and_bind(const char *addr, const char *port)
{
struct addrinfo hints;
struct addrinfo *result, *rp;
int s, listen_sock;
int s, listen_sock = -1;

memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC; /* Return IPv4 and IPv6 choices */
Expand Down
2 changes: 1 addition & 1 deletion src/redir.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ create_and_bind(const char *addr, const char *port)
{
struct addrinfo hints;
struct addrinfo *result, *rp;
int s, listen_sock;
int s, listen_sock = -1;

memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC; /* Return IPv4 and IPv6 choices */
Expand Down
2 changes: 1 addition & 1 deletion src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ create_and_bind(const char *host, const char *port, int mptcp)
{
struct addrinfo hints;
struct addrinfo *result, *rp, *ipv4v6bindall;
int s, listen_sock;
int s, listen_sock = -1;

memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC; /* Return IPv4 and IPv6 choices */
Expand Down
2 changes: 1 addition & 1 deletion src/tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ create_and_bind(const char *addr, const char *port)
{
struct addrinfo hints;
struct addrinfo *result, *rp;
int s, listen_sock;
int s, listen_sock = -1;

memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC; /* Return IPv4 and IPv6 choices */
Expand Down
2 changes: 1 addition & 1 deletion src/udprelay.c
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ create_server_socket(const char *host, const char *port)
{
struct addrinfo hints;
struct addrinfo *result, *rp, *ipv4v6bindall;
int s, server_sock;
int s, server_sock = -1;

memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC; /* Return IPv4 and IPv6 choices */
Expand Down

0 comments on commit 0c23224

Please sign in to comment.