messaging4: Add "goto fail" to imessaging_init
authorVolker Lendecke <vl@samba.org>
Thu, 27 Mar 2014 10:07:34 +0000 (10:07 +0000)
committerJeremy Allison <jra@samba.org>
Mon, 31 Mar 2014 20:52:14 +0000 (22:52 +0200)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source4/lib/messaging/messaging.c

index ba1c5bd727cc606d10aeb99e96d2d3e24e2fa978..b1b0003e7bd8276402cdd17a59ce825f487c1ff7 100644 (file)
@@ -590,24 +590,21 @@ struct imessaging_context *imessaging_init(TALLOC_CTX *mem_ctx,
        /* setup a handler for messages from other cluster nodes, if appropriate */
        status = cluster_message_init(msg, server_id, cluster_message_handler);
        if (!NT_STATUS_IS_OK(status)) {
-               talloc_free(msg);
-               return NULL;
+               goto fail;
        }
 
        /* create the messaging directory if needed */
 
        msg->lp_ctx = talloc_reference(msg, lp_ctx);
        if (!msg->lp_ctx) {
-               talloc_free(msg);
-               return NULL;
+               goto fail;
        }
 
        msg->base_path     = lpcfg_imessaging_path(msg, lp_ctx);
 
        ok = directory_create_or_exist_strict(msg->base_path, geteuid(), 0700);
        if (!ok) {
-               talloc_free(msg);
-               return NULL;
+               goto fail;
        }
 
        msg->path          = imessaging_path(msg, server_id);
@@ -618,8 +615,7 @@ struct imessaging_context *imessaging_init(TALLOC_CTX *mem_ctx,
 
        status = socket_create("unix", SOCKET_TYPE_DGRAM, &msg->sock, 0);
        if (!NT_STATUS_IS_OK(status)) {
-               talloc_free(msg);
-               return NULL;
+               goto fail;
        }
 
        /* by stealing here we ensure that the socket is cleaned up (and even
@@ -629,15 +625,13 @@ struct imessaging_context *imessaging_init(TALLOC_CTX *mem_ctx,
        path = socket_address_from_strings(msg, msg->sock->backend_name,
                                           msg->path, 0);
        if (!path) {
-               talloc_free(msg);
-               return NULL;
+               goto fail;
        }
 
        status = socket_listen(msg->sock, path, 50, 0);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("Unable to setup messaging listener for '%s':%s\n", msg->path, nt_errstr(status)));
-               talloc_free(msg);
-               return NULL;
+               goto fail;
        }
 
        /* it needs to be non blocking for sends */
@@ -657,6 +651,9 @@ struct imessaging_context *imessaging_init(TALLOC_CTX *mem_ctx,
        IRPC_REGISTER(msg, irpc, IRPC_UPTIME, irpc_uptime, msg);
 
        return msg;
+fail:
+       talloc_free(msg);
+       return NULL;
 }
 
 /*