From bf2a1b169fd3964d6a2a4b8c53658a0c05a5966b Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 5 Aug 2011 13:20:16 +0100 Subject: Remove more never-used variables --- bus/test.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'bus') diff --git a/bus/test.c b/bus/test.c index 049fae6f..e1b8a130 100644 --- a/bus/test.c +++ b/bus/test.c @@ -40,8 +40,6 @@ static dbus_bool_t add_client_watch (DBusWatch *watch, void *data) { - DBusConnection *connection = data; - return _dbus_loop_add_watch (client_loop, watch); } @@ -49,8 +47,6 @@ static void remove_client_watch (DBusWatch *watch, void *data) { - DBusConnection *connection = data; - _dbus_loop_remove_watch (client_loop, watch); } @@ -58,8 +54,6 @@ static dbus_bool_t add_client_timeout (DBusTimeout *timeout, void *data) { - DBusConnection *connection = data; - return _dbus_loop_add_timeout (client_loop, timeout); } @@ -67,8 +61,6 @@ static void remove_client_timeout (DBusTimeout *timeout, void *data) { - DBusConnection *connection = data; - _dbus_loop_remove_timeout (client_loop, timeout); } -- cgit v1.2.3 From e91bbcbcb4e9b86415bf09c1e212c9d635873910 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 5 Aug 2011 13:20:31 +0100 Subject: Remove a never-used callback --- bus/connection.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'bus') diff --git a/bus/connection.c b/bus/connection.c index 81f595d2..166d5a74 100644 --- a/bus/connection.c +++ b/bus/connection.c @@ -403,14 +403,6 @@ free_connection_data (void *data) dbus_free (d); } -static void -call_timeout_callback (DBusTimeout *timeout, - void *data) -{ - /* can return FALSE on OOM but we just let it fire again later */ - dbus_timeout_handle (timeout); -} - BusConnections* bus_connections_new (BusContext *context) { -- cgit v1.2.3 From eaa1f2574629425c0e66225d5e387734cde087c6 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 5 Aug 2011 13:22:18 +0100 Subject: bus_registry_acquire_service: remove unnecessary variable --- bus/services.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'bus') diff --git a/bus/services.c b/bus/services.c index 0a049257..68a7022a 100644 --- a/bus/services.c +++ b/bus/services.c @@ -385,7 +385,6 @@ bus_registry_acquire_service (BusRegistry *registry, { dbus_bool_t retval; DBusConnection *old_owner_conn; - DBusConnection *current_owner_conn; BusClientPolicy *policy; BusService *service; BusActivation *activation; @@ -510,12 +509,10 @@ bus_registry_acquire_service (BusRegistry *registry, primary_owner = bus_service_get_primary_owner (service); if (primary_owner == NULL) goto out; - - current_owner_conn = primary_owner->conn; - + if (old_owner_conn == NULL) { - _dbus_assert (current_owner_conn == connection); + _dbus_assert (primary_owner->conn == connection); *result = DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER; } -- cgit v1.2.3 From 0d9a7a0f9762777fc72e02b2ab3406efda3b8e00 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 5 Aug 2011 13:22:46 +0100 Subject: activation helper: remove unused variable when not being verbose --- bus/activation-helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bus') diff --git a/bus/activation-helper.c b/bus/activation-helper.c index 7012227e..ab9d6010 100644 --- a/bus/activation-helper.c +++ b/bus/activation-helper.c @@ -144,10 +144,10 @@ out_all: static dbus_bool_t clear_environment (DBusError *error) { - const char *debug_env = NULL; const char *starter_env = NULL; - #ifdef DBUS_ENABLE_VERBOSE_MODE + const char *debug_env = NULL; + /* are we debugging */ debug_env = _dbus_getenv ("DBUS_VERBOSE"); #endif -- cgit v1.2.3 From 420c6840a3c133a189b59889f31b7a645ac43681 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 5 Aug 2011 13:23:49 +0100 Subject: bus_driver_handle_message: remove unused label --- bus/driver.c | 1 - 1 file changed, 1 deletion(-) (limited to 'bus') diff --git a/bus/driver.c b/bus/driver.c index 9ecfd55f..7554d331 100644 --- a/bus/driver.c +++ b/bus/driver.c @@ -2009,7 +2009,6 @@ bus_driver_handle_message (DBusConnection *connection, } } - unknown: _dbus_verbose ("No driver handler for message \"%s\"\n", name); -- cgit v1.2.3 From 2c1ad79c0c0ad3db7b469fc82176713daa06c478 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 5 Aug 2011 13:24:24 +0100 Subject: BusConnections: don't assert about BusConnectionData in functions that don't need it --- bus/connection.c | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'bus') diff --git a/bus/connection.c b/bus/connection.c index 166d5a74..26839529 100644 --- a/bus/connection.c +++ b/bus/connection.c @@ -830,12 +830,7 @@ bus_connection_get_unix_groups (DBusConnection *connection, int *n_groups, DBusError *error) { - BusConnectionData *d; unsigned long uid; - - d = BUS_CONNECTION_DATA (connection); - - _dbus_assert (d != NULL); *groups = NULL; *n_groups = 0; @@ -1451,13 +1446,7 @@ bus_connections_check_limits (BusConnections *connections, DBusConnection *requesting_completion, DBusError *error) { - BusConnectionData *d; unsigned long uid; - - d = BUS_CONNECTION_DATA (requesting_completion); - _dbus_assert (d != NULL); - - _dbus_assert (d->name == NULL); if (connections->n_completed >= bus_context_get_max_completed_connections (connections->context)) -- cgit v1.2.3 From d1756a7e4cbb6ef83b70319ab72a49760f2c227e Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 5 Aug 2011 13:25:14 +0100 Subject: Fix an assortment of variables that aren't used when not checking/asserting --- bus/driver.c | 23 +++++++++++++++-------- dbus/dbus-connection.c | 3 ++- dbus/dbus-message.c | 5 +++++ dbus/dbus-string-private.h | 1 + 4 files changed, 23 insertions(+), 9 deletions(-) (limited to 'bus') diff --git a/bus/driver.c b/bus/driver.c index 7554d331..574e0f3d 100644 --- a/bus/driver.c +++ b/bus/driver.c @@ -827,7 +827,6 @@ bus_driver_handle_update_activation_environment (DBusConnection *connection, DBusMessageIter iter; DBusMessageIter dict_iter; DBusMessageIter dict_entry_iter; - int msg_type; int array_type; int key_type; DBusList *keys, *key_link; @@ -842,9 +841,13 @@ bus_driver_handle_update_activation_environment (DBusConnection *connection, /* The message signature has already been checked for us, * so let's just assert it's right. */ - msg_type = dbus_message_iter_get_arg_type (&iter); +#ifndef DBUS_DISABLE_ASSERT + { + int msg_type = dbus_message_iter_get_arg_type (&iter); - _dbus_assert (msg_type == DBUS_TYPE_ARRAY); + _dbus_assert (msg_type == DBUS_TYPE_ARRAY); + } +#endif dbus_message_iter_recurse (&iter, &dict_iter); @@ -1930,7 +1933,7 @@ bus_driver_handle_message (DBusConnection *connection, DBusMessage *message, DBusError *error) { - const char *name, *sender, *interface; + const char *name, *interface; const InterfaceHandler *ih; const MessageHandler *mh; dbus_bool_t found_interface = FALSE; @@ -1957,13 +1960,17 @@ bus_driver_handle_message (DBusConnection *connection, _dbus_assert (dbus_message_get_member (message) != NULL); name = dbus_message_get_member (message); - sender = dbus_message_get_sender (message); - _dbus_verbose ("Driver got a method call: %s\n", - dbus_message_get_member (message)); + _dbus_verbose ("Driver got a method call: %s\n", name); /* security checks should have kept this from getting here */ - _dbus_assert (sender != NULL || strcmp (name, "Hello") == 0); +#ifndef DBUS_DISABLE_ASSERT + { + const char *sender = dbus_message_get_sender (message); + + _dbus_assert (sender != NULL || strcmp (name, "Hello") == 0); + } +#endif for (ih = interface_handlers; ih->name != NULL; ih++) { diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index cb1da8c1..9128ffc7 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -3884,7 +3884,8 @@ dbus_connection_steal_borrowed_message (DBusConnection *connection, pop_message = _dbus_list_pop_first (&connection->incoming_messages); _dbus_assert (message == pop_message); - + (void) pop_message; /* unused unless asserting */ + connection->n_incoming -= 1; _dbus_verbose ("Incoming message %p stolen from queue, %d incoming\n", diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index cc1cfa17..0c7e80d6 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -2267,12 +2267,14 @@ dbus_message_iter_get_fixed_array (DBusMessageIter *iter, int *n_elements) { DBusMessageRealIter *real = (DBusMessageRealIter *)iter; +#ifndef DBUS_DISABLE_CHECKS int subtype = _dbus_type_reader_get_current_type(&real->u.reader); _dbus_return_if_fail (_dbus_message_iter_check (real)); _dbus_return_if_fail (value != NULL); _dbus_return_if_fail ((subtype == DBUS_TYPE_INVALID) || (dbus_type_is_fixed (subtype) && subtype != DBUS_TYPE_UNIX_FD)); +#endif _dbus_type_reader_read_fixed_multi (&real->u.reader, value, n_elements); @@ -2824,12 +2826,14 @@ dbus_message_iter_abandon_container (DBusMessageIter *iter, DBusMessageIter *sub) { DBusMessageRealIter *real = (DBusMessageRealIter *)iter; +#ifndef DBUS_DISABLE_CHECKS DBusMessageRealIter *real_sub = (DBusMessageRealIter *)sub; _dbus_return_if_fail (_dbus_message_iter_append_check (real)); _dbus_return_if_fail (real->iter_type == DBUS_MESSAGE_ITER_TYPE_WRITER); _dbus_return_if_fail (_dbus_message_iter_append_check (real_sub)); _dbus_return_if_fail (real_sub->iter_type == DBUS_MESSAGE_ITER_TYPE_WRITER); +#endif _dbus_message_iter_abandon_signature (real); } @@ -4701,6 +4705,7 @@ dbus_message_demarshal_bytes_needed(const char *buf, if (validity == DBUS_VALID) { _dbus_assert (have_message || (header_len + body_len) > len); + (void) have_message; /* unused unless asserting */ return header_len + body_len; } else diff --git a/dbus/dbus-string-private.h b/dbus/dbus-string-private.h index 2a4043a0..2e6de900 100644 --- a/dbus/dbus-string-private.h +++ b/dbus/dbus-string-private.h @@ -75,6 +75,7 @@ _DBUS_STATIC_ASSERT (sizeof (DBusRealString) == sizeof (DBusString)); */ #define DBUS_GENERIC_STRING_PREAMBLE(real) \ do { \ + (void) real; /* might be unused unless asserting */ \ _dbus_assert ((real) != NULL); \ _dbus_assert (!(real)->invalid); \ _dbus_assert ((real)->len >= 0); \ -- cgit v1.2.3 From 86b0ba0278f527143fe5785ca819e45b94937474 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 5 Aug 2011 13:40:44 +0100 Subject: Use {}, not semicolon, when the statement of an "if" does nothing The uses in bus/activation.c are also probably wrong because they ignore the result of the test, but that's orthogonal. () --- bus/activation.c | 8 ++++++-- dbus/dbus-spawn.c | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'bus') diff --git a/bus/activation.c b/bus/activation.c index 6101173f..dea62433 100644 --- a/bus/activation.c +++ b/bus/activation.c @@ -2535,14 +2535,18 @@ bus_activation_service_reload_test (const DBusString *test_data_dir) _dbus_assert_not_reached ("could not initiate service reload test"); if (!do_service_reload_test (&directory, FALSE)) - ; /* Do nothing? */ + { + /* Do nothing? */ + } /* Do OOM tests */ if (!init_service_reload_test (&directory)) _dbus_assert_not_reached ("could not initiate service reload test"); if (!do_service_reload_test (&directory, TRUE)) - ; /* Do nothing? */ + { + /* Do nothing? */ + } /* Cleanup test directory */ if (!cleanup_service_reload_test (&directory)) diff --git a/dbus/dbus-spawn.c b/dbus/dbus-spawn.c index a4652a3e..9f6be265 100644 --- a/dbus/dbus-spawn.c +++ b/dbus/dbus-spawn.c @@ -1103,7 +1103,9 @@ babysit (pid_t grandchild_pid, { char b; if (read (sigchld_pipe[READ_END], &b, 1) == -1) - /* ignore */; + { + /* ignore */ + } /* do waitpid check */ check_babysit_events (grandchild_pid, parent_pipe, 0); } -- cgit v1.2.3