Skip to content

Commit

Permalink
Avoid static analyzer warnings about potentially uninitialized values
Browse files Browse the repository at this point in the history
  • Loading branch information
practicalswift authored and cdecker committed May 1, 2018
1 parent f083a69 commit 5db73c6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gossipd/gossip.c
Original file line number Diff line number Diff line change
Expand Up @@ -1518,7 +1518,7 @@ static void gossip_refresh_network(struct daemon *daemon)
static struct io_plan *connection_in(struct io_conn *conn, struct daemon *daemon)
{
struct wireaddr addr;
struct sockaddr_storage s;
struct sockaddr_storage s = {};
socklen_t len = sizeof(s);

if (getpeername(io_conn_fd(conn), (struct sockaddr *)&s, &len) != 0) {
Expand Down Expand Up @@ -1577,7 +1577,7 @@ static void setup_listeners(struct daemon *daemon, u16 portnum)
/* IPv6, since on Linux that (usually) binds to IPv4 too. */
fd1 = make_listen_fd(AF_INET6, &addr6, sizeof(addr6), true);
if (fd1 >= 0) {
struct sockaddr_in6 in6;
struct sockaddr_in6 in6 = {};

len = sizeof(in6);
if (getsockname(fd1, (void *)&in6, &len) != 0) {
Expand Down
5 changes: 5 additions & 0 deletions gossipd/test/run-find_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ int main(void)
add_connection(rstate, &a, &b, 1, 1, 1);

route = find_route(tmpctx, rstate, &a, &b, 1000, riskfactor, 0.0, NULL, &fee);
assert(route);
assert(tal_count(route) == 1);
assert(fee == 0);

Expand All @@ -214,6 +215,7 @@ int main(void)
add_connection(rstate, &b, &c, 1, 1, 1);

route = find_route(tmpctx, rstate, &a, &c, 1000, riskfactor, 0.0, NULL, &fee);
assert(route);
assert(tal_count(route) == 2);
assert(fee == 1);

Expand All @@ -228,13 +230,15 @@ int main(void)

/* Will go via D for small amounts. */
route = find_route(tmpctx, rstate, &a, &c, 1000, riskfactor, 0.0, NULL, &fee);
assert(route);
assert(tal_count(route) == 2);
assert(channel_is_between(route[0], &a, &d));
assert(channel_is_between(route[1], &d, &c));
assert(fee == 0);

/* Will go via B for large amounts. */
route = find_route(tmpctx, rstate, &a, &c, 3000000, riskfactor, 0.0, NULL, &fee);
assert(route);
assert(tal_count(route) == 2);
assert(channel_is_between(route[0], &a, &b));
assert(channel_is_between(route[1], &b, &c));
Expand All @@ -243,6 +247,7 @@ int main(void)
/* Make B->C inactive, force it back via D */
get_connection(rstate, &b, &c)->active = false;
route = find_route(tmpctx, rstate, &a, &c, 3000000, riskfactor, 0.0, NULL, &fee);
assert(route);
assert(tal_count(route) == 2);
assert(channel_is_between(route[0], &a, &d));
assert(channel_is_between(route[1], &d, &c));
Expand Down

0 comments on commit 5db73c6

Please sign in to comment.