From 35a9a5a69e9faa285d35c46751e97b52e79c1a11 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Tue, 20 Aug 2013 15:27:40 +0800 Subject: [PATCH 08/10] Cleanup: remove temporary error --- bus/bus.c | 12 +++--------- bus/dispatch.c | 12 ++---------- dbus/dbus-internals.c | 24 ++++++------------------ dbus/dbus-transport.c | 24 +++++++++--------------- 4 files changed, 20 insertions(+), 52 deletions(-) diff --git a/bus/bus.c b/bus/bus.c index 307c158..ca25d20 100644 --- a/bus/bus.c +++ b/bus/bus.c @@ -1485,18 +1485,12 @@ bus_context_check_security_policy (BusContext *context, if (proposed_recipient != NULL /* not to the bus driver */ && addressed_recipient == proposed_recipient /* not eavesdropping */) { - DBusError error2; - - dbus_error_init (&error2); requested_reply = bus_connections_check_reply (bus_connection_get_connections (sender), transaction, sender, addressed_recipient, message, - &error2); - if (dbus_error_is_set (&error2)) - { - dbus_move_error (&error2, error); - return FALSE; - } + error); + if (dbus_error_is_set (error)) + return FALSE; } } } diff --git a/bus/dispatch.c b/bus/dispatch.c index 72d228a..a1c3c66 100644 --- a/bus/dispatch.c +++ b/bus/dispatch.c @@ -85,7 +85,6 @@ bus_dispatch_matches (BusTransaction *transaction, DBusMessage *message, DBusError *error) { - DBusError tmp_error; BusConnections *connections; DBusList *recipients; BusMatchmaker *matchmaker; @@ -133,7 +132,6 @@ bus_dispatch_matches (BusTransaction *transaction, /* Now dispatch to others who look interested in this message */ connections = bus_transaction_get_connections (transaction); - dbus_error_init (&tmp_error); matchmaker = bus_context_get_matchmaker (context); recipients = NULL; @@ -153,7 +151,7 @@ bus_dispatch_matches (BusTransaction *transaction, dest = link->data; if (!send_one_message (dest, context, sender, addressed_recipient, - message, transaction, &tmp_error)) + message, transaction, error)) break; link = _dbus_list_get_next_link (&recipients, link); @@ -161,13 +159,7 @@ bus_dispatch_matches (BusTransaction *transaction, _dbus_list_clear (&recipients); - if (dbus_error_is_set (&tmp_error)) - { - dbus_move_error (&tmp_error, error); - return FALSE; - } - else - return TRUE; + return !dbus_error_is_set (error); } static DBusHandlerResult diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c index 257f1d4..996d961 100644 --- a/dbus/dbus-internals.c +++ b/dbus/dbus-internals.c @@ -805,31 +805,19 @@ _dbus_read_uuid_file (const DBusString *filename, dbus_bool_t create_if_not_found, DBusError *error) { - DBusError read_error = DBUS_ERROR_INIT; - - if (_dbus_read_uuid_file_without_creating (filename, uuid, &read_error)) + if (_dbus_read_uuid_file_without_creating (filename, uuid, error)) return TRUE; - if (!create_if_not_found) - { - dbus_move_error (&read_error, error); - return FALSE; - } - /* If the file exists and contains junk, we want to keep that error * message instead of overwriting it with a "file exists" error * message when we try to write */ - if (dbus_error_has_name (&read_error, DBUS_ERROR_INVALID_FILE_CONTENT)) - { - dbus_move_error (&read_error, error); + if (!create_if_not_found || + dbus_error_has_name (error, DBUS_ERROR_INVALID_FILE_CONTENT)) return FALSE; - } - else - { - dbus_error_free (&read_error); - return _dbus_create_uuid_file_exclusively (filename, uuid, error); - } + + dbus_error_free (error); + return _dbus_create_uuid_file_exclusively (filename, uuid, error); } /* Protected by _DBUS_LOCK (machine_uuid) */ diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c index fff76cc..a98c408 100644 --- a/dbus/dbus-transport.c +++ b/dbus/dbus-transport.c @@ -369,7 +369,6 @@ _dbus_transport_open (DBusAddressEntry *entry, const char *expected_guid_orig; char *expected_guid; int i; - DBusError tmp_error = DBUS_ERROR_INIT; _DBUS_ASSERT_ERROR_IS_CLEAR (error); @@ -387,27 +386,24 @@ _dbus_transport_open (DBusAddressEntry *entry, { DBusTransportOpenResult result; - _DBUS_ASSERT_ERROR_IS_CLEAR (&tmp_error); - result = (* open_funcs[i].func) (entry, &transport, &tmp_error); + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + result = (* open_funcs[i].func) (entry, &transport, error); switch (result) { case DBUS_TRANSPORT_OPEN_OK: - _DBUS_ASSERT_ERROR_IS_CLEAR (&tmp_error); + _DBUS_ASSERT_ERROR_IS_CLEAR (error); goto out; - break; case DBUS_TRANSPORT_OPEN_NOT_HANDLED: - _DBUS_ASSERT_ERROR_IS_CLEAR (&tmp_error); + _DBUS_ASSERT_ERROR_IS_CLEAR (error); /* keep going through the loop of open funcs */ break; case DBUS_TRANSPORT_OPEN_BAD_ADDRESS: - _DBUS_ASSERT_ERROR_IS_SET (&tmp_error); + _DBUS_ASSERT_ERROR_IS_SET (error); goto out; - break; case DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT: - _DBUS_ASSERT_ERROR_IS_SET (&tmp_error); + _DBUS_ASSERT_ERROR_IS_SET (error); goto out; - break; } } @@ -415,18 +411,16 @@ _dbus_transport_open (DBusAddressEntry *entry, if (transport == NULL) { - if (!dbus_error_is_set (&tmp_error)) - _dbus_set_bad_address (&tmp_error, + if (!dbus_error_is_set (error)) + _dbus_set_bad_address (error, NULL, NULL, "Unknown address type (examples of valid types are \"tcp\" and on UNIX \"unix\")"); - _DBUS_ASSERT_ERROR_IS_SET (&tmp_error); - dbus_move_error(&tmp_error, error); dbus_free (expected_guid); } else { - _DBUS_ASSERT_ERROR_IS_CLEAR (&tmp_error); + _DBUS_ASSERT_ERROR_IS_CLEAR (error); /* In the case of autostart the initial guid is NULL * and the autostart transport recursively calls -- 1.7.9.5