From 668f288c996a79566c32fca24fa09ab00a51d800 Mon Sep 17 00:00:00 2001 From: Jagger Date: Wed, 9 Mar 2016 01:16:50 +0100 Subject: [PATCH] Firther deferization of net.c --- net.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/net.c b/net.c index ecf1182..76b4453 100644 --- a/net.c +++ b/net.c @@ -57,11 +57,14 @@ bool netInitNsFromParent(struct nsjconf_t * nsjconf, int pid) return true; } - int err, master_index; - - struct nl_sock *sk = nl_socket_alloc(); + __block struct nl_sock *sk = nl_socket_alloc(); + if (sk == NULL) { + LOG_E("Could not allocate socket with nl_socket_alloc()"); + return false; + } defer(nl_socket_free(sk)); + int err; if ((err = nl_connect(sk, NETLINK_ROUTE)) < 0) { LOG_E("Unable to connect socket: %s", nl_geterror(err)); return false; @@ -81,7 +84,8 @@ bool netInitNsFromParent(struct nsjconf_t * nsjconf, int pid) } defer(nl_cache_free(link_cache)); - if (!(master_index = rtnl_link_name2i(link_cache, nsjconf->iface))) { + int master_index = rtnl_link_name2i(link_cache, nsjconf->iface); + if (master_index == 0) { LOG_E("rtnl_link_name2i(): Did not find '%s' interface", nsjconf->iface); return false; }