]> git.ozlabs.org Git - ccan/commitdiff
ccan: fix erroneous fd negation in poll.c.
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 28 Feb 2019 05:26:10 +0000 (15:56 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 28 Feb 2019 05:26:10 +0000 (15:56 +1030)
We could just make them -1, since we don't rely on the values.
But simple negation doesn't make 0 invalid.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan/io/poll.c

index a853c8705f1d5b68971327ec9c38d22ef4222e2b..b44f12563865f6729155371ff8e4ca17a778e160 100644 (file)
@@ -58,7 +58,7 @@ static bool add_fd(struct fd *fd, short events)
        pollfds[num_fds].events = events;
        /* In case it's idle. */
        if (!events)
        pollfds[num_fds].events = events;
        /* In case it's idle. */
        if (!events)
-               pollfds[num_fds].fd = -fd->fd;
+               pollfds[num_fds].fd = -fd->fd - 1;
        else
                pollfds[num_fds].fd = fd->fd;
        pollfds[num_fds].revents = 0; /* In case we're iterating now */
        else
                pollfds[num_fds].fd = fd->fd;
        pollfds[num_fds].revents = 0; /* In case we're iterating now */
@@ -176,7 +176,7 @@ void backend_new_plan(struct io_conn *conn)
                num_waiting++;
                pfd->fd = conn->fd.fd;
        } else {
                num_waiting++;
                pfd->fd = conn->fd.fd;
        } else {
-               pfd->fd = -conn->fd.fd;
+               pfd->fd = -conn->fd.fd - 1;
        }
 }
 
        }
 }