tools/ctdb: Stop return value from being clobbered in control_lvsmaster()
authorMartin Schwenke <martin@meltin.net>
Wed, 18 Sep 2013 03:40:52 +0000 (13:40 +1000)
committerAmitay Isaacs <amitay@gmail.com>
Fri, 4 Oct 2013 05:15:35 +0000 (15:15 +1000)
ret is initialised too early and is clobbered by the call to
ctdb_ctrl_getcapabilities().  Initialising it later means that the
function returns -1 when no LVS master is found.

Signed-off-by: Martin Schwenke <martin@meltin.net>
tools/ctdb.c

index 552906816848a658e81024f43186d4c889a96f0e..727d38e051f9590c268bd2a92d2f23cc42e6dcf8 100644 (file)
@@ -3538,8 +3538,6 @@ static int control_lvsmaster(struct ctdb_context *ctdb, int argc, const char **a
                CTDB_NO_MEMORY(ctdb, capabilities);
        }
 
-       ret = -1;
-       
        /* collect capabilities for all connected nodes */
        for (i=0; i<nodemap->num; i++) {
                if (nodemap->nodes[i].flags & NODE_FLAGS_INACTIVE) {
@@ -3565,6 +3563,8 @@ static int control_lvsmaster(struct ctdb_context *ctdb, int argc, const char **a
                }
        }
 
+       ret = -1;
+
        /* find and show the lvsmaster */
        for (i=0; i<nodemap->num; i++) {
                if (nodemap->nodes[i].flags & NODE_FLAGS_INACTIVE) {