]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
control_open() should always return the fd to help static analysis.
authorRoy Marples <roy@marples.name>
Tue, 3 May 2016 11:07:57 +0000 (11:07 +0000)
committerRoy Marples <roy@marples.name>
Tue, 3 May 2016 11:07:57 +0000 (11:07 +0000)
control.c

index 3510dcb004faf4815df43c3e7bb386de6d58f522..4c0e3beb0f6ef4130a5c0ed4e43f676c751b3cab 100644 (file)
--- 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