Commit 0ce52c7c authored by Rusty Russell's avatar Rusty Russell

io: fix maybe-uninitialized warning in test (-O2)

/home/rusty/devel/cvs/ccan/ccan/io/test/run-01-start-finish.c: In function ‘main’:
/home/rusty/devel/cvs/ccan/ccan/io/test/run-01-start-finish.c:89:7: warning: ‘addrinfo’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   if (connect(fd, addrinfo->ai_addr, addrinfo->ai_addrlen) != 0)
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 6e86fffc
...@@ -47,7 +47,8 @@ struct io_conn; ...@@ -47,7 +47,8 @@ struct io_conn;
* int fd[2]; * int fd[2];
* struct io_conn *conn; * struct io_conn *conn;
* *
* pipe(fd); * if (pipe(fd) != 0)
* exit(1);
* conn = io_new_conn(NULL, fd[0], conn_init, (const char *)"hi!"); * conn = io_new_conn(NULL, fd[0], conn_init, (const char *)"hi!");
* if (!conn) * if (!conn)
* exit(1); * exit(1);
......
...@@ -69,7 +69,7 @@ static int make_listen_fd(const char *port, struct addrinfo **info) ...@@ -69,7 +69,7 @@ static int make_listen_fd(const char *port, struct addrinfo **info)
int main(void) int main(void)
{ {
int state = 0; int state = 0;
struct addrinfo *addrinfo; struct addrinfo *addrinfo = NULL;
struct io_listener *l; struct io_listener *l;
int fd; int fd;
......
...@@ -71,7 +71,7 @@ static int make_listen_fd(const char *port, struct addrinfo **info) ...@@ -71,7 +71,7 @@ static int make_listen_fd(const char *port, struct addrinfo **info)
int main(void) int main(void)
{ {
struct data *d = malloc(sizeof(*d)); struct data *d = malloc(sizeof(*d));
struct addrinfo *addrinfo; struct addrinfo *addrinfo = NULL;
struct io_listener *l; struct io_listener *l;
int fd, status; int fd, status;
......
...@@ -156,7 +156,8 @@ int main(void) ...@@ -156,7 +156,8 @@ int main(void)
ok1(t3.ts.tv_sec == 2); ok1(t3.ts.tv_sec == 2);
ok1(t3.ts.tv_nsec == 147483648); ok1(t3.ts.tv_nsec == 147483648);
pipe(fds); if (pipe(fds) != 0)
exit(1);
fflush(stdout); fflush(stdout);
switch (fork()) { switch (fork()) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment