From c9aafae5ce0058bff7eaa64c011fb79e05cb64dd Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Sun, 6 May 2007 08:05:22 +1000 Subject: [PATCH] dont allocate arrays where we can just return a single integer (This used to be ctdb commit 07bc338e490e0f7018808a2450bc54863eb88c94) --- ctdb/common/ctdb_client.c | 10 +++++----- ctdb/common/ctdb_control.c | 13 ++----------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/ctdb/common/ctdb_client.c b/ctdb/common/ctdb_client.c index e9de2d7e214..a5a07f7ff38 100644 --- a/ctdb/common/ctdb_client.c +++ b/ctdb/common/ctdb_client.c @@ -843,12 +843,12 @@ int ctdb_ctrl_getrecmode(struct ctdb_context *ctdb, struct timeval timeout, uint ret = ctdb_control(ctdb, destnode, 0, CTDB_CONTROL_GET_RECMODE, 0, data, ctdb, &outdata, &res, &timeout); - if (ret != 0 || res != 0) { + if (ret != 0) { DEBUG(0,(__location__ " ctdb_control for getrecmode failed\n")); return -1; } - *recmode = ((uint32_t *)outdata.dptr)[0]; + *recmode = res; return 0; } @@ -1589,12 +1589,12 @@ int ctdb_ctrl_getpid(struct ctdb_context *ctdb, struct timeval timeout, uint32_t ret = ctdb_control(ctdb, destnode, 0, CTDB_CONTROL_GET_PID, 0, data, ctdb, &outdata, &res, &timeout); - if (ret != 0 || res != 0) { - DEBUG(0,(__location__ " ctdb_control for getrecmode failed\n")); + if (ret != 0) { + DEBUG(0,(__location__ " ctdb_control for getpid failed\n")); return -1; } - *pid = ((uint32_t *)outdata.dptr)[0]; + *pid = res; return 0; } diff --git a/ctdb/common/ctdb_control.c b/ctdb/common/ctdb_control.c index c058104946b..dfbfc32383e 100644 --- a/ctdb/common/ctdb_control.c +++ b/ctdb/common/ctdb_control.c @@ -341,20 +341,11 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb, } case CTDB_CONTROL_GET_RECMODE: { - outdata->dsize = sizeof(uint32_t); - outdata->dptr = (unsigned char *)&ctdb->recovery_mode; - - return 0; + return ctdb->recovery_mode; } case CTDB_CONTROL_GET_PID: { - static uint32_t pid; - - pid = getpid(); - outdata->dsize = sizeof(uint32_t); - outdata->dptr = (unsigned char *)&pid; - - return 0; + return getpid(); } case CTDB_CONTROL_CONFIG: {