[python] Fix reference counting for Py_None.
authorMatthias Bolte <matthias.bolte@googlemail.com>
Thu, 5 Nov 2009 14:26:13 +0000 (15:26 +0100)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Thu, 5 Nov 2009 14:29:12 +0000 (15:29 +0100)
  * Before returning Py_None its reference count has to be
    increased by Py_INCREF(), otherwise the reference count
    of Py_None drops to zero after some time.

Signed-off-by: Matthias Bolte <matthias.bolte@googlemail.com>

python/module.c

index a431d16..4bc7bb9 100644 (file)
 
 static PyObject *_error_type;
 
+static PyObject *
+_return_none_or_null (int none)
+{
+       if (none) {
+               Py_INCREF (Py_None);
+               return Py_None;
+       } else {
+               return NULL;
+       }
+}
+
 static void
 _format_error (struct VscError *error)
 {
@@ -392,8 +403,8 @@ static PyObject *
 _init (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
        struct VscError error;
-       PyObject *result = Py_None;
-       PyObject *config_filename_object = Py_None;
+       int success = TRUE;
+       PyObject *config_filename_object = NULL;
        const char *config_filename = NULL;
 
        if (! PyArg_ParseTuple (args, "O:init", &config_filename_object)) {
@@ -401,8 +412,8 @@ _init (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
        }
 
        if (_unwrap_optional_string (config_filename_object,
-                                   "config_filename",
-                                   &config_filename) < 0) {
+                                    "config_filename",
+                                    &config_filename) < 0) {
                return NULL;
        }
 
@@ -418,10 +429,10 @@ _init (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 cleanup:
        vsc_error_cleanup (&error);
 
-       return result;
+       return _return_none_or_null (success);
 
 failure:
-       result = NULL;
+       success = FALSE;
 
        goto cleanup;
 }
@@ -445,7 +456,7 @@ _cleanup (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 
        vsc_mgmt_cleanup ();
 
-       return Py_None;
+       return _return_none_or_null (TRUE);
 }
 
 
@@ -462,7 +473,7 @@ static PyObject *
 _backup (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
        struct VscError error;
-       PyObject *result = Py_None;
+       int success = TRUE;
        const char *filename;
 
        if (! PyArg_ParseTuple (args, "s:backup", &filename)) {
@@ -481,16 +492,14 @@ _backup (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 cleanup:
        vsc_error_cleanup (&error);
 
-       return result;
+       return _return_none_or_null (success);
 
 failure:
-       result = NULL;
+       success = FALSE;
 
        goto cleanup;
 }
 
-
-
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  * Core: recover
  */
@@ -504,7 +513,7 @@ _recover (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
        struct VscError error;
        const char *filename;
-       PyObject *result = Py_None;
+       int success = TRUE;
 
        if (! PyArg_ParseTuple (args, "s:recover", &filename)) {
                return NULL;
@@ -522,10 +531,10 @@ _recover (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 cleanup:
        vsc_error_cleanup (&error);
 
-       return result;
+       return _return_none_or_null (success);
 
 failure:
-       result = NULL;
+       success = FALSE;
 
        goto cleanup;
 }
@@ -543,7 +552,7 @@ static PyObject *
 _tabula_rasa (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
        struct VscError error;
-       PyObject *result = Py_None;
+       int success = TRUE;
        int force_level = 0;
 
        if (! PyArg_ParseTuple (args, "i:tabula_rasa", &force_level)) {
@@ -562,10 +571,10 @@ _tabula_rasa (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 cleanup:
        vsc_error_cleanup (&error);
 
-       return result;
+       return _return_none_or_null (success);
 
 failure:
-       result = NULL;
+       success = FALSE;
 
        goto cleanup;
 }
@@ -675,9 +684,9 @@ static PyObject *
 _host_get_info (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
        struct VscError error;
+       PyObject *result = NULL;
        PyObject *last_modification_object = NULL;
        PyObject *last_resource_allocation_object = NULL;
-       PyObject *host_info_object = NULL;
        const char *host_ipv4_string = NULL;
        struct VscMgmtIpv4 host_ipv4;
        struct VscMgmtHostInfo host_info;
@@ -708,7 +717,7 @@ _host_get_info (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
        last_resource_allocation_object =
           Py_BuildValue ("(ll)", host_info.last_resource_allocation.tv_sec,
                          host_info.last_resource_allocation.tv_usec);
-       host_info_object =
+       result =
           Py_BuildValue ("{sssisIsIsksNsN}",
                          "ipv4", host_ipv4_string,
                          "type", host_info.type,
@@ -722,13 +731,10 @@ _host_get_info (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 cleanup:
        vsc_error_cleanup (&error);
 
-       return (PyObject *) host_info_object;
+       return result;
 
 failure:
-       if (host_info_object != NULL) {
-               Py_DECREF (host_info_object);
-               host_info_object = NULL;
-       }
+       VSC__ASSERT (result == NULL);
 
        goto cleanup;
 }
@@ -809,7 +815,7 @@ static PyObject *
 _read_host_list (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
        struct VscError error;
-       PyObject *result = Py_None;
+       int success = TRUE;
        const char *filename;
 
        if (! PyArg_ParseTuple (args, "s:read_host_list", &filename)) {
@@ -830,10 +836,10 @@ _read_host_list (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 cleanup:
        vsc_error_cleanup (&error);
 
-       return result;
+       return _return_none_or_null (success);
 
 failure:
-       result = NULL;
+       success = FALSE;
 
        goto cleanup;
 }
@@ -902,9 +908,8 @@ PyDoc_STRVAR (_image_deploy__doc__,
 static PyObject *
 _image_deploy (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
-       PyObject *result = Py_None;
-
        struct VscError error;
+       int success = TRUE;
        const char *image_filename = NULL;
        PyObject *vm_uuid_list_object = NULL;
        struct VscMgmtUuid *vm_uuid_list = NULL;
@@ -934,10 +939,10 @@ _image_deploy (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 cleanup:
        vsc_error_cleanup (&error);
 
-       return result;
+       return _return_none_or_null (success);
 
 failure:
-       result = NULL;
+       success = FALSE;
 
        goto cleanup;
 }
@@ -956,11 +961,11 @@ static PyObject *
 _image_retract (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
        struct VscError error;
+       int success = TRUE;
        const char *vm_uuid_string = NULL;
        PyObject *image_filename_object = NULL;
        const char *image_filename = NULL;
        struct VscMgmtUuid vm_uuid;
-       PyObject *result = Py_None;
 
        if (! PyArg_ParseTuple (args, "sO:image_retract", &vm_uuid_string,
                                &image_filename_object)) {
@@ -991,10 +996,10 @@ _image_retract (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 cleanup:
        vsc_error_cleanup (&error);
 
-       return result;
+       return _return_none_or_null (success);
 
 failure:
-       result = NULL;
+       success = FALSE;
 
        goto cleanup;
 }
@@ -1015,8 +1020,8 @@ PyDoc_STRVAR (_vm_deploy__doc__,
 static PyObject *
 _vm_deploy (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
-       PyObject *result = Py_None;
        struct VscError error;
+       int success = TRUE;
        PyObject *host_ipv4_list_object = NULL;
        PyObject *vm_uuid_list_object = NULL;
        PyObject *vm_resource_config_object = NULL;
@@ -1088,10 +1093,10 @@ cleanup:
 
        vsc_error_cleanup (&error);
 
-       return result;
+       return _return_none_or_null (success);
 
 failure:
-       result = NULL;
+       success = FALSE;
 
        goto cleanup;
 }
@@ -1110,9 +1115,9 @@ static PyObject *
 _vm_retract (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
        struct VscError error;
+       int success = TRUE;
        const char *vm_uuid_string = NULL;
        struct VscMgmtUuid vm_uuid;
-       PyObject *result = Py_None;
 
        if (! PyArg_ParseTuple (args, "s:vm_retract", &vm_uuid_string)) {
                return NULL;
@@ -1137,10 +1142,10 @@ _vm_retract (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 cleanup:
        vsc_error_cleanup (&error);
 
-       return result;
+       return _return_none_or_null (success);
 
 failure:
-       result = NULL;
+       success = FALSE;
 
        goto cleanup;
 }
@@ -1159,9 +1164,9 @@ static PyObject *
 _vm_power_on (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
        struct VscError error;
+       int success = TRUE;
        const char *vm_uuid_string = NULL;
        struct VscMgmtUuid vm_uuid;
-       PyObject *result = Py_None;
 
        if (! PyArg_ParseTuple (args, "s:vm_power_on", &vm_uuid_string)) {
                return NULL;
@@ -1186,10 +1191,10 @@ _vm_power_on (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 cleanup:
        vsc_error_cleanup (&error);
 
-       return result;
+       return _return_none_or_null (success);
 
 failure:
-       result = NULL;
+       success = FALSE;
 
        goto cleanup;
 }
@@ -1208,9 +1213,9 @@ static PyObject *
 _vm_power_off (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
        struct VscError error;
+       int success = TRUE;
        const char *vm_uuid_string = NULL;
        struct VscMgmtUuid vm_uuid;
-       PyObject *result = Py_None;
 
        if (! PyArg_ParseTuple (args, "s:vm_power_off", &vm_uuid_string)) {
                return NULL;
@@ -1235,10 +1240,10 @@ _vm_power_off (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 cleanup:
        vsc_error_cleanup (&error);
 
-       return result;
+       return _return_none_or_null (success);
 
 failure:
-       result = NULL;
+       success = FALSE;
 
        goto cleanup;
 }
@@ -1257,9 +1262,9 @@ static PyObject *
 _vm_reboot (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
        struct VscError error;
+       int success = TRUE;
        const char *vm_uuid_string = NULL;
        struct VscMgmtUuid vm_uuid;
-       PyObject *result = Py_None;
 
        if (! PyArg_ParseTuple (args, "s:vm_reboot", &vm_uuid_string)) {
                return NULL;
@@ -1284,10 +1289,10 @@ _vm_reboot (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 cleanup:
        vsc_error_cleanup (&error);
 
-       return result;
+       return _return_none_or_null (success);
 
 failure:
-       result = NULL;
+       success = FALSE;
 
        goto cleanup;
 }
@@ -1306,11 +1311,11 @@ static PyObject *
 _vm_migrate (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
        struct VscError error;
+       int success = TRUE;
        const char *vm_uuid_string = NULL;
        const char *host_ipv4_string = NULL;
        struct VscMgmtUuid vm_uuid;
        struct VscMgmtIpv4 host_ipv4;
-       PyObject *result = Py_None;
 
        if (! PyArg_ParseTuple (args, "ss:vm_migrate", &vm_uuid_string,
                                &host_ipv4_string)) {
@@ -1343,10 +1348,10 @@ _vm_migrate (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 cleanup:
        vsc_error_cleanup (&error);
 
-       return result;
+       return _return_none_or_null (success);
 
 failure:
-       result = NULL;
+       success = FALSE;
 
        goto cleanup;
 }
@@ -1365,7 +1370,7 @@ static PyObject *
 _vm_get_uuid (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
        struct VscError error;
-       PyObject *result = Py_None;
+       PyObject *result = NULL;
        const char *vm_ipv4_string = NULL;
        struct VscMgmtIpv4 vm_ipv4;
        struct VscMgmtUuid vm_uuid;
@@ -1401,7 +1406,7 @@ cleanup:
        return result;
 
 failure:
-       result = NULL;
+       VSC__ASSERT (result == NULL);
 
        goto cleanup;
 }
@@ -1420,12 +1425,12 @@ static PyObject *
 _vm_get_info (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
        struct VscError error;
+       PyObject *result = NULL;
        PyObject *resource_config_object = NULL;
        PyObject *checkpoint_uuid_list_object = NULL;
        PyObject *deployed_at_object = NULL;
        PyObject *last_config_change_object = NULL;
        PyObject *last_state_change_object = NULL;
-       PyObject *vm_info_object = NULL;
        const char *vm_uuid_string = NULL;
        struct VscMgmtUuid vm_uuid;
        struct VscMgmtVmInfo vm_info;
@@ -1479,7 +1484,7 @@ _vm_get_info (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
        last_config_change_object =
           Py_BuildValue ("(ll)", vm_info.last_config_change.tv_sec,
                          vm_info.last_config_change.tv_usec);
-       vm_info_object =
+       result =
           Py_BuildValue ("{sssssisssNsNsssssN}",
                          "uuid", vm_uuid_string,
                          "ipv4", vm_ipv4_string,
@@ -1497,13 +1502,10 @@ cleanup:
        vsc_mgmt_vm_info_cleanup (&vm_info);
        vsc_error_cleanup (&error);
 
-       return (PyObject *) vm_info_object;
+       return result;
 
 failure:
-       if (vm_info_object != NULL) {
-               Py_DECREF (vm_info_object);
-               vm_info_object = NULL;
-       }
+       VSC__ASSERT (result == NULL);
 
        goto cleanup;
 }
@@ -1522,7 +1524,7 @@ static PyObject *
 _vm_get_host (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
        struct VscError error;
-       PyObject *result = Py_None;
+       PyObject *result = NULL;
        const char *vm_uuid_string = NULL;
        struct VscMgmtUuid vm_uuid;
        struct VscMgmtIpv4 host_ipv4;
@@ -1558,7 +1560,7 @@ cleanup:
        return result;
 
 failure:
-       result = NULL;
+       VSC__ASSERT (result == NULL);
 
        goto cleanup;
 }
@@ -1577,6 +1579,7 @@ static PyObject *
 _vm_set_resource_config (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
        struct VscError error;
+       int success = TRUE;
        const char *vm_uuid_string = NULL;
        PyObject *vm_resource_config_object = NULL;
        struct VscMgmtUuid vm_uuid;
@@ -1584,7 +1587,6 @@ _vm_set_resource_config (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
        PyObject* core_clock_object = NULL;
        PyObject* memory_size_object = NULL;
        struct VscMgmtVmResourceConfig vm_resource_config;
-       PyObject *result = Py_None;
 
        if (! PyArg_ParseTuple (args, "sO:vm_set_resource_config", &vm_uuid_string,
                                &vm_resource_config_object)) {
@@ -1666,10 +1668,10 @@ _vm_set_resource_config (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 cleanup:
        vsc_error_cleanup (&error);
 
-       return result;
+       return _return_none_or_null (success);
 
 failure:
-       result = NULL;
+       success = FALSE;
 
        goto cleanup;
 }
@@ -1688,7 +1690,7 @@ static PyObject *
 _read_network_list (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
        struct VscError error;
-       PyObject *result = Py_None;
+       int success = TRUE;
        const char *filename;
 
        if (! PyArg_ParseTuple (args, "s:read_network_list", &filename)) {
@@ -1709,10 +1711,10 @@ _read_network_list (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 cleanup:
        vsc_error_cleanup (&error);
 
-       return result;
+       return _return_none_or_null (success);
 
 failure:
-       result = NULL;
+       success = FALSE;
 
        goto cleanup;
 }
@@ -1731,9 +1733,9 @@ static PyObject *
 _network_setup (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
        struct VscError error;
+       PyObject *result = NULL;
        struct VscMgmtUuid *network_uuid = NULL;
        char network_uuid_string[VSC_MGMT__UUID__STRING_SIZE] = "";
-       PyObject *result = Py_None;
 
        if (! PyArg_ParseTuple (args, ":network_setup")) {
                return NULL;
@@ -1759,7 +1761,7 @@ cleanup:
        return result;
 
 failure:
-       result = NULL;
+       VSC__ASSERT (result == NULL);
 
        goto cleanup;
 }
@@ -1778,9 +1780,9 @@ static PyObject *
 _network_teardown (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
        struct VscError error;
+       int success = TRUE;
        const char *network_uuid_string = NULL;
        struct VscMgmtUuid network_uuid;
-       PyObject *result = Py_None;
 
        if (! PyArg_ParseTuple (args, "s:network_teardown", &network_uuid_string)) {
                return NULL;
@@ -1805,10 +1807,10 @@ _network_teardown (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 cleanup:
        vsc_error_cleanup (&error);
 
-       return result;
+       return _return_none_or_null (success);
 
 failure:
-       result = NULL;
+       success = FALSE;
 
        goto cleanup;
 }
@@ -1827,11 +1829,11 @@ static PyObject *
 _suspension_create (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
        struct VscError error;
+       PyObject *result = NULL;
        PyObject *vm_uuid_list_object = NULL;
        struct VscMgmtUuid *vm_uuid_list = NULL;
        struct VscMgmtUuid suspension_uuid;
        char suspension_uuid_string[VSC_MGMT__UUID__STRING_SIZE] = "";
-       PyObject *suspension_uuid_object = Py_None;
 
        if (! PyArg_ParseTuple (args, "O:suspension_create",
                                &vm_uuid_list_object)) {
@@ -1857,15 +1859,15 @@ _suspension_create (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 
        vsc_mgmt_uuid_format (&suspension_uuid, suspension_uuid_string);
 
-       suspension_uuid_object = Py_BuildValue ("s", suspension_uuid_string);
+       result = Py_BuildValue ("s", suspension_uuid_string);
 
 cleanup:
        vsc_error_cleanup (&error);
 
-       return suspension_uuid_object;
+       return result;
 
 failure:
-       suspension_uuid_object = NULL;
+       VSC__ASSERT (result == NULL);
 
        goto cleanup;
 }
@@ -1884,9 +1886,9 @@ static PyObject *
 _suspension_resume (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
        struct VscError error;
+       int success = TRUE;
        const char *suspension_uuid_string = NULL;
        struct VscMgmtUuid suspension_uuid;
-       PyObject *result = Py_None;
 
        if (! PyArg_ParseTuple (args, "s:suspension_resume",
                                &suspension_uuid_string)) {
@@ -1912,10 +1914,10 @@ _suspension_resume (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 cleanup:
        vsc_error_cleanup (&error);
 
-       return result;
+       return _return_none_or_null (success);
 
 failure:
-       result = NULL;
+       success = FALSE;
 
        goto cleanup;
 }
@@ -1934,7 +1936,7 @@ static PyObject *
 _suspension_get_info (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
        struct VscError error;
-       PyObject *suspension_info_object = NULL;
+       PyObject *result = NULL;
        const char *suspension_uuid_string = NULL;
        struct VscMgmtUuid suspension_uuid;
        struct VscMgmtSuspensionInfo suspension_info;
@@ -1960,20 +1962,16 @@ _suspension_get_info (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
                goto failure;
        }
 
-       suspension_info_object =
-          Py_BuildValue ("{si}",
-                         "dummy", suspension_info.dummy);
+       result = Py_BuildValue ("{si}",
+                               "dummy", suspension_info.dummy);
 
 cleanup:
        vsc_error_cleanup (&error);
 
-       return suspension_info_object;
+       return result;
 
 failure:
-       if (suspension_info_object != NULL) {
-               Py_DECREF (suspension_info_object);
-               suspension_info_object = NULL;
-       }
+       VSC__ASSERT (result == NULL);
 
        goto cleanup;
 }
@@ -2044,11 +2042,11 @@ static PyObject *
 _checkpoint_create (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
        struct VscError error;
+       PyObject *result = NULL;
        PyObject *vm_uuid_list_object = NULL;
        struct VscMgmtUuid *vm_uuid_list = NULL;
        struct VscMgmtUuid checkpoint_uuid;
        char checkpoint_uuid_string[VSC_MGMT__UUID__STRING_SIZE] = "";
-       PyObject *checkpoint_uuid_object = Py_None;
 
        if (! PyArg_ParseTuple (args, "O:checkpoint_create",
                                &vm_uuid_list_object)) {
@@ -2074,15 +2072,15 @@ _checkpoint_create (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 
        vsc_mgmt_uuid_format (&checkpoint_uuid, checkpoint_uuid_string);
 
-       checkpoint_uuid_object = Py_BuildValue ("s", checkpoint_uuid_string);
+       result = Py_BuildValue ("s", checkpoint_uuid_string);
 
 cleanup:
        vsc_error_cleanup (&error);
 
-       return checkpoint_uuid_object;
+       return result;
 
 failure:
-       checkpoint_uuid_object = NULL;
+       VSC__ASSERT (result == NULL);
 
        goto cleanup;
 }
@@ -2101,9 +2099,9 @@ static PyObject *
 _checkpoint_delete (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
        struct VscError error;
+       int success = TRUE;
        const char *checkpoint_uuid_string = NULL;
        struct VscMgmtUuid checkpoint_uuid;
-       PyObject *result = Py_None;
 
        if (! PyArg_ParseTuple (args, "s:checkpoint_delete",
                                &checkpoint_uuid_string)) {
@@ -2129,10 +2127,10 @@ _checkpoint_delete (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 cleanup:
        vsc_error_cleanup (&error);
 
-       return result;
+       return _return_none_or_null (success);
 
 failure:
-       result = NULL;
+       success = FALSE;
 
        goto cleanup;
 }
@@ -2151,9 +2149,9 @@ static PyObject *
 _checkpoint_restore (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
        struct VscError error;
+       int success = TRUE;
        const char *checkpoint_uuid_string = NULL;
        struct VscMgmtUuid checkpoint_uuid;
-       PyObject *result = Py_None;
 
        if (! PyArg_ParseTuple (args, "s:checkpoint_restore",
                                &checkpoint_uuid_string)) {
@@ -2179,10 +2177,10 @@ _checkpoint_restore (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 cleanup:
        vsc_error_cleanup (&error);
 
-       return result;
+       return _return_none_or_null (success);
 
 failure:
-       result = NULL;
+       success = FALSE;
 
        goto cleanup;
 }
@@ -2201,7 +2199,7 @@ static PyObject *
 _checkpoint_get_info (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
 {
        struct VscError error;
-       PyObject *checkpoint_info_object = NULL;
+       PyObject *result = NULL;
        const char *checkpoint_uuid_string = NULL;
        struct VscMgmtUuid checkpoint_uuid;
        struct VscMgmtCheckpointInfo checkpoint_info;
@@ -2227,20 +2225,16 @@ _checkpoint_get_info (PyObject *self VSC__ATTR__UNUSED, PyObject *args)
                goto failure;
        }
 
-       checkpoint_info_object =
-          Py_BuildValue ("{si}",
-                         "dummy", checkpoint_info.dummy);
+       result = Py_BuildValue ("{si}",
+                               "dummy", checkpoint_info.dummy);
 
 cleanup:
        vsc_error_cleanup (&error);
 
-       return checkpoint_info_object;
+       return result;
 
 failure:
-       if (checkpoint_info_object != NULL) {
-               Py_DECREF (checkpoint_info_object);
-               checkpoint_info_object = NULL;
-       }
+       VSC__ASSERT (result == NULL);
 
        goto cleanup;
 }