[Ocfs2-tools-devel] [PATCH 37/37] o2cbtool: Utilize #defines for heartbeat modes

Sunil Mushran sunil.mushran at oracle.com
Mon Jan 31 11:15:31 PST 2011


Use O2CB_GLOBAL_HEARTBEAT_TAG and O2CB_LOCAL_HEARTBEAT_TAG instead of
the hard coded strings.

Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
---
 o2cb_ctl/o2cb_config.c  |    4 ++--
 o2cb_ctl/op_heartbeat.c |    3 ++-
 o2cb_ctl/op_lists.c     |    2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/o2cb_ctl/o2cb_config.c b/o2cb_ctl/o2cb_config.c
index 0018f46..997dab3 100644
--- a/o2cb_ctl/o2cb_config.c
+++ b/o2cb_ctl/o2cb_config.c
@@ -198,7 +198,7 @@ static gint o2cb_config_fill_cluster(O2CBConfig *config, JConfig *cf,
     rc = -ENOMEM;
     hb_mode = j_config_get_attribute(c_cfs, "heartbeat_mode");
     if (!hb_mode)
-        hb_mode = g_strdup("local");
+        hb_mode = g_strdup(O2CB_LOCAL_HEARTBEAT_TAG);
     if (!hb_mode)
         goto out_error;
     rc = o2cb_cluster_set_heartbeat_mode(cluster, hb_mode);
@@ -623,7 +623,7 @@ O2CBCluster *o2cb_config_add_cluster(O2CBConfig *config,
     cluster = g_new(O2CBCluster, 1);
 
     cluster->c_name = g_strdup(name);
-    cluster->c_hb_mode = g_strdup("local");
+    cluster->c_hb_mode = g_strdup(O2CB_LOCAL_HEARTBEAT_TAG);
     cluster->c_num_nodes = 0;
     cluster->c_nodes = NULL;
     cluster->c_heartbeat = NULL;
diff --git a/o2cb_ctl/op_heartbeat.c b/o2cb_ctl/op_heartbeat.c
index 4de4d70..3a822ab 100644
--- a/o2cb_ctl/op_heartbeat.c
+++ b/o2cb_ctl/op_heartbeat.c
@@ -176,7 +176,8 @@ errcode_t o2cbtool_heartbeat_mode(struct o2cb_command *cmd)
 	clustername = cmd->o_argv[1];
 	hbmode = cmd->o_argv[2];
 
-	if (strcmp(hbmode, "global") && strcmp(hbmode, "local"))
+	if (strcmp(hbmode, O2CB_GLOBAL_HEARTBEAT_TAG) &&
+	    strcmp(hbmode, O2CB_LOCAL_HEARTBEAT_TAG))
 		goto bail;
 
 	cmd->o_print_usage = 0;
diff --git a/o2cb_ctl/op_lists.c b/o2cb_ctl/op_lists.c
index 13f04cb..2d47776 100644
--- a/o2cb_ctl/op_lists.c
+++ b/o2cb_ctl/op_lists.c
@@ -121,7 +121,7 @@ static void show_cluster(O2CBCluster *cluster, gchar *clustername,
 	nodecount = o2cb_cluster_get_node_count(cluster);
 	hbmode = o2cb_cluster_get_heartbeat_mode(cluster);
 	if (!hbmode)
-		hbmode = strdup("local");
+		hbmode = strdup(O2CB_LOCAL_HEARTBEAT_TAG);
 	verbosef(VL_OUT, format, nodecount, hbmode, clustername);
 	g_free(hbmode);
 }
-- 
1.7.1




More information about the Ocfs2-tools-devel mailing list