ctdbd: Update the get_tunable code to return -EINVAL for unknown tunable
authorMartin Schwenke <martin@meltin.net>
Tue, 21 May 2013 05:41:56 +0000 (15:41 +1000)
committerMartin Schwenke <martin@meltin.net>
Fri, 24 May 2013 06:04:50 +0000 (16:04 +1000)
Otherwise callers can't tell the difference between some other failure
(e.g. memory allocation failure) and an unknown tunable.

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

index e930bffc399a8bf5a92e8cf26b63b4f2991cb113..665426cd9230d75f2aaf4572f128b575f44cf509 100644 (file)
@@ -2502,7 +2502,7 @@ int ctdb_ctrl_get_tunable(struct ctdb_context *ctdb,
        talloc_free(data.dptr);
        if (ret != 0 || res != 0) {
                DEBUG(DEBUG_ERR,(__location__ " ctdb_control for get_tunable failed\n"));
-               return -1;
+               return ret != 0 ? ret : res;
        }
 
        if (outdata.dsize != sizeof(uint32_t)) {
index 84fb9490070c69e8ed3e3d61301b4142a2735549..365c6ba558493b953cb6d72273f5409594ce21c0 100644 (file)
@@ -128,7 +128,7 @@ int32_t ctdb_control_get_tunable(struct ctdb_context *ctdb, TDB_DATA indata,
        talloc_free(name);
        
        if (i == ARRAY_SIZE(tunable_map)) {
-               return -1;
+               return -EINVAL;
        }
 
        val = *(uint32_t *)(tunable_map[i].offset + (uint8_t*)&ctdb->tunable);
index 48ca93ba0eecf4a2e8e00fd8c30a3a9a371c4486..b3cbade35eca60cf36a0a7ea5c5d960339c5f28c 100644 (file)
@@ -4430,7 +4430,7 @@ static int control_getvar(struct ctdb_context *ctdb, int argc, const char **argv
 
        name = argv[0];
        ret = ctdb_ctrl_get_tunable(ctdb, TIMELIMIT(), options.pnn, name, &value);
-       if (ret == -1) {
+       if (ret != 0) {
                DEBUG(DEBUG_ERR, ("Unable to get tunable variable '%s'\n", name));
                return -1;
        }