]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
dont allocate arrays where we can just return a single integer
authorRonnie Sahlberg <sahlberg@ronnie>
Sat, 5 May 2007 22:05:22 +0000 (08:05 +1000)
committerRonnie Sahlberg <sahlberg@ronnie>
Sat, 5 May 2007 22:05:22 +0000 (08:05 +1000)
(This used to be ctdb commit 07bc338e490e0f7018808a2450bc54863eb88c94)

ctdb/common/ctdb_client.c
ctdb/common/ctdb_control.c

index e9de2d7e2144d34a6aa0aa5fb8f8a4dd3d4a5813..a5a07f7ff38553a6be2a934be2b7ca19f79fcb49 100644 (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;
 }
index c058104946b0dc472b00df47c3bb4236cace53f8..dfbfc32383e154aeece040740f199cf451431da7 100644 (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: {