[PATCH] libhal: unref DBusMessages as soon as possible
Guillem Jover
guillem.jover at NOKIA.COM
Thu Nov 8 19:03:52 PST 2007
Reduces the amount of same calls in different code paths. Fixes few
double unreferencing, and several resource leaks by unreferencing
the DBusMessages.
---
libhal/libhal.c | 255 ++++++++++++++++++++++---------------------------------
1 files changed, 101 insertions(+), 154 deletions(-)
diff --git a/libhal/libhal.c b/libhal/libhal.c
index 619b7a5..dfdbcce 100644
--- a/libhal/libhal.c
+++ b/libhal/libhal.c
@@ -501,18 +501,17 @@ libhal_device_get_all_properties (LibHalContext *ctx, const char *udi, DBusError
message, -1,
&_error);
+ dbus_message_unref (message);
+
dbus_move_error (&_error, error);
if (error != NULL && dbus_error_is_set (error)) {
fprintf (stderr,
"%s %d : %s\n",
__FILE__, __LINE__, error->message);
-
- dbus_message_unref (message);
return NULL;
}
if (reply == NULL) {
- dbus_message_unref (message);
return NULL;
}
@@ -520,7 +519,6 @@ libhal_device_get_all_properties (LibHalContext *ctx, const char *udi, DBusError
result = get_property_set (&reply_iter);
- dbus_message_unref (message);
dbus_message_unref (reply);
return result;
@@ -1219,13 +1217,13 @@ libhal_get_all_devices (LibHalContext *ctx, int *num_devices, DBusError *error)
dbus_error_init (&_error);
reply = dbus_connection_send_with_reply_and_block (ctx->connection, message, -1, &_error);
+ dbus_message_unref (message);
+
dbus_move_error (&_error, error);
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return NULL;
}
if (reply == NULL) {
- dbus_message_unref (message);
return NULL;
}
@@ -1234,6 +1232,7 @@ libhal_get_all_devices (LibHalContext *ctx, int *num_devices, DBusError *error)
if (dbus_message_iter_get_arg_type (&reply_iter) != DBUS_TYPE_ARRAY) {
fprintf (stderr, "%s %d : wrong reply from hald. Expecting an array.\n", __FILE__, __LINE__);
+ dbus_message_unref (reply);
return NULL;
}
@@ -1242,8 +1241,6 @@ libhal_get_all_devices (LibHalContext *ctx, int *num_devices, DBusError *error)
hal_device_names = libhal_get_string_array_from_iter (&iter_array, num_devices);
dbus_message_unref (reply);
- dbus_message_unref (message);
-
return hal_device_names;
}
@@ -1288,22 +1285,20 @@ libhal_device_get_property_type (LibHalContext *ctx, const char *udi, const char
message, -1,
&_error);
+ dbus_message_unref (message);
+
dbus_move_error (&_error, error);
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return LIBHAL_PROPERTY_TYPE_INVALID;
}
if (reply == NULL) {
- dbus_message_unref (message);
return LIBHAL_PROPERTY_TYPE_INVALID;
}
dbus_message_iter_init (reply, &reply_iter);
dbus_message_iter_get_basic (&reply_iter, &type);
- dbus_message_unref (message);
dbus_message_unref (reply);
-
return type;
}
@@ -1352,13 +1347,13 @@ libhal_device_get_property_strlist (LibHalContext *ctx, const char *udi, const c
message, -1,
&_error);
+ dbus_message_unref (message);
+
dbus_move_error (&_error, error);
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return NULL;
}
if (reply == NULL) {
- dbus_message_unref (message);
return NULL;
}
/* now analyse reply */
@@ -1366,6 +1361,7 @@ libhal_device_get_property_strlist (LibHalContext *ctx, const char *udi, const c
if (dbus_message_iter_get_arg_type (&reply_iter) != DBUS_TYPE_ARRAY) {
fprintf (stderr, "%s %d : wrong reply from hald. Expecting an array.\n", __FILE__, __LINE__);
+ dbus_message_unref (reply);
return NULL;
}
@@ -1374,8 +1370,6 @@ libhal_device_get_property_strlist (LibHalContext *ctx, const char *udi, const c
our_strings = libhal_get_string_array_from_iter (&iter_array, NULL);
dbus_message_unref (reply);
- dbus_message_unref (message);
-
return our_strings;
}
@@ -1426,13 +1420,13 @@ libhal_device_get_property_string (LibHalContext *ctx,
message, -1,
&_error);
+ dbus_message_unref (message);
+
dbus_move_error (&_error, error);
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return NULL;
}
if (reply == NULL) {
- dbus_message_unref (message);
return NULL;
}
@@ -1441,7 +1435,6 @@ libhal_device_get_property_string (LibHalContext *ctx,
/* now analyze reply */
if (dbus_message_iter_get_arg_type (&reply_iter) !=
DBUS_TYPE_STRING) {
- dbus_message_unref (message);
dbus_message_unref (reply);
return NULL;
}
@@ -1451,11 +1444,8 @@ libhal_device_get_property_string (LibHalContext *ctx,
if (value == NULL) {
fprintf (stderr, "%s %d : error allocating memory\n",
__FILE__, __LINE__);
- /** @todo FIXME cleanup */
- return NULL;
}
- dbus_message_unref (message);
dbus_message_unref (reply);
return value;
}
@@ -1503,13 +1493,13 @@ libhal_device_get_property_int (LibHalContext *ctx,
message, -1,
&_error);
+ dbus_message_unref (message);
+
dbus_move_error (&_error, error);
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return -1;
}
if (reply == NULL) {
- dbus_message_unref (message);
return -1;
}
@@ -1522,13 +1512,11 @@ libhal_device_get_property_int (LibHalContext *ctx,
"%s %d : property '%s' for device '%s' is not "
"of type integer\n", __FILE__, __LINE__, key,
udi);
- dbus_message_unref (message);
dbus_message_unref (reply);
return -1;
}
dbus_message_iter_get_basic (&reply_iter, &value);
- dbus_message_unref (message);
dbus_message_unref (reply);
return value;
}
@@ -1575,14 +1563,14 @@ libhal_device_get_property_uint64 (LibHalContext *ctx,
reply = dbus_connection_send_with_reply_and_block (ctx->connection,
message, -1,
&_error);
-
+
+ dbus_message_unref (message);
+
dbus_move_error (&_error, error);
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return -1;
}
if (reply == NULL) {
- dbus_message_unref (message);
return -1;
}
@@ -1594,13 +1582,11 @@ libhal_device_get_property_uint64 (LibHalContext *ctx,
"%s %d : property '%s' for device '%s' is not "
"of type integer\n", __FILE__, __LINE__, key,
udi);
- dbus_message_unref (message);
dbus_message_unref (reply);
return -1;
}
dbus_message_iter_get_basic (&reply_iter, &value);
- dbus_message_unref (message);
dbus_message_unref (reply);
return value;
}
@@ -1648,13 +1634,13 @@ libhal_device_get_property_double (LibHalContext *ctx,
message, -1,
&_error);
+ dbus_message_unref (message);
+
dbus_move_error (&_error, error);
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return -1.0f;
}
if (reply == NULL) {
- dbus_message_unref (message);
return -1.0f;
}
@@ -1666,13 +1652,11 @@ libhal_device_get_property_double (LibHalContext *ctx,
fprintf (stderr,
"%s %d : property '%s' for device '%s' is not "
"of type double\n", __FILE__, __LINE__, key, udi);
- dbus_message_unref (message);
dbus_message_unref (reply);
return -1.0f;
}
dbus_message_iter_get_basic (&reply_iter, &value);
- dbus_message_unref (message);
dbus_message_unref (reply);
return (double) value;
}
@@ -1720,13 +1704,13 @@ libhal_device_get_property_bool (LibHalContext *ctx,
message, -1,
&_error);
+ dbus_message_unref (message);
+
dbus_move_error (&_error, error);
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return FALSE;
}
if (reply == NULL) {
- dbus_message_unref (message);
return FALSE;
}
@@ -1738,13 +1722,11 @@ libhal_device_get_property_bool (LibHalContext *ctx,
fprintf (stderr,
"%s %d : property '%s' for device '%s' is not "
"of type bool\n", __FILE__, __LINE__, key, udi);
- dbus_message_unref (message);
dbus_message_unref (reply);
return FALSE;
}
dbus_message_iter_get_basic (&reply_iter, &value);
- dbus_message_unref (message);
dbus_message_unref (reply);
return value;
}
@@ -1830,17 +1812,16 @@ libhal_device_set_property_helper (LibHalContext *ctx,
reply = dbus_connection_send_with_reply_and_block (ctx->connection,
message, -1,
error);
+
+ dbus_message_unref (message);
+
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return FALSE;
}
-
if (reply == NULL) {
- dbus_message_unref (message);
return FALSE;
}
- dbus_message_unref (message);
dbus_message_unref (reply);
return TRUE;
@@ -2049,14 +2030,17 @@ libhal_device_property_strlist_append (LibHalContext *ctx,
reply = dbus_connection_send_with_reply_and_block (ctx->connection,
message, -1,
error);
+
+ dbus_message_unref (message);
+
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return FALSE;
}
if (reply == NULL) {
- dbus_message_unref (message);
return FALSE;
}
+
+ dbus_message_unref (reply);
return TRUE;
}
@@ -2104,14 +2088,17 @@ libhal_device_property_strlist_prepend (LibHalContext *ctx,
reply = dbus_connection_send_with_reply_and_block (ctx->connection,
message, -1,
error);
+
+ dbus_message_unref (message);
+
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return FALSE;
}
if (reply == NULL) {
- dbus_message_unref (message);
return FALSE;
}
+
+ dbus_message_unref (reply);
return TRUE;
}
@@ -2159,14 +2146,17 @@ libhal_device_property_strlist_remove_index (LibHalContext *ctx,
reply = dbus_connection_send_with_reply_and_block (ctx->connection,
message, -1,
error);
+
+ dbus_message_unref (message);
+
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return FALSE;
}
if (reply == NULL) {
- dbus_message_unref (message);
return FALSE;
}
+
+ dbus_message_unref (reply);
return TRUE;
}
@@ -2213,14 +2203,17 @@ libhal_device_property_strlist_remove (LibHalContext *ctx,
reply = dbus_connection_send_with_reply_and_block (ctx->connection,
message, -1,
error);
+
+ dbus_message_unref (message);
+
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return FALSE;
}
if (reply == NULL) {
- dbus_message_unref (message);
return FALSE;
}
+
+ dbus_message_unref (reply);
return TRUE;
}
@@ -2273,6 +2266,8 @@ libhal_device_lock (LibHalContext *ctx,
message, -1,
error);
+ dbus_message_unref (message);
+
if (error != NULL && dbus_error_is_set (error)) {
if (strcmp (error->name,
"org.freedesktop.Hal.DeviceAlreadyLocked") == 0) {
@@ -2283,12 +2278,8 @@ libhal_device_lock (LibHalContext *ctx,
}
}
- dbus_message_unref (message);
return FALSE;
}
-
- dbus_message_unref (message);
-
if (reply == NULL)
return FALSE;
@@ -2335,13 +2326,11 @@ libhal_device_unlock (LibHalContext *ctx,
message, -1,
error);
+ dbus_message_unref (message);
+
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return FALSE;
}
-
- dbus_message_unref (message);
-
if (reply == NULL)
return FALSE;
@@ -2390,12 +2379,13 @@ libhal_new_device (LibHalContext *ctx, DBusError *error)
reply = dbus_connection_send_with_reply_and_block (ctx->connection,
message, -1,
error);
+
+ dbus_message_unref (message);
+
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return NULL;
}
if (reply == NULL) {
- dbus_message_unref (message);
return NULL;
}
@@ -2406,7 +2396,6 @@ libhal_new_device (LibHalContext *ctx, DBusError *error)
fprintf (stderr,
"%s %d : expected a string in reply to NewDevice\n",
__FILE__, __LINE__);
- dbus_message_unref (message);
dbus_message_unref (reply);
return NULL;
}
@@ -2418,7 +2407,6 @@ libhal_new_device (LibHalContext *ctx, DBusError *error)
__FILE__, __LINE__);
}
- dbus_message_unref (message);
dbus_message_unref (reply);
return value;
}
@@ -2475,16 +2463,16 @@ libhal_device_commit_to_gdl (LibHalContext *ctx,
reply = dbus_connection_send_with_reply_and_block (ctx->connection,
message, -1,
error);
+
+ dbus_message_unref (message);
+
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return FALSE;
}
if (reply == NULL) {
- dbus_message_unref (message);
return FALSE;
}
- dbus_message_unref (message);
dbus_message_unref (reply);
return TRUE;
}
@@ -2532,16 +2520,16 @@ libhal_remove_device (LibHalContext *ctx, const char *udi, DBusError *error)
reply = dbus_connection_send_with_reply_and_block (ctx->connection,
message, -1,
error);
+
+ dbus_message_unref (message);
+
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return FALSE;
}
if (reply == NULL) {
- dbus_message_unref (message);
return FALSE;
}
- dbus_message_unref (message);
dbus_message_unref (reply);
return TRUE;
}
@@ -2587,13 +2575,13 @@ libhal_device_exists (LibHalContext *ctx, const char *udi, DBusError *error)
message, -1,
&_error);
+ dbus_message_unref (message);
+
dbus_move_error (&_error, error);
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return FALSE;
}
if (reply == NULL) {
- dbus_message_unref (message);
return FALSE;
}
@@ -2604,14 +2592,12 @@ libhal_device_exists (LibHalContext *ctx, const char *udi, DBusError *error)
fprintf (stderr,
"%s %d : expected a bool in reply to DeviceExists\n",
__FILE__, __LINE__);
- dbus_message_unref (message);
dbus_message_unref (reply);
return FALSE;
}
dbus_message_iter_get_basic (&reply_iter, &value);
- dbus_message_unref (message);
dbus_message_unref (reply);
return value;
}
@@ -2659,13 +2645,13 @@ libhal_device_property_exists (LibHalContext *ctx,
message, -1,
&_error);
+ dbus_message_unref (message);
+
dbus_move_error (&_error, error);
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return FALSE;
}
if (reply == NULL) {
- dbus_message_unref (message);
return FALSE;
}
@@ -2675,14 +2661,12 @@ libhal_device_property_exists (LibHalContext *ctx,
if (dbus_message_iter_get_arg_type (&reply_iter) != DBUS_TYPE_BOOLEAN) {
fprintf (stderr, "%s %d : expected a bool in reply to "
"PropertyExists\n", __FILE__, __LINE__);
- dbus_message_unref (message);
dbus_message_unref (reply);
return FALSE;
}
dbus_message_iter_get_basic (&reply_iter, &value);
- dbus_message_unref (message);
dbus_message_unref (reply);
return value;
}
@@ -2729,16 +2713,16 @@ libhal_merge_properties (LibHalContext *ctx,
reply = dbus_connection_send_with_reply_and_block (ctx->connection,
message, -1,
error);
+
+ dbus_message_unref (message);
+
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return FALSE;
}
if (reply == NULL) {
- dbus_message_unref (message);
return FALSE;
}
- dbus_message_unref (message);
dbus_message_unref (reply);
return TRUE;
}
@@ -2801,13 +2785,13 @@ libhal_device_matches (LibHalContext *ctx,
message, -1,
&_error);
+ dbus_message_unref (message);
+
dbus_move_error (&_error, error);
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return FALSE;
}
if (reply == NULL) {
- dbus_message_unref (message);
return FALSE;
}
/* now analyse reply */
@@ -2817,14 +2801,12 @@ libhal_device_matches (LibHalContext *ctx,
fprintf (stderr,
"%s %d : expected a bool in reply to DeviceMatches\n",
__FILE__, __LINE__);
- dbus_message_unref (message);
dbus_message_unref (reply);
return FALSE;
}
dbus_message_iter_get_basic (&reply_iter, &value);
- dbus_message_unref (message);
dbus_message_unref (reply);
return value;
}
@@ -2958,13 +2940,13 @@ libhal_manager_find_device_string_match (LibHalContext *ctx,
message, -1,
&_error);
+ dbus_message_unref (message);
+
dbus_move_error (&_error, error);
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return NULL;
}
if (reply == NULL) {
- dbus_message_unref (message);
return NULL;
}
/* now analyse reply */
@@ -2980,8 +2962,6 @@ libhal_manager_find_device_string_match (LibHalContext *ctx,
hal_device_names = libhal_get_string_array_from_iter (&iter_array, num_devices);
dbus_message_unref (reply);
- dbus_message_unref (message);
-
return hal_device_names;
}
@@ -3026,18 +3006,17 @@ libhal_device_add_capability (LibHalContext *ctx,
reply = dbus_connection_send_with_reply_and_block (ctx->connection,
message, -1,
error);
+
+ dbus_message_unref (message);
+
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return FALSE;
}
-
if (reply == NULL) {
- dbus_message_unref (message);
return FALSE;
}
dbus_message_unref (reply);
- dbus_message_unref (message);
return TRUE;
}
@@ -3122,14 +3101,14 @@ libhal_find_device_by_capability (LibHalContext *ctx,
reply = dbus_connection_send_with_reply_and_block (ctx->connection,
message, -1,
&_error);
-
+
+ dbus_message_unref (message);
+
dbus_move_error (&_error, error);
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return NULL;
}
if (reply == NULL) {
- dbus_message_unref (message);
return NULL;
}
/* now analyse reply */
@@ -3145,8 +3124,6 @@ libhal_find_device_by_capability (LibHalContext *ctx,
hal_device_names = libhal_get_string_array_from_iter (&iter_array, num_devices);
dbus_message_unref (reply);
- dbus_message_unref (message);
-
return hal_device_names;
}
@@ -3687,20 +3664,17 @@ libhal_device_rescan (LibHalContext *ctx, const char *udi, DBusError *error)
message, -1,
error);
+ dbus_message_unref (message);
+
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return FALSE;
}
-
- dbus_message_unref (message);
-
if (reply == NULL)
return FALSE;
dbus_message_iter_init (reply, &reply_iter);
if (dbus_message_iter_get_arg_type (&reply_iter) !=
DBUS_TYPE_BOOLEAN) {
- dbus_message_unref (message);
dbus_message_unref (reply);
return FALSE;
}
@@ -3748,20 +3722,17 @@ libhal_device_reprobe (LibHalContext *ctx, const char *udi, DBusError *error)
message, -1,
error);
+ dbus_message_unref (message);
+
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return FALSE;
}
-
- dbus_message_unref (message);
-
if (reply == NULL)
return FALSE;
dbus_message_iter_init (reply, &reply_iter);
if (dbus_message_iter_get_arg_type (&reply_iter) !=
DBUS_TYPE_BOOLEAN) {
- dbus_message_unref (message);
dbus_message_unref (reply);
return FALSE;
}
@@ -3821,16 +3792,15 @@ dbus_bool_t libhal_device_emit_condition (LibHalContext *ctx,
message, -1,
error);
+ dbus_message_unref (message);
+
if (error != NULL && dbus_error_is_set (error)) {
fprintf (stderr,
"%s %d : Failure sending D-BUS message: %s: %s\n",
__FILE__, __LINE__, error->name, error->message);
- dbus_message_unref (message);
return FALSE;
}
- dbus_message_unref (message);
-
if (reply == NULL) {
fprintf (stderr,
"%s %d : Got no reply\n",
@@ -3841,7 +3811,6 @@ dbus_bool_t libhal_device_emit_condition (LibHalContext *ctx,
dbus_message_iter_init (reply, &reply_iter);
if (dbus_message_iter_get_arg_type (&reply_iter) !=
DBUS_TYPE_BOOLEAN) {
- dbus_message_unref (message);
dbus_message_unref (reply);
fprintf (stderr,
"%s %d : Malformed reply\n",
@@ -3892,13 +3861,11 @@ addon_is_ready(LibHalContext *ctx, const char *identifier,
message, -1,
error);
+ dbus_message_unref (message);
+
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return FALSE;
}
-
- dbus_message_unref (message);
-
if (reply == NULL)
return FALSE;
@@ -4001,20 +3968,17 @@ libhal_device_claim_interface (LibHalContext *ctx,
message, -1,
error);
+ dbus_message_unref (message);
+
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return FALSE;
}
-
- dbus_message_unref (message);
-
if (reply == NULL)
return FALSE;
dbus_message_iter_init (reply, &reply_iter);
if (dbus_message_iter_get_arg_type (&reply_iter) !=
DBUS_TYPE_BOOLEAN) {
- dbus_message_unref (message);
dbus_message_unref (reply);
return FALSE;
}
@@ -4449,21 +4413,21 @@ libhal_device_commit_changeset (LibHalContext *ctx, LibHalChangeSet *changeset,
message, -1,
&_error);
+ dbus_message_unref (message);
+
dbus_move_error (&_error, error);
if (error != NULL && dbus_error_is_set (error)) {
fprintf (stderr,
"%s %d : %s\n",
__FILE__, __LINE__, error->message);
- dbus_message_unref (message);
return FALSE;
}
-
if (reply == NULL) {
- dbus_message_unref (message);
return FALSE;
}
+ dbus_message_unref (reply);
return TRUE;
}
@@ -4555,13 +4519,11 @@ libhal_device_acquire_interface_lock (LibHalContext *ctx,
message, -1,
error);
+ dbus_message_unref (message);
+
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return FALSE;
}
-
- dbus_message_unref (message);
-
if (reply == NULL)
return FALSE;
@@ -4612,13 +4574,11 @@ dbus_bool_t libhal_device_release_interface_lock (LibHalContext *ctx,
message, -1,
error);
+ dbus_message_unref (message);
+
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return FALSE;
}
-
- dbus_message_unref (message);
-
if (reply == NULL)
return FALSE;
@@ -4669,13 +4629,11 @@ dbus_bool_t libhal_acquire_global_interface_lock (LibHalContext *ctx,
message, -1,
error);
+ dbus_message_unref (message);
+
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return FALSE;
}
-
- dbus_message_unref (message);
-
if (reply == NULL)
return FALSE;
@@ -4723,13 +4681,11 @@ dbus_bool_t libhal_release_global_interface_lock (LibHalContext *ctx,
message, -1,
error);
+ dbus_message_unref (message);
+
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return FALSE;
}
-
- dbus_message_unref (message);
-
if (reply == NULL)
return FALSE;
@@ -4789,20 +4745,17 @@ libhal_device_is_caller_locked_out (LibHalContext *ctx,
message, -1,
error);
+ dbus_message_unref (message);
+
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return TRUE;
}
-
- dbus_message_unref (message);
-
if (reply == NULL)
return TRUE;
/* now analyze reply */
dbus_message_iter_init (reply, &reply_iter);
if (dbus_message_iter_get_arg_type (&reply_iter) != DBUS_TYPE_BOOLEAN) {
- dbus_message_unref (message);
dbus_message_unref (reply);
return TRUE;
}
@@ -4929,20 +4882,17 @@ libhal_device_is_locked_by_others (LibHalContext *ctx,
message, -1,
error);
+ dbus_message_unref (message);
+
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return TRUE;
}
-
- dbus_message_unref (message);
-
if (reply == NULL)
return TRUE;
/* now analyze reply */
dbus_message_iter_init (reply, &reply_iter);
if (dbus_message_iter_get_arg_type (&reply_iter) != DBUS_TYPE_BOOLEAN) {
- dbus_message_unref (message);
dbus_message_unref (reply);
return TRUE;
}
@@ -5007,20 +4957,17 @@ libhal_device_is_caller_privileged (LibHalContext *ctx,
message, -1,
error);
+ dbus_message_unref (message);
+
if (error != NULL && dbus_error_is_set (error)) {
- dbus_message_unref (message);
return NULL;
}
-
- dbus_message_unref (message);
-
if (reply == NULL)
return NULL;
/* now analyze reply */
dbus_message_iter_init (reply, &reply_iter);
if (dbus_message_iter_get_arg_type (&reply_iter) != DBUS_TYPE_STRING) {
- dbus_message_unref (message);
dbus_message_unref (reply);
return NULL;
}
--
1.5.3.5
More information about the hal
mailing list