public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* master - fence: Fix bug in make_args()
@ 2008-11-07 22:34 Lon Hohberger
  0 siblings, 0 replies; only message in thread
From: Lon Hohberger @ 2008-11-07 22:34 UTC (permalink / raw)
  To: cluster-cvs-relay

Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=3de140ad461dadfd99eadd4d37bc9d53ffd1b741
Commit:        3de140ad461dadfd99eadd4d37bc9d53ffd1b741
Parent:        69b3ecac8da9ce4a34efb6702b253e52ea87e063
Author:        Lon Hohberger <lhh@redhat.com>
AuthorDate:    Fri Nov 7 17:33:20 2008 -0500
Committer:     Lon Hohberger <lhh@redhat.com>
CommitterDate: Fri Nov 7 17:33:20 2008 -0500

fence: Fix bug in make_args()

A bug in make_args() caused it  to always return an error code,
even if we formulated a perfectly good set of arguments.

Basically, eventually ccs_get_list returns -1 when all items are
exhausted, so the check at the bottom of the function would free
any arguments we had (correctly) set up and return an error code,
thereby avoiding actually calling the agent.
---
 fence/libfence/agent.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/fence/libfence/agent.c b/fence/libfence/agent.c
index 3454ec7..c04df17 100644
--- a/fence/libfence/agent.c
+++ b/fence/libfence/agent.c
@@ -128,7 +128,7 @@ static int make_args(int cd, char *victim, char *method, int d,
 				char *device, char **args_out)
 {
 	char path[256], *args, *str;
-	int error;
+	int error, cnt = 0;
 
 	args = malloc(MAX_AGENT_ARGS_LEN);
 	if (!args)
@@ -144,6 +144,7 @@ static int make_args(int cd, char *victim, char *method, int d,
 		error = ccs_get_list(cd, path, &str);
 		if (error || !str)
 			break;
+		++cnt;
 
 		if (!strncmp(str, "name=", 5)) {
 			free(str);
@@ -164,6 +165,7 @@ static int make_args(int cd, char *victim, char *method, int d,
 		error = ccs_get_list(cd, path, &str);
 		if (error || !str)
 			break;
+		++cnt;
 
 		if (!strncmp(str, "name=", 5)) {
 			free(str);
@@ -175,6 +177,8 @@ static int make_args(int cd, char *victim, char *method, int d,
 		free(str);
 	}
 
+	if (cnt)
+		error = 0;
 	if (error) {
 		free(args);
 		args = NULL;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-11-07 22:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-07 22:34 master - fence: Fix bug in make_args() Lon Hohberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).