From: Roy Marples Date: Tue, 3 May 2016 11:07:57 +0000 (+0000) Subject: control_open() should always return the fd to help static analysis. X-Git-Tag: v6.11.0~50 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39b81574dfe71dc76ca02b78e21caf06d5239381;p=thirdparty%2Fdhcpcd.git control_open() should always return the fd to help static analysis. --- diff --git a/control.c b/control.c index 3510dcb0..4c0e3beb 100644 --- a/control.c +++ b/control.c @@ -314,17 +314,19 @@ int control_open(struct dhcpcd_ctx *ctx, const char *ifname) { struct sockaddr_un sa; - socklen_t len; - if ((ctx->control_fd = make_sock(&sa, ifname, 0)) == -1) - return -1; - len = (socklen_t)SUN_LEN(&sa); - if (connect(ctx->control_fd, (struct sockaddr *)&sa, len) == -1) { - close(ctx->control_fd); - ctx->control_fd = -1; - return -1; + if ((ctx->control_fd = make_sock(&sa, ifname, 0)) != -1) { + socklen_t len; + int r; + + len = (socklen_t)SUN_LEN(&sa); + r = connect(ctx->control_fd, (struct sockaddr *)&sa, len); + if (r == -1) { + close(ctx->control_fd); + ctx->control_fd = -1; + } } - return 0; + return ctx->control_fd; } ssize_t