[PATCH] ctdb-server: Add goto tag avoiding code duplication
Swen Schillig
swen at vnet.ibm.com
Fri Mar 9 08:14:51 UTC 2018
Please review and push if OK.
Thanks in advance.
Cheers Swen
-------------- next part --------------
From fb84d39aa744f4a0357fea2973e803b9c2556ff0 Mon Sep 17 00:00:00 2001
From: Swen Schillig <swen at vnet.ibm.com>
Date: Thu, 8 Feb 2018 12:08:45 +0100
Subject: [PATCH] ctdb-server: Add goto tag avoiding code duplication
Introduced err_out goto tag to prevent code duplication.
Signed-off-by: Swen Schillig <swen at vnet.ibm.com>
---
ctdb/server/ctdb_call.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/ctdb/server/ctdb_call.c b/ctdb/server/ctdb_call.c
index 6fa3d14c595..a076000a800 100644
--- a/ctdb/server/ctdb_call.c
+++ b/ctdb/server/ctdb_call.c
@@ -1856,23 +1856,20 @@ int ctdb_start_revoke_ro_record(struct ctdb_context *ctdb,
rev_hdl->key.dptr = talloc_memdup(rev_hdl, key.dptr, key.dsize);
if (rev_hdl->key.dptr == NULL) {
D_ERR("Failed to allocate key for revokechild_handle\n");
- talloc_free(rev_hdl);
- return -1;
+ goto err_out;
}
ret = pipe(rev_hdl->fd);
if (ret != 0) {
D_ERR("Failed to allocate key for revokechild_handle\n");
- talloc_free(rev_hdl);
- return -1;
+ goto err_out;
}
rev_hdl->child = ctdb_fork(ctdb);
if (rev_hdl->child == (pid_t)-1) {
D_ERR("Failed to fork child for revokechild\n");
- talloc_free(rev_hdl);
- return -1;
+ goto err_out;
}
if (rev_hdl->child == 0) {
@@ -1913,6 +1910,9 @@ child_finished:
tevent_fd_set_auto_close(rev_hdl->fde);
return 0;
+err_out:
+ talloc_free(rev_hdl);
+ return -1;
}
int ctdb_add_revoke_deferred_call(struct ctdb_context *ctdb, struct ctdb_db_context *ctdb_db, TDB_DATA key, struct ctdb_req_header *hdr, deferred_requeue_fn fn, void *call_context)
--
2.14.3
More information about the samba-technical
mailing list