[Cluster-devel] [PATCH 3/3] Use standard path var and memset it before each query

Fabio M. Di Nitto fabbione at ubuntu.com
Tue Oct 23 04:49:35 UTC 2007


From: Fabio M. Di Nitto <fabbione at ubuntu.com>

Signed-off-by: Fabio M. Di Nitto <fabbione at ubuntu.com>
---
:100644 100644 6abc618... 30bf039... M	cman/daemon/cmanccs.c
 cman/daemon/cmanccs.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/cman/daemon/cmanccs.c b/cman/daemon/cmanccs.c
index 6abc618..30bf039 100644
--- a/cman/daemon/cmanccs.c
+++ b/cman/daemon/cmanccs.c
@@ -130,24 +130,26 @@ int read_ccs_nodes(unsigned int *config_version, int check_nodeids)
 	two_node = 0;
 
     for (i=1;;i++) {
-	char nodekey[256];
-	char key[256];
+	char path[MAX_PATH_LEN];
 	int  votes=0, nodeid=0;
 
-	sprintf(nodekey, NODE_NAME_PATH_BYNUM, i);
-	error = ccs_get(ctree, nodekey, &nodename);
+	memset(path, 0, MAX_PATH_LEN);
+	sprintf(path, NODE_NAME_PATH_BYNUM, i);
+	error = ccs_get(ctree, path, &nodename);
 	if (error)
 	    break;
 
-	sprintf(key, NODE_VOTES_PATH, nodename);
-	if (!ccs_get(ctree, key, &str)) {
+	memset(path, 0, MAX_PATH_LEN);
+	sprintf(path, NODE_VOTES_PATH, nodename);
+	if (!ccs_get(ctree, path, &str)) {
 	    votes = atoi(str);
 	    free(str);
 	} else
 	    votes = 1;
 
-	sprintf(key, NODE_NODEID_PATH, nodename);
-	if (!ccs_get(ctree, key, &str))	{
+	memset(path, 0, MAX_PATH_LEN);
+	sprintf(path, NODE_NODEID_PATH, nodename);
+	if (!ccs_get(ctree, path, &str)) {
 	    nodeid = atoi(str);
 	    free(str);
 
-- 
1.5.2.5




More information about the Cluster-devel mailing list