[sheepdog] [PATCH] sheep: remove a needless conditional branch

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Tue Jul 2 12:27:31 CEST 2013


Current create_cluster() has a conditional branch which depends on
cluster drivers have their own get_local_addr(). If every cluster
driver has their own one, the branch is needless.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
 sheep/cluster/shepherd.c  |    1 +
 sheep/cluster/zookeeper.c |    1 +
 sheep/group.c             |    6 ++----
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/sheep/cluster/shepherd.c b/sheep/cluster/shepherd.c
index 46ca5f9..26fb005 100644
--- a/sheep/cluster/shepherd.c
+++ b/sheep/cluster/shepherd.c
@@ -693,6 +693,7 @@ static struct cluster_driver cdrv_shepherd = {
 	.block		= shepherd_block,
 	.unblock	= shepherd_unblock,
 	.update_node	= shepherd_update_node,
+	.get_local_addr = get_local_addr,
 };
 
 cdrv_register(cdrv_shepherd);
diff --git a/sheep/cluster/zookeeper.c b/sheep/cluster/zookeeper.c
index 5e2018e..5ed16cf 100644
--- a/sheep/cluster/zookeeper.c
+++ b/sheep/cluster/zookeeper.c
@@ -1173,6 +1173,7 @@ static struct cluster_driver cdrv_zookeeper = {
 	.block      = zk_block,
 	.unblock    = zk_unblock,
 	.update_node = zk_update_node,
+	.get_local_addr = get_local_addr,
 };
 
 cdrv_register(cdrv_zookeeper);
diff --git a/sheep/group.c b/sheep/group.c
index 2d4a25c..1b1cea5 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -1284,10 +1284,8 @@ int create_cluster(int port, int64_t zone, int nr_vnodes,
 		return -1;
 
 	if (!explicit_addr) {
-		if (sys->cdrv->get_local_addr)
-			ret = sys->cdrv->get_local_addr(sys->this_node.nid.addr);
-		else
-			ret = get_local_addr(sys->this_node.nid.addr);
+		ret = sys->cdrv->get_local_addr(sys->this_node.nid.addr);
+
 		if (ret < 0)
 			return -1;
 	}
-- 
1.7.10.4




More information about the sheepdog mailing list