]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
rpc_client: Simplify rpc_pipe_open_ncalrpc()
authorVolker Lendecke <vl@samba.org>
Sun, 10 Jan 2021 17:42:18 +0000 (18:42 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 12 Jan 2021 00:10:30 +0000 (00:10 +0000)
Consolidate close(fd)

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/rpc_client/cli_pipe.c

index 040bd7cda90faf3a2c1f3dfca881706c73eda8fe..8f52acadec87be38aa31cdd3e2e147bebeaa7ff6 100644 (file)
@@ -2925,7 +2925,7 @@ NTSTATUS rpc_pipe_open_ncalrpc(TALLOC_CTX *mem_ctx, const char *socket_path,
        socklen_t salen = sizeof(addr);
        size_t pathlen;
        NTSTATUS status;
-       int fd;
+       int fd = -1;
 
        pathlen = strlcpy(addr.sun_path, socket_path, sizeof(addr.sun_path));
        if (pathlen >= sizeof(addr.sun_path)) {
@@ -2966,15 +2966,14 @@ NTSTATUS rpc_pipe_open_ncalrpc(TALLOC_CTX *mem_ctx, const char *socket_path,
                DEBUG(0, ("connect(%s) failed: %s\n", socket_path,
                          strerror(errno)));
                status = map_nt_error_from_unix(errno);
-               close(fd);
                goto fail;
        }
 
        status = rpc_transport_sock_init(result, fd, &result->transport);
        if (!NT_STATUS_IS_OK(status)) {
-               close(fd);
                goto fail;
        }
+       fd = -1;
 
        result->transport->transport = NCALRPC;
 
@@ -2988,6 +2987,9 @@ NTSTATUS rpc_pipe_open_ncalrpc(TALLOC_CTX *mem_ctx, const char *socket_path,
        return NT_STATUS_OK;
 
  fail:
+       if (fd != -1) {
+               close(fd);
+       }
        TALLOC_FREE(result);
        return status;
 }