1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

dont allocate arrays where we can just return a single integer

(This used to be ctdb commit 07bc338e490e0f7018808a2450bc54863eb88c94)
This commit is contained in:
Ronnie Sahlberg 2007-05-06 08:05:22 +10:00
parent dceab7ff3e
commit c9aafae5ce
2 changed files with 7 additions and 16 deletions

View File

@ -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;
}

View File

@ -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: {