]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
tipc/node: Fix socket fd check in cmd_node_get_addr()
authorPhil Sutter <phil@nwl.cc>
Thu, 17 Aug 2017 17:09:32 +0000 (19:09 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Fri, 18 Aug 2017 16:13:17 +0000 (09:13 -0700)
socket() returns -1 on error, not 0.

Signed-off-by: Phil Sutter <phil@nwl.cc>
tipc/node.c

index 201fe1a4df3bd9e2e54b68522baa3406cd517198..fe085aec9b4acae5be327649c90f8465f83111e4 100644 (file)
@@ -109,7 +109,8 @@ static int cmd_node_get_addr(struct nlmsghdr *nlh, const struct cmd *cmd,
        socklen_t sz = sizeof(struct sockaddr_tipc);
        struct sockaddr_tipc addr;
 
-       if (!(sk = socket(AF_TIPC, SOCK_RDM, 0))) {
+       sk = socket(AF_TIPC, SOCK_RDM, 0);
+       if (sk < 0) {
                fprintf(stderr, "opening TIPC socket: %s\n", strerror(errno));
                return -1;
        }