Browse Source

Avoid static analyzer warnings about potentially uninitialized values

ppa-0.6.1
practicalswift 7 years ago
committed by Christian Decker
parent
commit
5db73c6e27
  1. 4
      gossipd/gossip.c
  2. 5
      gossipd/test/run-find_route.c

4
gossipd/gossip.c

@ -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) static struct io_plan *connection_in(struct io_conn *conn, struct daemon *daemon)
{ {
struct wireaddr addr; struct wireaddr addr;
struct sockaddr_storage s; struct sockaddr_storage s = {};
socklen_t len = sizeof(s); socklen_t len = sizeof(s);
if (getpeername(io_conn_fd(conn), (struct sockaddr *)&s, &len) != 0) { if (getpeername(io_conn_fd(conn), (struct sockaddr *)&s, &len) != 0) {
@ -1577,7 +1577,7 @@ static void setup_listeners(struct daemon *daemon, u16 portnum)
/* IPv6, since on Linux that (usually) binds to IPv4 too. */ /* IPv6, since on Linux that (usually) binds to IPv4 too. */
fd1 = make_listen_fd(AF_INET6, &addr6, sizeof(addr6), true); fd1 = make_listen_fd(AF_INET6, &addr6, sizeof(addr6), true);
if (fd1 >= 0) { if (fd1 >= 0) {
struct sockaddr_in6 in6; struct sockaddr_in6 in6 = {};
len = sizeof(in6); len = sizeof(in6);
if (getsockname(fd1, (void *)&in6, &len) != 0) { if (getsockname(fd1, (void *)&in6, &len) != 0) {

5
gossipd/test/run-find_route.c

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

Loading…
Cancel
Save