Browse Source

wireaddr: handle case where non-IPv6 and non-IPv4 address is returned.

Thanks clang!  Here's the error:
ommon/wireaddr.c:359:14: error: variable 'addr' is used uninitialized whenever

      'if' condition is false [-Werror,-Wsometimes-uninitialized]
                } else if (addrinfo->ai_family == AF_INET6) {
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
common/wireaddr.c:364:25: note: uninitialized use occurs here
                tal_arr_expand(addrs, addr);
                                      ^~~~
./common/utils.h:27:16: note: expanded from macro 'tal_arr_expand'
                (*(p))[n] = (s);                                        \
                             ^
common/wireaddr.c:359:10: note: remove the 'if' if its condition is always true
                } else if (addrinfo->ai_family == AF_INET6) {
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
common/wireaddr.c:354:3: note: variable 'addr' is declared here
                struct wireaddr addr;
                ^

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
travis-debug
Rusty Russell 5 years ago
parent
commit
f554d6376f
  1. 4
      common/wireaddr.c

4
common/wireaddr.c

@ -360,7 +360,9 @@ bool wireaddr_from_hostname(struct wireaddr **addrs, const char *hostname,
sa6 = (struct sockaddr_in6 *) addrinfo->ai_addr;
wireaddr_from_ipv6(&addr, &sa6->sin6_addr, port);
res = true;
}
} else
/* Ignore any other address types. */
continue;
tal_arr_expand(addrs, addr);
}

Loading…
Cancel
Save