diff --git a/bus/driver.c b/bus/driver.c index 23e75a2..bef02f6 100644 --- a/bus/driver.c +++ b/bus/driver.c @@ -1734,7 +1734,7 @@ bus_driver_handle_get_connection_credentials (DBusConnection *connection, /* use the GVariant bytestring convention for strings of unknown * encoding: include the \0 in the payload, for zero-copy reading */ if (!_dbus_asv_add_byte_array (&array_iter, "LinuxSecurityLabel", - s, strlen (s) + 1)) + s, (int) strlen (s) + 1)) { dbus_free (s); goto oom; diff --git a/bus/signals.c b/bus/signals.c index e8def9f..ff1e04b 100644 --- a/bus/signals.c +++ b/bus/signals.c @@ -70,7 +70,7 @@ bus_match_rule_new (DBusConnection *matches_go_to) #ifndef DBUS_ENABLE_EMBEDDED_TESTS _dbus_assert (rule->matches_go_to != NULL); #endif - + return rule; } @@ -116,7 +116,7 @@ bus_match_rule_unref (BusMatchRule *rule) dbus_free (rule->args); } - + dbus_free (rule); } } @@ -166,12 +166,12 @@ match_rule_to_string (BusMatchRule *rule) { DBusString str; char *ret; - + if (!_dbus_string_init (&str)) { return NULL; } - + if (rule->flags & BUS_MATCH_MESSAGE_TYPE) { if (!append_key_and_escaped_value (&str, "type", @@ -186,7 +186,7 @@ match_rule_to_string (BusMatchRule *rule) if (!_dbus_string_append (&str, ",")) goto nomem; } - + if (!append_key_and_escaped_value (&str, "interface", rule->interface)) goto nomem; } @@ -198,7 +198,7 @@ match_rule_to_string (BusMatchRule *rule) if (!_dbus_string_append (&str, ",")) goto nomem; } - + if (!append_key_and_escaped_value (&str, "member", rule->member)) goto nomem; } @@ -210,7 +210,7 @@ match_rule_to_string (BusMatchRule *rule) if (!_dbus_string_append (&str, ",")) goto nomem; } - + if (!append_key_and_escaped_value (&str, "path", rule->path)) goto nomem; } @@ -234,7 +234,7 @@ match_rule_to_string (BusMatchRule *rule) if (!_dbus_string_append (&str, ",")) goto nomem; } - + if (!append_key_and_escaped_value (&str, "sender", rule->sender)) goto nomem; } @@ -246,7 +246,7 @@ match_rule_to_string (BusMatchRule *rule) if (!_dbus_string_append (&str, ",")) goto nomem; } - + if (!append_key_and_escaped_value (&str, "destination", rule->destination)) goto nomem; } @@ -268,7 +268,7 @@ match_rule_to_string (BusMatchRule *rule) if (rule->flags & BUS_MATCH_ARGS) { int i; - + _dbus_assert (rule->args != NULL); i = 0; @@ -286,7 +286,7 @@ match_rule_to_string (BusMatchRule *rule) is_path = (rule->arg_lens[i] & BUS_MATCH_ARG_IS_PATH) != 0; is_namespace = (rule->arg_lens[i] & BUS_MATCH_ARG_NAMESPACE) != 0; - + if (!_dbus_string_append_printf (&str, "arg%d%s", i, @@ -296,17 +296,17 @@ match_rule_to_string (BusMatchRule *rule) if (!append_key_and_escaped_value (&str, "", rule->args[i])) goto nomem; } - + ++i; } } - + if (!_dbus_string_steal_data (&str, &ret)) goto nomem; _dbus_string_free (&str); return ret; - + nomem: _dbus_string_free (&str); return NULL; @@ -482,7 +482,7 @@ bus_match_rule_set_arg (BusMatchRule *rule, new_args[i] = NULL; ++i; } - + rule->args = new_args; /* and now add to the lengths */ @@ -542,7 +542,7 @@ find_key (const DBusString *str, const char *key_end; _DBUS_ASSERT_ERROR_IS_CLEAR (error); - + s = _dbus_string_get_const_data (str); p = s + start; @@ -559,7 +559,7 @@ find_key (const DBusString *str, while (*p && ISWHITE (*p)) ++p; - + if (key_start == key_end) { /* Empty match rules or trailing whitespace are OK */ @@ -574,7 +574,7 @@ find_key (const DBusString *str, return FALSE; } ++p; - + if (!_dbus_string_append_len (key, key_start, key_end - key_start)) { BUS_SET_OOM (error); @@ -582,7 +582,7 @@ find_key (const DBusString *str, } *value_pos = p - s; - + return TRUE; } @@ -600,9 +600,9 @@ find_value (const DBusString *str, int orig_len; _DBUS_ASSERT_ERROR_IS_CLEAR (error); - + orig_len = _dbus_string_get_length (value); - + s = _dbus_string_get_const_data (str); p = s + start; @@ -621,7 +621,7 @@ find_value (const DBusString *str, case '\'': quote_char = '\''; goto next; - + case ',': ++p; goto done; @@ -629,7 +629,7 @@ find_value (const DBusString *str, case '\\': quote_char = '\\'; goto next; - + default: if (!_dbus_string_append_byte (value, *p)) { @@ -655,7 +655,7 @@ find_value (const DBusString *str, BUS_SET_OOM (error); goto failed; } - + quote_char = '\0'; } else @@ -700,9 +700,9 @@ find_value (const DBusString *str, _dbus_assert (quote_char == '\0'); /* Zero-length values are allowed */ - + *value_end = p - s; - + return TRUE; failed: @@ -730,7 +730,7 @@ typedef struct static dbus_bool_t tokenize_rule (const DBusString *rule_text, RuleToken tokens[MAX_RULE_TOKENS], - DBusError *error) + DBusError *error) { int i; int pos; @@ -739,7 +739,7 @@ tokenize_rule (const DBusString *rule_text, dbus_bool_t retval; retval = FALSE; - + if (!_dbus_string_init (&key)) { BUS_SET_OOM (error); @@ -766,7 +766,7 @@ tokenize_rule (const DBusString *rule_text, if (_dbus_string_get_length (&key) == 0) goto next; - + if (!_dbus_string_steal_data (&key, &tokens[i].key)) { BUS_SET_OOM (error); @@ -787,7 +787,7 @@ tokenize_rule (const DBusString *rule_text, } retval = TRUE; - + out: if (!retval) { @@ -801,10 +801,10 @@ tokenize_rule (const DBusString *rule_text, ++i; } } - + _dbus_string_free (&key); _dbus_string_free (&value); - + return retval; } @@ -826,7 +826,7 @@ bus_match_rule_parse_arg_match (BusMatchRule *rule, * if we wanted, which would specify another type, in which case * arg0='5' would have the 5 parsed as an int rather than string. */ - + /* First we need to parse arg0 = 0, arg27 = 27 */ _dbus_string_init_const (&key_str, key); @@ -848,7 +848,7 @@ bus_match_rule_parse_arg_match (BusMatchRule *rule, if (end != length) { - int len1 = strlen ("path"); + int len1 = (int) strlen ("path"); if ((end + len1) == length && _dbus_string_ends_with_c_str (&key_str, "path")) { @@ -883,7 +883,7 @@ bus_match_rule_parse_arg_match (BusMatchRule *rule, "Key '%s' in match rule has arg number %lu but the maximum is %d.\n", key, (unsigned long) arg, DBUS_MAXIMUM_MATCH_RULE_ARG_NUMBER); goto failed; } - + if ((rule->flags & BUS_MATCH_ARGS) && rule->args_len > (int) arg && rule->args[arg] != NULL) @@ -892,7 +892,7 @@ bus_match_rule_parse_arg_match (BusMatchRule *rule, "Argument %d matched more than once in match rule\n", key); goto failed; } - + if (!bus_match_rule_set_arg (rule, arg, value, is_path, is_namespace)) { BUS_SET_OOM (error); @@ -922,7 +922,7 @@ bus_match_rule_parse (DBusConnection *matches_go_to, BusMatchRule *rule; RuleToken tokens[MAX_RULE_TOKENS+1]; /* NULL termination + 1 */ int i; - + _DBUS_ASSERT_ERROR_IS_CLEAR (error); if (_dbus_string_get_length (rule_text) > DBUS_MAXIMUM_MATCH_RULE_LENGTH) @@ -933,19 +933,19 @@ bus_match_rule_parse (DBusConnection *matches_go_to, DBUS_MAXIMUM_MATCH_RULE_LENGTH); return NULL; } - + memset (tokens, '\0', sizeof (tokens)); - + rule = bus_match_rule_new (matches_go_to); if (rule == NULL) { BUS_SET_OOM (error); goto failed; } - + if (!tokenize_rule (rule_text, tokens, error)) goto failed; - + i = 0; while (tokens[i].key != NULL) { @@ -953,7 +953,7 @@ bus_match_rule_parse (DBusConnection *matches_go_to, int len; const char *key = tokens[i].key; const char *value = tokens[i].value; - + _dbus_string_init_const (&tmp_str, value); len = _dbus_string_get_length (&tmp_str); @@ -967,9 +967,9 @@ bus_match_rule_parse (DBusConnection *matches_go_to, "Key %s specified twice in match rule\n", key); goto failed; } - + t = dbus_message_type_from_string (value); - + if (t == DBUS_MESSAGE_TYPE_INVALID) { dbus_set_error (error, DBUS_ERROR_MATCH_RULE_INVALID, @@ -1136,10 +1136,10 @@ bus_match_rule_parse (DBusConnection *matches_go_to, ++i; } - + goto out; - + failed: _DBUS_ASSERT_ERROR_IS_SET (error); if (rule) @@ -1149,7 +1149,7 @@ bus_match_rule_parse (DBusConnection *matches_go_to, } out: - + i = 0; while (tokens[i].key || tokens[i].value) { @@ -1158,7 +1158,7 @@ bus_match_rule_parse (DBusConnection *matches_go_to, dbus_free (tokens[i].value); ++i; } - + return rule; } @@ -1473,7 +1473,7 @@ bus_matchmaker_add_rule (BusMatchmaker *matchmaker, dbus_free (s); } #endif - + return TRUE; } @@ -1517,10 +1517,10 @@ match_rule_equal (BusMatchRule *a, if (a->flags & BUS_MATCH_ARGS) { int i; - + if (a->args_len != b->args_len) return FALSE; - + i = 0; while (i < a->args_len) { @@ -1540,11 +1540,11 @@ match_rule_equal (BusMatchRule *a, if (memcmp (a->args[i], b->args[i], length) != 0) return FALSE; } - + ++i; } } - + return TRUE; } @@ -1553,7 +1553,7 @@ bus_matchmaker_remove_rule_link (DBusList **rules, DBusList *link) { BusMatchRule *rule = link->data; - + bus_connection_remove_match_rule (rule->matches_go_to, rule); _dbus_list_remove_link (rules, link); @@ -1566,8 +1566,8 @@ bus_matchmaker_remove_rule_link (DBusList **rules, dbus_free (s); } #endif - - bus_match_rule_unref (rule); + + bus_match_rule_unref (rule); } void @@ -1603,7 +1603,7 @@ bus_matchmaker_remove_rule (BusMatchmaker *matchmaker, dbus_free (s); } #endif - + bus_match_rule_unref (rule); } @@ -1751,7 +1751,7 @@ connection_is_primary_owner (DBusConnection *connection, BusRegistry *registry; _dbus_assert (connection != NULL); - + registry = bus_connection_get_registry (connection); _dbus_string_init_const (&str, service_name); @@ -1887,7 +1887,7 @@ match_rule_matches (BusMatchRule *rule, return FALSE; if (addressed_recipient == NULL) - { + { if (strcmp (rule->destination, DBUS_SERVICE_DBUS) != 0) return FALSE; @@ -1940,7 +1940,7 @@ match_rule_matches (BusMatchRule *rule, if (!str_has_prefix (path, rule->path)) return FALSE; - len = strlen (rule->path); + len = (int) strlen (rule->path); /* Check that the actual argument is within the expected * namespace, rather than just starting with that string, @@ -1958,11 +1958,11 @@ match_rule_matches (BusMatchRule *rule, { int i; DBusMessageIter iter; - + _dbus_assert (rule->args != NULL); dbus_message_iter_init (message, &iter); - + i = 0; while (i < rule->args_len) { @@ -1975,7 +1975,7 @@ match_rule_matches (BusMatchRule *rule, expected_length = rule->arg_lens[i] & ~BUS_MATCH_ARG_FLAGS; is_path = (rule->arg_lens[i] & BUS_MATCH_ARG_IS_PATH) != 0; is_namespace = (rule->arg_lens[i] & BUS_MATCH_ARG_NAMESPACE) != 0; - + current_type = dbus_message_iter_get_arg_type (&iter); if (expected_arg != NULL) @@ -1991,7 +1991,7 @@ match_rule_matches (BusMatchRule *rule, dbus_message_iter_get_basic (&iter, &actual_arg); _dbus_assert (actual_arg != NULL); - actual_length = strlen (actual_arg); + actual_length = (int) strlen (actual_arg); if (is_path) { @@ -2041,14 +2041,14 @@ match_rule_matches (BusMatchRule *rule, } } - + if (current_type != DBUS_TYPE_INVALID) dbus_message_iter_next (&iter); ++i; } } - + return TRUE; } @@ -2182,7 +2182,7 @@ check_parse (dbus_bool_t should_succeed, dbus_error_init (&error); _dbus_string_init_const (&str, text); - + rule = bus_match_rule_parse (NULL, &str, &error); if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY)) { @@ -2269,7 +2269,7 @@ test_parsing (void *data) _dbus_assert (strcmp (rule->interface, "org.Bar") == 0); _dbus_assert (strcmp (rule->path, "/foo") == 0); - + bus_match_rule_unref (rule); } @@ -2286,7 +2286,7 @@ test_parsing (void *data) bus_match_rule_unref (rule); } - + rule = check_parse (TRUE, "arg1='foo'"); if (rule != NULL) { @@ -2315,7 +2315,7 @@ test_parsing (void *data) bus_match_rule_unref (rule); } - + rule = check_parse (TRUE, "arg40='foo'"); if (rule != NULL) { @@ -2330,7 +2330,7 @@ test_parsing (void *data) bus_match_rule_unref (rule); } - + rule = check_parse (TRUE, "arg63='foo'"); if (rule != NULL) { @@ -2427,7 +2427,7 @@ test_parsing (void *data) _dbus_assert (rule == NULL); rule = check_parse (FALSE, "argument='foo'"); _dbus_assert (rule == NULL); - + /* Reject duplicates */ rule = check_parse (FALSE, "type='signal',type='method_call'"); _dbus_assert (rule == NULL); @@ -2457,7 +2457,7 @@ test_parsing (void *data) _dbus_assert (rule == NULL); rule = check_parse (FALSE, "arg30='foo',arg30='bar'"); _dbus_assert (rule == NULL); - + /* Reject broken keys */ rule = check_parse (FALSE, "blah='signal'"); _dbus_assert (rule == NULL); @@ -2475,7 +2475,7 @@ test_parsing (void *data) if (rule != NULL) { _dbus_assert (rule->flags == 0); - + bus_match_rule_unref (rule); } @@ -2484,14 +2484,14 @@ test_parsing (void *data) if (rule != NULL) { _dbus_assert (rule->flags == 0); - + bus_match_rule_unref (rule); } /* But with non-whitespace chars and no =value, it's not OK */ rule = check_parse (FALSE, "type"); _dbus_assert (rule == NULL); - + return TRUE; } @@ -2523,7 +2523,7 @@ static void test_equality (void) { int i; - + i = 0; while (i < _DBUS_N_ELEMENTS (equality_tests)) { @@ -2532,7 +2532,7 @@ test_equality (void) char *first_str, *second_str; BusMatchRule *first_reparsed, *second_reparsed; int j; - + first = check_parse (TRUE, equality_tests[i].first); _dbus_assert (first != NULL); second = check_parse (TRUE, equality_tests[i].second); @@ -2580,10 +2580,10 @@ test_equality (void) equality_tests[j].second); exit (1); } - + bus_match_rule_unref (second); } - + ++j; } @@ -2736,11 +2736,11 @@ test_matching (void) DBUS_TYPE_INT32, &v_INT32, NULL)) _dbus_assert_not_reached ("oom"); - + check_matching (message1, 1, should_match_message_1, should_not_match_message_1); - + dbus_message_unref (message1); message2 = dbus_message_new (DBUS_MESSAGE_TYPE_SIGNAL); diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index 8952b75..9fe15a1 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -4,7 +4,7 @@ * Copyright (C) 2002-2006 Red Hat Inc. * * Licensed under the Academic Free License version 2.1 - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -14,7 +14,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA @@ -96,7 +96,7 @@ * The other application may be a message bus; for convenience, the * function dbus_bus_get() is provided to automatically open a * connection to the well-known message buses. - * + * * In brief a DBusConnection is a message queue associated with some * message transport mechanism such as a socket. The connection * maintains a queue of incoming messages and a queue of outgoing @@ -118,17 +118,17 @@ * The connection provides #DBusWatch and #DBusTimeout objects to * the main loop. These are used to know when reading, writing, or * dispatching should be performed. - * + * * Incoming messages are processed * by calling dbus_connection_dispatch(). dbus_connection_dispatch() * runs any handlers registered for the topmost message in the message * queue, then discards the message, then returns. - * + * * dbus_connection_get_dispatch_status() indicates whether * messages are currently in the queue that need dispatching. * dbus_connection_set_dispatch_status_function() allows * you to set a function to be used to monitor the dispatch status. - * + * * If you're using GLib or Qt add-on libraries for D-Bus, there are * special convenience APIs in those libraries that hide * all the details of dispatch and watch/timeout monitoring. @@ -151,7 +151,7 @@ * avoid setting up any handler functions (see * dbus_connection_add_filter(), * dbus_connection_register_object_path() for more on handlers). - * + * * When you use dbus_connection_send() or one of its variants to send * a message, the message is added to the outgoing queue. It's * actually written to the network later; either in @@ -218,12 +218,12 @@ _dbus_connection_trace_ref (DBusConnection *connection, } /** - * Internal struct representing a message filter function + * Internal struct representing a message filter function */ typedef struct DBusMessageFilter DBusMessageFilter; /** - * Internal struct representing a message filter function + * Internal struct representing a message filter function */ struct DBusMessageFilter { @@ -263,7 +263,7 @@ struct DBusConnection DBusCondVar *dispatch_cond; /**< Notify when dispatch_acquired is available */ DBusCMutex *io_path_mutex; /**< Protects io_path_acquired */ DBusCondVar *io_path_cond; /**< Notify when io_path_acquired is available */ - + DBusList *outgoing_messages; /**< Queue of messages we need to send, send the end of the list first. */ DBusList *incoming_messages; /**< Queue of messages we have received, end of the list received most recently. */ DBusList *expired_messages; /**< Messages that will be released when we next unlock. */ @@ -271,23 +271,23 @@ struct DBusConnection DBusMessage *message_borrowed; /**< Filled in if the first incoming message has been borrowed; * dispatch_acquired will be set by the borrower */ - + int n_outgoing; /**< Length of outgoing queue. */ int n_incoming; /**< Length of incoming queue. */ DBusCounter *outgoing_counter; /**< Counts size of outgoing messages. */ - + DBusTransport *transport; /**< Object that sends/receives messages over network. */ DBusWatchList *watches; /**< Stores active watches. */ DBusTimeoutList *timeouts; /**< Stores active timeouts. */ - + DBusList *filter_list; /**< List of filters. */ DBusRMutex *slot_mutex; /**< Lock on slot_list so overall connection lock need not be taken */ DBusDataSlotList slot_list; /**< Data stored by allocated integer ID */ - DBusHashTable *pending_replies; /**< Hash of message serials to #DBusPendingCall. */ - + DBusHashTable *pending_replies; /**< Hash of message serials to #DBusPendingCall. */ + dbus_uint32_t client_serial; /**< Client serial. Increments each time a message is sent */ DBusList *disconnect_message_link; /**< Preallocated list node for queueing the disconnection message */ @@ -311,9 +311,9 @@ struct DBusConnection */ dbus_bool_t dispatch_acquired; /**< Someone has dispatch path (can drain incoming queue) */ dbus_bool_t io_path_acquired; /**< Someone has transport io path (can use the transport to read/write messages) */ - + unsigned int shareable : 1; /**< #TRUE if libdbus owns a reference to the connection and can return it from dbus_connection_open() more than once */ - + unsigned int exit_on_disconnect : 1; /**< If #TRUE, exit after handling disconnect signal */ unsigned int route_peer_messages : 1; /**< If #TRUE, if org.freedesktop.DBus.Peer messages have a bus name, don't handle them automatically */ @@ -325,14 +325,14 @@ struct DBusConnection unsigned int disconnected_message_processed : 1; /**< We did our default handling of the disconnected message, * such as closing the connection. */ - + #ifndef DBUS_DISABLE_CHECKS unsigned int have_connection_lock : 1; /**< Used to check locking */ #endif #if defined(DBUS_ENABLE_CHECKS) || defined(DBUS_ENABLE_ASSERT) int generation; /**< _dbus_current_generation that should correspond to this connection */ -#endif +#endif }; static DBusDispatchStatus _dbus_connection_get_dispatch_status_unlocked (DBusConnection *connection); @@ -374,7 +374,7 @@ _dbus_message_filter_unref (DBusMessageFilter *filter) { if (filter->free_user_data_function) (* filter->free_user_data_function) (filter->user_data); - + dbus_free (filter); } } @@ -447,12 +447,12 @@ _dbus_connection_wakeup_mainloop (DBusConnection *connection) * @param mutex_loc return for the location of the main mutex pointer * @param dispatch_mutex_loc return location of the dispatch mutex pointer * @param io_path_mutex_loc return location of the io_path mutex pointer - * @param dispatch_cond_loc return location of the dispatch conditional + * @param dispatch_cond_loc return location of the dispatch conditional * variable pointer - * @param io_path_cond_loc return location of the io_path conditional + * @param io_path_cond_loc return location of the io_path conditional * variable pointer - */ -void + */ +void _dbus_connection_test_get_locks (DBusConnection *connection, DBusMutex **mutex_loc, DBusMutex **dispatch_mutex_loc, @@ -505,13 +505,13 @@ _dbus_connection_queue_received_message_link (DBusConnection *connection, _dbus_pending_call_set_timeout_added_unlocked (pending, FALSE); } } - - + + connection->n_incoming += 1; _dbus_connection_wakeup_mainloop (connection); - + _dbus_verbose ("Message %p (%s %s %s %s '%s' reply to %u) added to incoming queue %p, %d incoming\n", message, dbus_message_type_to_string (dbus_message_get_type (message)), @@ -546,7 +546,7 @@ _dbus_connection_queue_synthesized_message_link (DBusConnection *connection, DBusList *link) { HAVE_LOCK_CHECK (connection); - + _dbus_list_append_link (&connection->incoming_messages, link); connection->n_incoming += 1; @@ -580,7 +580,7 @@ _dbus_connection_has_messages_to_send_unlocked (DBusConnection *connection) * Use dbus_connection_flush() to block until all outgoing * messages have been written to the underlying transport * (such as a socket). - * + * * @param connection the connection. * @returns #TRUE if the outgoing queue is non-empty. */ @@ -588,7 +588,7 @@ dbus_bool_t dbus_connection_has_messages_to_send (DBusConnection *connection) { dbus_bool_t v; - + _dbus_return_val_if_fail (connection != NULL, FALSE); CONNECTION_LOCK (connection); @@ -604,12 +604,12 @@ dbus_connection_has_messages_to_send (DBusConnection *connection) * * @param connection the connection. * @returns the message to be sent. - */ + */ DBusMessage* _dbus_connection_get_message_to_send (DBusConnection *connection) { HAVE_LOCK_CHECK (connection); - + return _dbus_list_get_last (&connection->outgoing_messages); } @@ -628,12 +628,12 @@ _dbus_connection_message_sent_unlocked (DBusConnection *connection, DBusList *link; HAVE_LOCK_CHECK (connection); - + /* This can be called before we even complete authentication, since * it's called on disconnect to clean up the outgoing queue. * It's also called as we successfully send each message. */ - + link = _dbus_list_get_last_link (&connection->outgoing_messages); _dbus_assert (link != NULL); _dbus_assert (link->data == message); @@ -726,7 +726,7 @@ protected_change_watch (DBusConnection *connection, else return FALSE; } - + /** * Adds a watch using the connection's DBusAddWatchFunction if @@ -931,7 +931,7 @@ _dbus_connection_attach_pending_call_unlocked (DBusConnection *connection, { if (!_dbus_connection_add_timeout_unlocked (connection, timeout)) return FALSE; - + if (!_dbus_hash_table_insert_int (connection->pending_replies, reply_serial, pending)) @@ -942,7 +942,7 @@ _dbus_connection_attach_pending_call_unlocked (DBusConnection *connection, HAVE_LOCK_CHECK (connection); return FALSE; } - + _dbus_pending_call_set_timeout_added_unlocked (pending, TRUE); } else @@ -959,7 +959,7 @@ _dbus_connection_attach_pending_call_unlocked (DBusConnection *connection, _dbus_pending_call_ref_unlocked (pending); HAVE_LOCK_CHECK (connection); - + return TRUE; } @@ -968,7 +968,7 @@ free_pending_call_on_hash_removal (void *data) { DBusPendingCall *pending; DBusConnection *connection; - + if (data == NULL) return; @@ -977,18 +977,18 @@ free_pending_call_on_hash_removal (void *data) connection = _dbus_pending_call_get_connection_unlocked (pending); HAVE_LOCK_CHECK (connection); - + if (_dbus_pending_call_is_timeout_added_unlocked (pending)) { _dbus_connection_remove_timeout_unlocked (connection, _dbus_pending_call_get_timeout_unlocked (pending)); - + _dbus_pending_call_set_timeout_added_unlocked (pending, FALSE); } - /* FIXME 1.0? this is sort of dangerous and undesirable to drop the lock - * here, but the pending call finalizer could in principle call out to - * application code so we pretty much have to... some larger code reorg + /* FIXME 1.0? this is sort of dangerous and undesirable to drop the lock + * here, but the pending call finalizer could in principle call out to + * application code so we pretty much have to... some larger code reorg * might be needed. */ _dbus_connection_ref_unlocked (connection); @@ -1062,7 +1062,7 @@ _dbus_connection_acquire_io_path (DBusConnection *connection, int timeout_milliseconds) { dbus_bool_t we_acquired; - + HAVE_LOCK_CHECK (connection); /* We don't want the connection to vanish */ @@ -1070,7 +1070,7 @@ _dbus_connection_acquire_io_path (DBusConnection *connection, /* We will only touch io_path_acquired which is protected by our mutex */ CONNECTION_UNLOCK (connection); - + _dbus_verbose ("locking io_path_mutex\n"); _dbus_cmutex_lock (connection->io_path_mutex); @@ -1078,7 +1078,7 @@ _dbus_connection_acquire_io_path (DBusConnection *connection, connection->io_path_acquired, timeout_milliseconds); we_acquired = FALSE; - + if (connection->io_path_acquired) { if (timeout_milliseconds != -1) @@ -1105,18 +1105,18 @@ _dbus_connection_acquire_io_path (DBusConnection *connection, while (connection->io_path_acquired) { _dbus_verbose ("waiting for IO path to be acquirable\n"); - _dbus_condvar_wait (connection->io_path_cond, + _dbus_condvar_wait (connection->io_path_cond, connection->io_path_mutex); } } } - + if (!connection->io_path_acquired) { we_acquired = TRUE; connection->io_path_acquired = TRUE; } - + _dbus_verbose ("end connection->io_path_acquired = %d we_acquired = %d\n", connection->io_path_acquired, we_acquired); @@ -1124,11 +1124,11 @@ _dbus_connection_acquire_io_path (DBusConnection *connection, _dbus_cmutex_unlock (connection->io_path_mutex); CONNECTION_LOCK (connection); - + HAVE_LOCK_CHECK (connection); _dbus_connection_unref_unlocked (connection); - + return we_acquired; } @@ -1143,15 +1143,15 @@ static void _dbus_connection_release_io_path (DBusConnection *connection) { HAVE_LOCK_CHECK (connection); - + _dbus_verbose ("locking io_path_mutex\n"); _dbus_cmutex_lock (connection->io_path_mutex); - + _dbus_assert (connection->io_path_acquired); _dbus_verbose ("start connection->io_path_acquired = %d\n", connection->io_path_acquired); - + connection->io_path_acquired = FALSE; _dbus_condvar_wake_one (connection->io_path_cond); @@ -1188,7 +1188,7 @@ _dbus_connection_release_io_path (DBusConnection *connection) * lock for a while. * * Called with connection lock held. - * + * * @param connection the connection. * @param pending the pending call that should be checked or NULL * @param flags iteration flags. @@ -1201,9 +1201,9 @@ _dbus_connection_do_iteration_unlocked (DBusConnection *connection, int timeout_milliseconds) { _dbus_verbose ("start\n"); - + HAVE_LOCK_CHECK (connection); - + if (connection->n_outgoing == 0) flags &= ~DBUS_ITERATION_DO_WRITING; @@ -1211,7 +1211,7 @@ _dbus_connection_do_iteration_unlocked (DBusConnection *connection, (flags & DBUS_ITERATION_BLOCK) ? timeout_milliseconds : 0)) { HAVE_LOCK_CHECK (connection); - + if ( (pending != NULL) && _dbus_pending_call_get_completed_unlocked(pending)) { _dbus_verbose ("pending call completed while acquiring I/O path"); @@ -1256,7 +1256,7 @@ _dbus_connection_new_for_transport (DBusTransport *transport) DBusMessage *disconnect_message; DBusCounter *outgoing_counter; DBusObjectTree *objects; - + watch_list = NULL; connection = NULL; pending_replies = NULL; @@ -1265,14 +1265,14 @@ _dbus_connection_new_for_transport (DBusTransport *transport) disconnect_message = NULL; outgoing_counter = NULL; objects = NULL; - + watch_list = _dbus_watch_list_new (); if (watch_list == NULL) goto error; timeout_list = _dbus_timeout_list_new (); if (timeout_list == NULL) - goto error; + goto error; pending_replies = _dbus_hash_table_new (DBUS_HASH_INT, @@ -1280,7 +1280,7 @@ _dbus_connection_new_for_transport (DBusTransport *transport) (DBusFreeFunction)free_pending_call_on_hash_removal); if (pending_replies == NULL) goto error; - + connection = dbus_new0 (DBusConnection, 1); if (connection == NULL) goto error; @@ -1296,11 +1296,11 @@ _dbus_connection_new_for_transport (DBusTransport *transport) _dbus_cmutex_new_at_location (&connection->dispatch_mutex); if (connection->dispatch_mutex == NULL) goto error; - + _dbus_condvar_new_at_location (&connection->dispatch_cond); if (connection->dispatch_cond == NULL) goto error; - + _dbus_condvar_new_at_location (&connection->io_path_cond); if (connection->io_path_cond == NULL) goto error; @@ -1312,7 +1312,7 @@ _dbus_connection_new_for_transport (DBusTransport *transport) disconnect_message = dbus_message_new_signal (DBUS_PATH_LOCAL, DBUS_INTERFACE_LOCAL, "Disconnected"); - + if (disconnect_message == NULL) goto error; @@ -1327,7 +1327,7 @@ _dbus_connection_new_for_transport (DBusTransport *transport) objects = _dbus_object_tree_new (connection); if (objects == NULL) goto error; - + if (_dbus_modify_sigpipe) _dbus_disable_sigpipe (); @@ -1346,11 +1346,11 @@ _dbus_connection_new_for_transport (DBusTransport *transport) connection->route_peer_messages = FALSE; connection->disconnected_message_arrived = FALSE; connection->disconnected_message_processed = FALSE; - + #if defined(DBUS_ENABLE_CHECKS) || defined(DBUS_ENABLE_ASSERT) connection->generation = _dbus_current_generation; #endif - + _dbus_data_slot_list_init (&connection->slot_list); connection->client_serial = 1; @@ -1358,7 +1358,7 @@ _dbus_connection_new_for_transport (DBusTransport *transport) connection->disconnect_message_link = disconnect_link; CONNECTION_LOCK (connection); - + if (!_dbus_transport_set_connection (transport, connection)) { CONNECTION_UNLOCK (connection); @@ -1372,14 +1372,14 @@ _dbus_connection_new_for_transport (DBusTransport *transport) _dbus_connection_trace_ref (connection, 0, 1, "new_for_transport"); return connection; - + error: if (disconnect_message != NULL) dbus_message_unref (disconnect_message); - + if (disconnect_link != NULL) _dbus_list_free_link (disconnect_link); - + if (connection != NULL) { _dbus_condvar_free_at_location (&connection->io_path_cond); @@ -1392,7 +1392,7 @@ _dbus_connection_new_for_transport (DBusTransport *transport) } if (pending_replies) _dbus_hash_table_unref (pending_replies); - + if (watch_list) _dbus_watch_list_free (watch_list); @@ -1404,7 +1404,7 @@ _dbus_connection_new_for_transport (DBusTransport *transport) if (objects) _dbus_object_tree_unref (objects); - + return NULL; } @@ -1471,7 +1471,7 @@ _dbus_connection_get_next_client_serial (DBusConnection *connection) /** * A callback for use with dbus_watch_new() to create a DBusWatch. - * + * * @todo This is basically a hack - we could delete _dbus_transport_handle_watch() * and the virtual handle_watch in DBusTransport if we got rid of it. * The reason this is some work is threading, see the _dbus_connection_handle_watch() @@ -1494,7 +1494,7 @@ _dbus_connection_handle_watch (DBusWatch *watch, connection = data; _dbus_verbose ("start\n"); - + CONNECTION_LOCK (connection); if (!_dbus_connection_acquire_io_path (connection, 1)) @@ -1513,14 +1513,14 @@ _dbus_connection_handle_watch (DBusWatch *watch, HAVE_LOCK_CHECK (connection); _dbus_verbose ("middle\n"); - + status = _dbus_connection_get_dispatch_status_unlocked (connection); /* this calls out to user code */ _dbus_connection_update_dispatch_status_and_unlock (connection, status); _dbus_verbose ("end\n"); - + return retval; } @@ -1561,10 +1561,10 @@ shared_connections_shutdown (void *data) { DBusConnection *connection; DBusHashIter iter; - + _dbus_hash_iter_init (shared_connections, &iter); _dbus_hash_iter_next (&iter); - + connection = _dbus_hash_iter_get_value (&iter); _DBUS_UNLOCK (shared_connections); @@ -1577,7 +1577,7 @@ shared_connections_shutdown (void *data) } _dbus_assert (_dbus_hash_table_get_n_entries (shared_connections) == 0); - + _dbus_hash_table_unref (shared_connections); shared_connections = NULL; @@ -1596,7 +1596,7 @@ shared_connections_shutdown (void *data) } shared_connections_no_guid = NULL; - + _DBUS_UNLOCK (shared_connections); } @@ -1605,7 +1605,7 @@ connection_lookup_shared (DBusAddressEntry *entry, DBusConnection **result) { _dbus_verbose ("checking for existing connection\n"); - + *result = NULL; if (!_DBUS_LOCK (shared_connections)) @@ -1618,7 +1618,7 @@ connection_lookup_shared (DBusAddressEntry *entry, if (shared_connections == NULL) { _dbus_verbose ("creating shared_connections hash table\n"); - + shared_connections = _dbus_hash_table_new (DBUS_HASH_STRING, dbus_free, NULL); @@ -1637,7 +1637,7 @@ connection_lookup_shared (DBusAddressEntry *entry, } _dbus_verbose (" successfully created shared_connections\n"); - + _DBUS_UNLOCK (shared_connections); return TRUE; /* no point looking up in the hash we just made */ } @@ -1646,11 +1646,11 @@ connection_lookup_shared (DBusAddressEntry *entry, const char *guid; guid = dbus_address_entry_get_value (entry, "guid"); - + if (guid != NULL) { DBusConnection *connection; - + connection = _dbus_hash_table_lookup_string (shared_connections, guid); @@ -1686,7 +1686,7 @@ connection_lookup_shared (DBusAddressEntry *entry, CONNECTION_UNLOCK (connection); } } - + _DBUS_UNLOCK (shared_connections); return TRUE; } @@ -1723,12 +1723,12 @@ connection_record_shared_unlocked (DBusConnection *connection, _DBUS_UNLOCK (shared_connections); return TRUE; /* don't store in the hash */ } - + /* A separate copy of the key is required in the hash table, because * we don't have a lock on the connection when we are doing a hash * lookup. */ - + guid_key = _dbus_strdup (guid); if (guid_key == NULL) return FALSE; @@ -1748,7 +1748,7 @@ connection_record_shared_unlocked (DBusConnection *connection, } _dbus_assert (shared_connections != NULL); - + if (!_dbus_hash_table_insert_string (shared_connections, guid_key, connection)) { @@ -1762,11 +1762,11 @@ connection_record_shared_unlocked (DBusConnection *connection, _dbus_verbose ("stored connection to %s to be shared\n", connection->server_guid); - + _DBUS_UNLOCK (shared_connections); _dbus_assert (connection->server_guid != NULL); - + return TRUE; } @@ -1789,11 +1789,11 @@ connection_forget_shared_unlocked (DBusConnection *connection) { _dbus_verbose ("dropping connection to %s out of the shared table\n", connection->server_guid); - + if (!_dbus_hash_table_remove_string (shared_connections, connection->server_guid)) _dbus_assert_not_reached ("connection was not in the shared table"); - + dbus_free (connection->server_guid); connection->server_guid = NULL; } @@ -1803,7 +1803,7 @@ connection_forget_shared_unlocked (DBusConnection *connection) } _DBUS_UNLOCK (shared_connections); - + /* remove our reference held on all shareable connections */ _dbus_connection_unref_unlocked (connection); } @@ -1826,7 +1826,7 @@ connection_try_from_address_entry (DBusAddressEntry *entry, connection = _dbus_connection_new_for_transport (transport); _dbus_transport_unref (transport); - + if (connection == NULL) { _DBUS_SET_OOM (error); @@ -1866,12 +1866,12 @@ _dbus_connection_open_internal (const char *address, _dbus_verbose ("opening %s connection to: %s\n", shared ? "shared" : "private", address); - + if (!dbus_parse_address (address, &entries, &len, error)) return NULL; _DBUS_ASSERT_ERROR_IS_CLEAR (error); - + connection = NULL; for (i = 0; i < len; i++) @@ -1890,14 +1890,14 @@ _dbus_connection_open_internal (const char *address, if (connection != NULL && shared) { const char *guid; - + connection->shareable = TRUE; - + /* guid may be NULL */ guid = dbus_address_entry_get_value (entries[i], "guid"); - + CONNECTION_LOCK (connection); - + if (!connection_record_shared_unlocked (connection, guid)) { _DBUS_SET_OOM (&tmp_error); @@ -1909,21 +1909,21 @@ _dbus_connection_open_internal (const char *address, CONNECTION_UNLOCK (connection); } } - + if (connection) break; _DBUS_ASSERT_ERROR_IS_SET (&tmp_error); - + if (i == 0) dbus_move_error (&tmp_error, &first_error); else dbus_error_free (&tmp_error); } - + _DBUS_ASSERT_ERROR_IS_CLEAR (error); _DBUS_ASSERT_ERROR_IS_CLEAR (&tmp_error); - + if (connection == NULL) { _DBUS_ASSERT_ERROR_IS_SET (&first_error); @@ -1931,7 +1931,7 @@ _dbus_connection_open_internal (const char *address, } else dbus_error_free (&first_error); - + dbus_address_entries_free (entries); return connection; } @@ -1941,7 +1941,7 @@ _dbus_connection_open_internal (const char *address, * only be used on private connections. Should only be called by the * dbus code that owns the connection - an owner must be known, * the open/close state is like malloc/free, not like ref/unref. - * + * * @param connection the connection */ void @@ -1960,9 +1960,9 @@ _dbus_connection_preallocate_send_unlocked (DBusConnection *connection) DBusPreallocatedSend *preallocated; HAVE_LOCK_CHECK (connection); - + _dbus_assert (connection != NULL); - + preallocated = dbus_new (DBusPreallocatedSend, 1); if (preallocated == NULL) return NULL; @@ -1978,14 +1978,14 @@ _dbus_connection_preallocate_send_unlocked (DBusConnection *connection) _dbus_counter_ref (preallocated->counter_link->data); preallocated->connection = connection; - + return preallocated; - + failed_1: _dbus_list_free_link (preallocated->queue_link); failed_0: dbus_free (preallocated); - + return NULL; } @@ -2009,9 +2009,9 @@ _dbus_connection_send_preallocated_unlocked_no_update (DBusConnection *con dbus_free (preallocated); preallocated = NULL; - + dbus_message_ref (message); - + connection->n_outgoing += 1; _dbus_verbose ("Message %p (%s %s %s %s '%s') for %s added to outgoing queue %p, %d pending to send\n", @@ -2048,7 +2048,7 @@ _dbus_connection_send_preallocated_unlocked_no_update (DBusConnection *con _dbus_verbose ("Message %p serial is %u\n", message, dbus_message_get_serial (message)); - + dbus_message_lock (message); /* Now we need to run an iteration to hopefully just write the messages @@ -2073,7 +2073,7 @@ _dbus_connection_send_preallocated_and_unlock (DBusConnection *connection, DBusDispatchStatus status; HAVE_LOCK_CHECK (connection); - + _dbus_connection_send_preallocated_unlocked_no_update (connection, preallocated, message, client_serial); @@ -2103,7 +2103,7 @@ _dbus_connection_send_and_unlock (DBusConnection *connection, _dbus_assert (connection != NULL); _dbus_assert (message != NULL); - + preallocated = _dbus_connection_preallocate_send_unlocked (connection); if (preallocated == NULL) { @@ -2139,7 +2139,7 @@ _dbus_connection_send_and_unlock (DBusConnection *connection, * * If we didn't atomically check the refcount and close with the lock held * though, we could screw this up. - * + * * @param connection the connection */ void @@ -2183,8 +2183,8 @@ _dbus_memory_pause_based_on_timeout (int timeout_milliseconds) } static DBusMessage * -generate_local_error_message (dbus_uint32_t serial, - char *error_name, +generate_local_error_message (dbus_uint32_t serial, + char *error_name, char *error_msg) { DBusMessage *message; @@ -2196,10 +2196,10 @@ generate_local_error_message (dbus_uint32_t serial, { dbus_message_unref (message); message = NULL; - goto out; + goto out; } - dbus_message_set_no_reply (message, TRUE); + dbus_message_set_no_reply (message, TRUE); if (!dbus_message_set_reply_serial (message, serial)) @@ -2265,7 +2265,7 @@ check_for_reply_unlocked (DBusConnection *connection, DBusList *link; HAVE_LOCK_CHECK (connection); - + link = _dbus_list_get_first_link (&connection->incoming_messages); while (link != NULL) @@ -2291,25 +2291,25 @@ connection_timeout_and_complete_all_pending_calls_unlocked (DBusConnection *conn * dropping the lock for each item. So we restart the * iter each time as we drain the hash table. */ - + while (_dbus_hash_table_get_n_entries (connection->pending_replies) > 0) { DBusPendingCall *pending; DBusHashIter iter; - + _dbus_hash_iter_init (connection->pending_replies, &iter); _dbus_hash_iter_next (&iter); - + pending = _dbus_hash_iter_get_value (&iter); _dbus_pending_call_ref_unlocked (pending); - - _dbus_pending_call_queue_timeout_error_unlocked (pending, + + _dbus_pending_call_queue_timeout_error_unlocked (pending, connection); if (_dbus_pending_call_is_timeout_added_unlocked (pending)) _dbus_connection_remove_timeout_unlocked (connection, _dbus_pending_call_get_timeout_unlocked (pending)); - _dbus_pending_call_set_timeout_added_unlocked (pending, FALSE); + _dbus_pending_call_set_timeout_added_unlocked (pending, FALSE); _dbus_hash_iter_remove_entry (&iter); _dbus_pending_call_unref_and_unlock (pending); @@ -2326,7 +2326,7 @@ complete_pending_call_and_unlock (DBusConnection *connection, _dbus_pending_call_set_reply_unlocked (pending, message); _dbus_pending_call_ref_unlocked (pending); /* in case there's no app with a ref held */ _dbus_connection_detach_pending_call_and_unlock (connection, pending); - + /* Must be called unlocked since it invokes app callback */ _dbus_pending_call_complete (pending); dbus_pending_call_unref (pending); @@ -2339,7 +2339,7 @@ check_for_reply_and_update_dispatch_unlocked (DBusConnection *connection, DBusMessage *reply; DBusDispatchStatus status; - reply = check_for_reply_unlocked (connection, + reply = check_for_reply_unlocked (connection, _dbus_pending_call_get_reply_serial_unlocked (pending)); if (reply != NULL) { @@ -2369,7 +2369,7 @@ check_for_reply_and_update_dispatch_unlocked (DBusConnection *connection, * filter callbacks. * * Returns immediately if pending call already got a reply. - * + * * @todo could use performance improvements (it keeps scanning * the whole message queue for example) * @@ -2394,7 +2394,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) dbus_pending_call_ref (pending); /* necessary because the call could be canceled */ connection = _dbus_pending_call_get_connection_and_lock (pending); - + /* Flush message queue - note, can affect dispatch status */ _dbus_connection_flush_unlocked (connection); @@ -2438,9 +2438,9 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) recheck_status: _dbus_verbose ("top of recheck\n"); - + HAVE_LOCK_CHECK (connection); - + /* queue messages and get status */ status = _dbus_connection_get_dispatch_status_unlocked (connection); @@ -2455,24 +2455,24 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) dbus_pending_call_unref (pending); return; } - + if (status == DBUS_DISPATCH_DATA_REMAINS) { if (check_for_reply_and_update_dispatch_unlocked (connection, pending)) return; } - + _dbus_get_monotonic_time (&tv_sec, &tv_usec); elapsed_milliseconds = (tv_sec - start_tv_sec) * 1000 + (tv_usec - start_tv_usec) / 1000; - + if (!_dbus_connection_get_is_connected_unlocked (connection)) { DBusMessage *error_msg; error_msg = generate_local_error_message (client_serial, - DBUS_ERROR_DISCONNECTED, - "Connection was disconnected before a reply was received"); + DBUS_ERROR_DISCONNECTED, + "Connection was disconnected before a reply was received"); /* on OOM error_msg is set to NULL */ complete_pending_call_and_unlock (connection, pending, error_msg); @@ -2494,7 +2494,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) _dbus_memory_pause_based_on_timeout (timeout_milliseconds - elapsed_milliseconds); } else - { + { /* block again, we don't have the reply buffered yet. */ _dbus_connection_do_iteration_unlocked (connection, pending, @@ -2510,7 +2510,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) else if (elapsed_milliseconds < timeout_milliseconds) { _dbus_verbose ("dbus_connection_send_with_reply_and_block(): %d milliseconds remain\n", timeout_milliseconds - elapsed_milliseconds); - + if (status == DBUS_DISPATCH_NEED_MEMORY) { /* Try sleeping a bit, as we aren't sure we need to block for reading, @@ -2522,7 +2522,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) _dbus_memory_pause_based_on_timeout (timeout_milliseconds - elapsed_milliseconds); } else - { + { /* block again, we don't have the reply buffered yet. */ _dbus_connection_do_iteration_unlocked (connection, NULL, @@ -2538,7 +2538,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) elapsed_milliseconds); _dbus_assert (!_dbus_pending_call_get_completed_unlocked (pending)); - + /* unlock and call user code */ complete_pending_call_and_unlock (connection, pending, NULL); @@ -2607,7 +2607,7 @@ _dbus_connection_set_pending_fds_function (DBusConnection *connection, * unless you have good reason; connections are expensive enough * that it's wasteful to create lots of connections to the same * server. - * + * * @param address the address. * @param error address where an error can be returned. * @returns new connection, or #NULL on failure. @@ -2641,7 +2641,7 @@ dbus_connection_open (const char *address, * When you are done with this connection, you must * dbus_connection_close() to disconnect it, * and dbus_connection_unref() to free the connection object. - * + * * (The dbus_connection_close() can be skipped if the * connection is already known to be disconnected, for example * if you are inside a handler for the Disconnected signal.) @@ -2720,23 +2720,23 @@ _dbus_connection_last_unref (DBusConnection *connection) */ _dbus_assert (!_dbus_transport_get_is_connected (connection->transport)); _dbus_assert (connection->server_guid == NULL); - + /* ---- We're going to call various application callbacks here, hope it doesn't break anything... */ _dbus_object_tree_free_all_unlocked (connection->objects); - + dbus_connection_set_dispatch_status_function (connection, NULL, NULL, NULL); dbus_connection_set_wakeup_main_function (connection, NULL, NULL, NULL); dbus_connection_set_unix_user_function (connection, NULL, NULL, NULL); dbus_connection_set_windows_user_function (connection, NULL, NULL, NULL); - + _dbus_watch_list_free (connection->watches); connection->watches = NULL; - + _dbus_timeout_list_free (connection->timeouts); connection->timeouts = NULL; _dbus_data_slot_list_free (&connection->slot_list); - + link = _dbus_list_get_first_link (&connection->filter_list); while (link != NULL) { @@ -2746,25 +2746,25 @@ _dbus_connection_last_unref (DBusConnection *connection) filter->function = NULL; _dbus_message_filter_unref (filter); /* calls app callback */ link->data = NULL; - + link = next; } _dbus_list_clear (&connection->filter_list); - + /* ---- Done with stuff that invokes application callbacks */ - _dbus_object_tree_unref (connection->objects); + _dbus_object_tree_unref (connection->objects); _dbus_hash_table_unref (connection->pending_replies); connection->pending_replies = NULL; - + _dbus_list_clear (&connection->filter_list); - + _dbus_list_foreach (&connection->outgoing_messages, free_outgoing_message, connection); _dbus_list_clear (&connection->outgoing_messages); - + _dbus_list_foreach (&connection->incoming_messages, (DBusForeachFunction) dbus_message_unref, NULL); @@ -2790,7 +2790,7 @@ _dbus_connection_last_unref (DBusConnection *connection) _dbus_rmutex_free_at_location (&connection->slot_mutex); _dbus_rmutex_free_at_location (&connection->mutex); - + dbus_free (connection); } @@ -2833,7 +2833,7 @@ dbus_connection_unref (DBusConnection *connection) { _dbus_warn_check_failed ("The last reference on a connection was dropped without closing the connection. This is a bug in an application. See dbus_connection_unref() documentation for details.\n%s", connection->shareable ? - "Most likely, the application called unref() too many times and removed a reference belonging to libdbus, since this is a shared connection.\n" : + "Most likely, the application called unref() too many times and removed a reference belonging to libdbus, since this is a shared connection.\n" : "Most likely, the application was supposed to call dbus_connection_close(), since this is a private connection.\n"); return; } @@ -2847,7 +2847,7 @@ dbus_connection_unref (DBusConnection *connection) * and in that case this function never runs. So this function must * not do anything more than disconnect the transport and update the * dispatch status. - * + * * If the transport self-disconnects, then we assume someone will * dispatch the connection to cause the dispatch status update. */ @@ -2857,7 +2857,7 @@ _dbus_connection_close_possibly_shared_and_unlock (DBusConnection *connection) DBusDispatchStatus status; HAVE_LOCK_CHECK (connection); - + _dbus_verbose ("Disconnecting %p\n", connection); /* We need to ref because update_dispatch_status_and_unlock will unref @@ -2865,7 +2865,7 @@ _dbus_connection_close_possibly_shared_and_unlock (DBusConnection *connection) * refcount holder. */ _dbus_connection_ref_unlocked (connection); - + _dbus_transport_disconnect (connection->transport); /* This has the side effect of queuing the disconnect message link @@ -2893,7 +2893,7 @@ _dbus_connection_close_possibly_shared_and_unlock (DBusConnection *connection) * * Attempts to send messages after closing a connection are safe, but will result in * error replies generated locally in libdbus. - * + * * This function does not affect the connection's reference count. It's * safe to close a connection more than once; all calls after the * first do nothing. It's impossible to "reopen" a connection, a @@ -2903,8 +2903,8 @@ _dbus_connection_close_possibly_shared_and_unlock (DBusConnection *connection) * message it generates needs to be dispatched. * * If a connection is dropped by the remote application, it will - * close itself. - * + * close itself. + * * You must close a connection prior to releasing the last reference to * the connection. If you dbus_connection_unref() for the last time * without closing the connection, the results are undefined; it @@ -2945,7 +2945,7 @@ dbus_connection_close (DBusConnection *connection) return; } #endif - + _dbus_connection_close_possibly_shared_and_unlock (connection); } @@ -2961,7 +2961,7 @@ _dbus_connection_get_is_connected_unlocked (DBusConnection *connection) * become disconnected when the remote application closes its end, or * exits; a connection may also be disconnected with * dbus_connection_close(). - * + * * There are not separate states for "closed" and "disconnected," the two * terms are synonymous. This function should really be called * get_is_open() but for historical reasons is not. @@ -2975,11 +2975,11 @@ dbus_connection_get_is_connected (DBusConnection *connection) dbus_bool_t res; _dbus_return_val_if_fail (connection != NULL, FALSE); - + CONNECTION_LOCK (connection); res = _dbus_connection_get_is_connected_unlocked (connection); CONNECTION_UNLOCK (connection); - + return res; } @@ -3001,7 +3001,7 @@ dbus_connection_get_is_authenticated (DBusConnection *connection) CONNECTION_LOCK (connection); res = _dbus_transport_try_to_authenticate (connection->transport); CONNECTION_UNLOCK (connection); - + return res; } @@ -3021,9 +3021,9 @@ dbus_connection_get_is_authenticated (DBusConnection *connection) * dbus_server_set_auth_mechanisms() to remove the mechanisms that * allow proving user identity (i.e. only allow the ANONYMOUS * mechanism). - * + * * @param connection the connection - * @returns #TRUE if not authenticated or authenticated as anonymous + * @returns #TRUE if not authenticated or authenticated as anonymous */ dbus_bool_t dbus_connection_get_is_anonymous (DBusConnection *connection) @@ -3031,11 +3031,11 @@ dbus_connection_get_is_anonymous (DBusConnection *connection) dbus_bool_t res; _dbus_return_val_if_fail (connection != NULL, FALSE); - + CONNECTION_LOCK (connection); res = _dbus_transport_get_is_anonymous (connection->transport); CONNECTION_UNLOCK (connection); - + return res; } @@ -3044,7 +3044,7 @@ dbus_connection_get_is_anonymous (DBusConnection *connection) * connection is on the client side. If the connection is on the * server side, this will always return #NULL - use dbus_server_get_id() * to get the ID of your own server, if you are the server side. - * + * * If a client-side connection is not authenticated yet, the ID may be * available if it was included in the server address, but may not be * available. The only way to be sure the server ID is available @@ -3063,7 +3063,7 @@ dbus_connection_get_is_anonymous (DBusConnection *connection) * get the machine you are on. There isn't a convenience wrapper, but * you can invoke org.freedesktop.DBus.Peer.GetMachineId on any peer * to get the machine ID on the other end. - * + * * The D-Bus specification describes the server ID and other IDs in a * bit more detail. * @@ -3153,7 +3153,7 @@ dbus_connection_set_exit_on_disconnect (DBusConnection *connection, } /** - * Preallocates resources needed to send a message, allowing the message + * Preallocates resources needed to send a message, allowing the message * to be sent without the possibility of memory allocation failure. * Allows apps to create a future guarantee that they can send * a message regardless of memory shortages. @@ -3169,7 +3169,7 @@ dbus_connection_preallocate_send (DBusConnection *connection) _dbus_return_val_if_fail (connection != NULL, NULL); CONNECTION_LOCK (connection); - + preallocated = _dbus_connection_preallocate_send_unlocked (connection); @@ -3192,7 +3192,7 @@ dbus_connection_free_preallocated_send (DBusConnection *connection, DBusPreallocatedSend *preallocated) { _dbus_return_if_fail (connection != NULL); - _dbus_return_if_fail (preallocated != NULL); + _dbus_return_if_fail (preallocated != NULL); _dbus_return_if_fail (connection == preallocated->connection); _dbus_list_free_link (preallocated->queue_link); @@ -3259,7 +3259,7 @@ _dbus_connection_send_unlocked_no_update (DBusConnection *connection, _dbus_assert (connection != NULL); _dbus_assert (message != NULL); - + preallocated = _dbus_connection_preallocate_send_unlocked (connection); if (preallocated == NULL) return FALSE; @@ -3275,15 +3275,15 @@ _dbus_connection_send_unlocked_no_update (DBusConnection *connection, * Adds a message to the outgoing message queue. Does not block to * write the message to the network; that happens asynchronously. To * force the message to be written, call dbus_connection_flush() however - * it is not necessary to call dbus_connection_flush() by hand; the - * message will be sent the next time the main loop is run. + * it is not necessary to call dbus_connection_flush() by hand; the + * message will be sent the next time the main loop is run. * dbus_connection_flush() should only be used, for example, if * the application was expected to exit before running the main loop. * * Because this only queues the message, the only reason it can * fail is lack of memory. Even if the connection is disconnected, - * no error will be returned. If the function fails due to lack of memory, - * it returns #FALSE. The function will never fail for other reasons; even + * no error will be returned. If the function fails due to lack of memory, + * it returns #FALSE. The function will never fail for other reasons; even * if the connection is disconnected, you can queue an outgoing message, * though obviously it won't be sent. * @@ -3292,7 +3292,7 @@ _dbus_connection_send_unlocked_no_update (DBusConnection *connection, * * dbus_message_unref() can be called as soon as this method returns * as the message queue will hold its own ref until the message is sent. - * + * * @param connection the connection. * @param message the message to write. * @param serial return location for message serial, or #NULL if you don't care @@ -3337,7 +3337,7 @@ reply_handler_timeout (void *data) connection = _dbus_pending_call_get_connection_and_lock (pending); _dbus_connection_ref_unlocked (connection); - _dbus_pending_call_queue_timeout_error_unlocked (pending, + _dbus_pending_call_queue_timeout_error_unlocked (pending, connection); _dbus_connection_remove_timeout_unlocked (connection, _dbus_pending_call_get_timeout_unlocked (pending)); @@ -3349,7 +3349,7 @@ reply_handler_timeout (void *data) /* Unlocks, and calls out to user code */ _dbus_connection_update_dispatch_status_and_unlock (connection, status); dbus_connection_unref (connection); - + return TRUE; } @@ -3367,7 +3367,7 @@ reply_handler_timeout (void *data) * * A #DBusPendingCall will always see exactly one reply message, * unless it's cancelled with dbus_pending_call_cancel(). - * + * * If #NULL is passed for the pending_return, the #DBusPendingCall * will still be generated internally, and used to track * the message reply timeout. This means a timeout error will @@ -3456,7 +3456,7 @@ dbus_connection_send_with_reply (DBusConnection *connection, if (!_dbus_pending_call_set_timeout_error_unlocked (pending, message, serial)) goto error; - + /* Insert the serial in the pending replies hash; * hash takes a refcount on DBusPendingCall. * Also, add the timeout. @@ -3464,7 +3464,7 @@ dbus_connection_send_with_reply (DBusConnection *connection, if (!_dbus_connection_attach_pending_call_unlocked (connection, pending)) goto error; - + if (!_dbus_connection_send_unlocked_no_update (connection, message, NULL)) { _dbus_connection_detach_pending_call_and_unlock (connection, @@ -3489,7 +3489,7 @@ dbus_connection_send_with_reply (DBusConnection *connection, if (pending_return == NULL) dbus_pending_call_unref (pending); - + return TRUE; error: @@ -3505,7 +3505,7 @@ dbus_connection_send_with_reply (DBusConnection *connection, * i.e. messages other than the reply are queued up but not * processed. This function is used to invoke method calls on a * remote object. - * + * * If a normal reply is received, it is returned, and removed from the * incoming message queue. If it is not received, #NULL is returned * and the error is set to #DBUS_ERROR_NO_REPLY. If an error reply is @@ -3571,7 +3571,7 @@ dbus_connection_send_with_reply_and_block (DBusConnection *connection, dbus_set_error (error, DBUS_ERROR_DISCONNECTED, "Connection is closed"); return NULL; } - + dbus_pending_call_block (pending); reply = dbus_pending_call_steal_reply (pending); @@ -3581,7 +3581,7 @@ dbus_connection_send_with_reply_and_block (DBusConnection *connection, * always fill this in. */ _dbus_assert (reply != NULL); - + if (dbus_set_error_from_message (error, reply)) { dbus_message_unref (reply); @@ -3596,7 +3596,7 @@ dbus_connection_send_with_reply_and_block (DBusConnection *connection, * Assumes connection lock already held. * * If you call this, you MUST call update_dispatch_status afterword... - * + * * @param connection the connection. */ static DBusDispatchStatus @@ -3610,7 +3610,7 @@ _dbus_connection_flush_unlocked (DBusConnection *connection) DBusDispatchStatus status; HAVE_LOCK_CHECK (connection); - + while (connection->n_outgoing > 0 && _dbus_connection_get_is_connected_unlocked (connection)) { @@ -3648,11 +3648,11 @@ dbus_connection_flush (DBusConnection *connection) DBusDispatchStatus status; _dbus_return_if_fail (connection != NULL); - + CONNECTION_LOCK (connection); status = _dbus_connection_flush_unlocked (connection); - + HAVE_LOCK_CHECK (connection); /* Unlocks and calls out to user code */ _dbus_connection_update_dispatch_status_and_unlock (connection, status); @@ -3664,7 +3664,7 @@ dbus_connection_flush (DBusConnection *connection) * This function implements dbus_connection_read_write_dispatch() and * dbus_connection_read_write() (they pass a different value for the * dispatch parameter). - * + * * @param connection the connection * @param timeout_milliseconds max time to block or -1 for infinite * @param dispatch dispatch new messages or leave them on the incoming queue @@ -3672,14 +3672,14 @@ dbus_connection_flush (DBusConnection *connection) */ static dbus_bool_t _dbus_connection_read_write_dispatch (DBusConnection *connection, - int timeout_milliseconds, + int timeout_milliseconds, dbus_bool_t dispatch) { DBusDispatchStatus dstatus; dbus_bool_t progress_possible; /* Need to grab a ref here in case we're a private connection and - * the user drops the last ref in a handler we call; see bug + * the user drops the last ref in a handler we call; see bug * https://bugs.freedesktop.org/show_bug.cgi?id=15635 */ dbus_connection_ref (connection); @@ -3711,7 +3711,7 @@ _dbus_connection_read_write_dispatch (DBusConnection *connection, timeout_milliseconds); } } - + HAVE_LOCK_CHECK (connection); /* If we can dispatch, we can make progress until the Disconnected message * has been processed; if we can only read/write, we can make progress @@ -3735,16 +3735,16 @@ _dbus_connection_read_write_dispatch (DBusConnection *connection, * This function is intended for use with applications that don't want * to write a main loop and deal with #DBusWatch and #DBusTimeout. An * example usage would be: - * + * * @code * while (dbus_connection_read_write_dispatch (connection, -1)) * ; // empty loop body * @endcode - * + * * In this usage you would normally have set up a filter function to look * at each message as it is dispatched. The loop terminates when the last * message from the connection (the disconnected signal) is processed. - * + * * If there are messages to dispatch, this function will * dbus_connection_dispatch() once, and return. If there are no * messages to dispatch, this function will block until it can read or @@ -3774,11 +3774,11 @@ dbus_connection_read_write_dispatch (DBusConnection *connection, return _dbus_connection_read_write_dispatch(connection, timeout_milliseconds, TRUE); } -/** +/** * This function is intended for use with applications that don't want to * write a main loop and deal with #DBusWatch and #DBusTimeout. See also * dbus_connection_read_write_dispatch(). - * + * * As long as the connection is open, this function will block until it can * read or write, then read or write, then return #TRUE. * @@ -3792,15 +3792,15 @@ dbus_connection_read_write_dispatch (DBusConnection *connection, * processed. dbus_connection_read_write_dispatch() dispatches * incoming messages for you; with dbus_connection_read_write() you * have to arrange to drain the incoming queue yourself. - * - * @param connection the connection - * @param timeout_milliseconds max time to block or -1 for infinite + * + * @param connection the connection + * @param timeout_milliseconds max time to block or -1 for infinite * @returns #TRUE if still connected */ -dbus_bool_t -dbus_connection_read_write (DBusConnection *connection, - int timeout_milliseconds) -{ +dbus_bool_t +dbus_connection_read_write (DBusConnection *connection, + int timeout_milliseconds) +{ _dbus_return_val_if_fail (connection != NULL, FALSE); _dbus_return_val_if_fail (timeout_milliseconds >= 0 || timeout_milliseconds == -1, FALSE); return _dbus_connection_read_write_dispatch(connection, timeout_milliseconds, FALSE); @@ -3830,7 +3830,7 @@ check_disconnected_message_arrived_unlocked (DBusConnection *connection, /** * Returns the first-received message from the incoming message queue, * leaving it in the queue. If the queue is empty, returns #NULL. - * + * * The caller does not own a reference to the returned message, and * must either return it using dbus_connection_return_message() or * keep it after calling dbus_connection_steal_borrowed_message(). No @@ -3855,14 +3855,14 @@ dbus_connection_borrow_message (DBusConnection *connection) _dbus_return_val_if_fail (connection != NULL, NULL); _dbus_verbose ("start\n"); - + /* this is called for the side effect that it queues * up any messages from the transport */ status = dbus_connection_get_dispatch_status (connection); if (status != DBUS_DISPATCH_DATA_REMAINS) return NULL; - + CONNECTION_LOCK (connection); _dbus_connection_acquire_dispatch (connection); @@ -3871,11 +3871,11 @@ dbus_connection_borrow_message (DBusConnection *connection) _dbus_assert (connection->message_borrowed == NULL); connection->message_borrowed = _dbus_list_get_first (&connection->incoming_messages); - + message = connection->message_borrowed; check_disconnected_message_arrived_unlocked (connection, message); - + /* Note that we KEEP the dispatch lock until the message is returned */ if (message == NULL) _dbus_connection_release_dispatch (connection); @@ -3885,7 +3885,7 @@ dbus_connection_borrow_message (DBusConnection *connection) _dbus_message_trace_ref (message, -1, -1, "dbus_connection_borrow_message"); /* We don't update dispatch status until it's returned or stolen */ - + return message; } @@ -3902,19 +3902,19 @@ dbus_connection_return_message (DBusConnection *connection, DBusMessage *message) { DBusDispatchStatus status; - + _dbus_return_if_fail (connection != NULL); _dbus_return_if_fail (message != NULL); _dbus_return_if_fail (message == connection->message_borrowed); _dbus_return_if_fail (connection->dispatch_acquired); - + CONNECTION_LOCK (connection); - + _dbus_assert (message == connection->message_borrowed); - + connection->message_borrowed = NULL; - _dbus_connection_release_dispatch (connection); + _dbus_connection_release_dispatch (connection); status = _dbus_connection_get_dispatch_status_unlocked (connection); _dbus_connection_update_dispatch_status_and_unlock (connection, status); @@ -3942,9 +3942,9 @@ dbus_connection_steal_borrowed_message (DBusConnection *connection, _dbus_return_if_fail (message != NULL); _dbus_return_if_fail (message == connection->message_borrowed); _dbus_return_if_fail (connection->dispatch_acquired); - + CONNECTION_LOCK (connection); - + _dbus_assert (message == connection->message_borrowed); pop_message = _dbus_list_pop_first (&connection->incoming_messages); @@ -3952,10 +3952,10 @@ dbus_connection_steal_borrowed_message (DBusConnection *connection, (void) pop_message; /* unused unless asserting */ connection->n_incoming -= 1; - + _dbus_verbose ("Incoming message %p stolen from queue, %d incoming\n", message, connection->n_incoming); - + connection->message_borrowed = NULL; _dbus_connection_release_dispatch (connection); @@ -3973,9 +3973,9 @@ static DBusList* _dbus_connection_pop_message_link_unlocked (DBusConnection *connection) { HAVE_LOCK_CHECK (connection); - + _dbus_assert (connection->message_borrowed == NULL); - + if (connection->n_incoming > 0) { DBusList *link; @@ -4003,7 +4003,7 @@ _dbus_connection_pop_message_link_unlocked (DBusConnection *connection) "_dbus_connection_pop_message_link_unlocked"); check_disconnected_message_arrived_unlocked (connection, link->data); - + return link; } else @@ -4019,17 +4019,17 @@ _dbus_connection_pop_message_unlocked (DBusConnection *connection) DBusList *link; HAVE_LOCK_CHECK (connection); - + link = _dbus_connection_pop_message_link_unlocked (connection); if (link != NULL) { DBusMessage *message; - + message = link->data; - + _dbus_list_free_link (link); - + return message; } else @@ -4041,7 +4041,7 @@ _dbus_connection_putback_message_link_unlocked (DBusConnection *connection, DBusList *message_link) { HAVE_LOCK_CHECK (connection); - + _dbus_assert (message_link != NULL); /* You can't borrow a message while a link is outstanding */ _dbus_assert (connection->message_borrowed == NULL); @@ -4083,7 +4083,7 @@ _dbus_connection_putback_message_link_unlocked (DBusConnection *connection, * queue, so dbus_connection_dispatch(), dbus_connection_pop_message(), * dbus_connection_borrow_message(), etc. will all block while one of the others * in the group is running. - * + * * @param connection the connection. * @returns next message in the incoming queue. */ @@ -4094,27 +4094,27 @@ dbus_connection_pop_message (DBusConnection *connection) DBusDispatchStatus status; _dbus_verbose ("start\n"); - + /* this is called for the side effect that it queues * up any messages from the transport */ status = dbus_connection_get_dispatch_status (connection); if (status != DBUS_DISPATCH_DATA_REMAINS) return NULL; - + CONNECTION_LOCK (connection); _dbus_connection_acquire_dispatch (connection); HAVE_LOCK_CHECK (connection); - + message = _dbus_connection_pop_message_unlocked (connection); - _dbus_verbose ("Returning popped message %p\n", message); + _dbus_verbose ("Returning popped message %p\n", message); _dbus_connection_release_dispatch (connection); status = _dbus_connection_get_dispatch_status_unlocked (connection); _dbus_connection_update_dispatch_status_and_unlock (connection, status); - + return message; } @@ -4132,24 +4132,24 @@ _dbus_connection_acquire_dispatch (DBusConnection *connection) _dbus_connection_ref_unlocked (connection); CONNECTION_UNLOCK (connection); - + _dbus_verbose ("locking dispatch_mutex\n"); _dbus_cmutex_lock (connection->dispatch_mutex); while (connection->dispatch_acquired) { _dbus_verbose ("waiting for dispatch to be acquirable\n"); - _dbus_condvar_wait (connection->dispatch_cond, + _dbus_condvar_wait (connection->dispatch_cond, connection->dispatch_mutex); } - + _dbus_assert (!connection->dispatch_acquired); connection->dispatch_acquired = TRUE; _dbus_verbose ("unlocking dispatch_mutex\n"); _dbus_cmutex_unlock (connection->dispatch_mutex); - + CONNECTION_LOCK (connection); _dbus_connection_unref_unlocked (connection); } @@ -4165,10 +4165,10 @@ static void _dbus_connection_release_dispatch (DBusConnection *connection) { HAVE_LOCK_CHECK (connection); - + _dbus_verbose ("locking dispatch_mutex\n"); _dbus_cmutex_lock (connection->dispatch_mutex); - + _dbus_assert (connection->dispatch_acquired); connection->dispatch_acquired = FALSE; @@ -4208,15 +4208,15 @@ notify_disconnected_unlocked (DBusConnection *connection) if (connection->n_outgoing > 0) { DBusList *link; - + _dbus_verbose ("Dropping %d outgoing messages since we're disconnected\n", connection->n_outgoing); - + while ((link = _dbus_list_get_last_link (&connection->outgoing_messages))) { _dbus_connection_message_sent_unlocked (connection, link->data); } - } + } } /* Note this may be called multiple times since we don't track whether we already did it */ @@ -4224,16 +4224,16 @@ static DBusDispatchStatus notify_disconnected_and_dispatch_complete_unlocked (DBusConnection *connection) { HAVE_LOCK_CHECK (connection); - + if (connection->disconnect_message_link != NULL) { _dbus_verbose ("Sending disconnect message\n"); - + /* If we have pending calls, queue their timeouts - we want the Disconnected * to be the last message, after these timeouts. */ connection_timeout_and_complete_all_pending_calls_unlocked (connection); - + /* We haven't sent the disconnect message already, * and all real messages have been queued up. */ @@ -4251,7 +4251,7 @@ static DBusDispatchStatus _dbus_connection_get_dispatch_status_unlocked (DBusConnection *connection) { HAVE_LOCK_CHECK (connection); - + if (connection->n_incoming > 0) return DBUS_DISPATCH_DATA_REMAINS; else if (!_dbus_transport_queue_messages (connection->transport)) @@ -4260,13 +4260,13 @@ _dbus_connection_get_dispatch_status_unlocked (DBusConnection *connection) { DBusDispatchStatus status; dbus_bool_t is_connected; - + status = _dbus_transport_get_dispatch_status (connection->transport); is_connected = _dbus_transport_get_is_connected (connection->transport); _dbus_verbose ("dispatch status = %s is_connected = %d\n", DISPATCH_STATUS_NAME (status), is_connected); - + if (!is_connected) { /* It's possible this would be better done by having an explicit @@ -4285,7 +4285,7 @@ _dbus_connection_get_dispatch_status_unlocked (DBusConnection *connection) if (status == DBUS_DISPATCH_COMPLETE) status = notify_disconnected_and_dispatch_complete_unlocked (connection); } - + if (status != DBUS_DISPATCH_COMPLETE) return status; else if (connection->n_incoming > 0) @@ -4318,7 +4318,7 @@ _dbus_connection_update_dispatch_status_and_unlock (DBusConnection *connectio !connection->disconnected_message_processed) { connection->disconnected_message_processed = TRUE; - + /* this does an unref, but we have a ref * so we should not run the finalizer here * inside the lock. @@ -4327,25 +4327,25 @@ _dbus_connection_update_dispatch_status_and_unlock (DBusConnection *connectio if (connection->exit_on_disconnect) { - CONNECTION_UNLOCK (connection); - + CONNECTION_UNLOCK (connection); + _dbus_verbose ("Exiting on Disconnected signal\n"); _dbus_exit (1); _dbus_assert_not_reached ("Call to exit() returned"); } } - + /* We drop the lock */ CONNECTION_UNLOCK (connection); - + if (changed && function) { _dbus_verbose ("Notifying of change to dispatch status of %p now %d (%s)\n", connection, new_status, DISPATCH_STATUS_NAME (new_status)); - (* function) (connection, new_status, data); + (* function) (connection, new_status, data); } - + dbus_connection_unref (connection); } @@ -4370,7 +4370,7 @@ _dbus_connection_update_dispatch_status_and_unlock (DBusConnection *connectio * In particular this happens on initial connection, because all sorts * of authentication protocol stuff has to be parsed before the * first message arrives. - * + * * @param connection the connection. * @returns current dispatch status */ @@ -4382,11 +4382,11 @@ dbus_connection_get_dispatch_status (DBusConnection *connection) _dbus_return_val_if_fail (connection != NULL, DBUS_DISPATCH_COMPLETE); _dbus_verbose ("start\n"); - + CONNECTION_LOCK (connection); status = _dbus_connection_get_dispatch_status_unlocked (connection); - + CONNECTION_UNLOCK (connection); return status; @@ -4436,7 +4436,7 @@ _dbus_connection_peer_filter_unlocked_no_update (DBusConnection *connection, "GetMachineId")) { DBusString uuid; - + ret = dbus_message_new_method_return (message); if (ret == NULL) goto out; @@ -4513,7 +4513,7 @@ _dbus_connection_run_builtin_filters_unlocked_no_update (DBusConnection *connect * The incoming data buffer is filled when the connection reads from * its underlying transport (such as a socket). Reading usually * happens in dbus_watch_handle() or dbus_connection_read_write(). - * + * * If there are complete messages in the incoming queue, * dbus_connection_dispatch() removes one message from the queue and * processes it. Processing has three steps. @@ -4521,7 +4521,7 @@ _dbus_connection_run_builtin_filters_unlocked_no_update (DBusConnection *connect * First, any method replies are passed to #DBusPendingCall or * dbus_connection_send_with_reply_and_block() in order to * complete the pending method call. - * + * * Second, any filters registered with dbus_connection_add_filter() * are run. If any filter returns #DBUS_HANDLER_RESULT_HANDLED * then processing stops after that filter. @@ -4539,9 +4539,9 @@ _dbus_connection_run_builtin_filters_unlocked_no_update (DBusConnection *connect * recursively. If threads have been initialized with a recursive * mutex function, then this will not deadlock; however, it can * certainly confuse your application. - * + * * @todo some FIXME in here about handling DBUS_HANDLER_RESULT_NEED_MEMORY - * + * * @param connection the connection * @returns dispatch status, see dbus_connection_get_dispatch_status() */ @@ -4559,7 +4559,7 @@ dbus_connection_dispatch (DBusConnection *connection) _dbus_return_val_if_fail (connection != NULL, DBUS_DISPATCH_COMPLETE); _dbus_verbose ("\n"); - + CONNECTION_LOCK (connection); status = _dbus_connection_get_dispatch_status_unlocked (connection); if (status != DBUS_DISPATCH_DATA_REMAINS) @@ -4568,7 +4568,7 @@ dbus_connection_dispatch (DBusConnection *connection) _dbus_connection_update_dispatch_status_and_unlock (connection, status); return status; } - + /* We need to ref the connection since the callback could potentially * drop the last ref to it */ @@ -4583,15 +4583,15 @@ dbus_connection_dispatch (DBusConnection *connection) /* another thread dispatched our stuff */ _dbus_verbose ("another thread dispatched message (during acquire_dispatch above)\n"); - + _dbus_connection_release_dispatch (connection); status = _dbus_connection_get_dispatch_status_unlocked (connection); _dbus_connection_update_dispatch_status_and_unlock (connection, status); - + dbus_connection_unref (connection); - + return status; } @@ -4609,14 +4609,14 @@ dbus_connection_dispatch (DBusConnection *connection) dbus_message_get_signature (message)); result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - + /* Pending call handling must be first, because if you do * dbus_connection_send_with_reply_and_block() or * dbus_pending_call_block() then no handlers/filters will be run on * the reply. We want consistent semantics in the case where we * dbus_connection_dispatch() the reply. */ - + reply_serial = dbus_message_get_reply_serial (message); pending = _dbus_hash_table_lookup_int (connection->pending_replies, reply_serial); @@ -4625,7 +4625,7 @@ dbus_connection_dispatch (DBusConnection *connection) _dbus_verbose ("Dispatching a pending reply\n"); complete_pending_call_and_unlock (connection, pending, message); pending = NULL; /* it's probably unref'd */ - + CONNECTION_LOCK (connection); _dbus_verbose ("pending call completed in dispatch\n"); result = DBUS_HANDLER_RESULT_HANDLED; @@ -4635,22 +4635,22 @@ dbus_connection_dispatch (DBusConnection *connection) result = _dbus_connection_run_builtin_filters_unlocked_no_update (connection, message); if (result != DBUS_HANDLER_RESULT_NOT_YET_HANDLED) goto out; - + if (!_dbus_list_copy (&connection->filter_list, &filter_list_copy)) { _dbus_connection_release_dispatch (connection); HAVE_LOCK_CHECK (connection); - + _dbus_connection_failed_pop (connection, message_link); /* unlocks and calls user code */ _dbus_connection_update_dispatch_status_and_unlock (connection, DBUS_DISPATCH_NEED_MEMORY); dbus_connection_unref (connection); - + return DBUS_DISPATCH_NEED_MEMORY; } - + _dbus_list_foreach (&filter_list_copy, (DBusForeachFunction)_dbus_message_filter_ref, NULL); @@ -4659,7 +4659,7 @@ dbus_connection_dispatch (DBusConnection *connection) * since we acquired the dispatcher */ CONNECTION_UNLOCK (connection); - + link = _dbus_list_get_first_link (&filter_list_copy); while (link != NULL) { @@ -4686,7 +4686,7 @@ dbus_connection_dispatch (DBusConnection *connection) (DBusForeachFunction)_dbus_message_filter_unref, NULL); _dbus_list_clear (&filter_list_copy); - + CONNECTION_LOCK (connection); if (result == DBUS_HANDLER_RESULT_NEED_MEMORY) @@ -4718,7 +4718,7 @@ dbus_connection_dispatch (DBusConnection *connection) result = _dbus_object_tree_dispatch_and_unlock (connection->objects, message, &found_object); - + CONNECTION_LOCK (connection); if (result != DBUS_HANDLER_RESULT_NOT_YET_HANDLED) @@ -4743,7 +4743,7 @@ dbus_connection_dispatch (DBusConnection *connection) _dbus_verbose ("no memory for error string in dispatch\n"); goto out; } - + if (!_dbus_string_append_printf (&str, "Method \"%s\" with signature \"%s\" on interface \"%s\" doesn't exist\n", dbus_message_get_member (message), @@ -4755,7 +4755,7 @@ dbus_connection_dispatch (DBusConnection *connection) _dbus_verbose ("no memory for error string in dispatch\n"); goto out; } - + reply = dbus_message_new_error (message, found_object ? DBUS_ERROR_UNKNOWN_METHOD : DBUS_ERROR_UNKNOWN_OBJECT, _dbus_string_get_const_data (&str)); @@ -4798,7 +4798,7 @@ dbus_connection_dispatch (DBusConnection *connection) result = DBUS_HANDLER_RESULT_HANDLED; } - + _dbus_verbose (" done dispatching %p (%s %s %s '%s') on connection %p\n", message, dbus_message_type_to_string (dbus_message_get_type (message)), dbus_message_get_interface (message) ? @@ -4809,12 +4809,12 @@ dbus_connection_dispatch (DBusConnection *connection) "no member", dbus_message_get_signature (message), connection); - + out: if (result == DBUS_HANDLER_RESULT_NEED_MEMORY) { _dbus_verbose ("out of memory\n"); - + /* Put message back, and we'll start over. * Yes this means handlers must be idempotent if they * don't return HANDLED; c'est la vie. @@ -4855,9 +4855,9 @@ dbus_connection_dispatch (DBusConnection *connection) /* unlocks and calls user code */ _dbus_connection_update_dispatch_status_and_unlock (connection, status); - + dbus_connection_unref (connection); - + return status; } @@ -4879,7 +4879,7 @@ dbus_connection_dispatch (DBusConnection *connection) * enabling/disabling can be done without memory allocation. The * toggled function may be NULL if a main loop re-queries * dbus_watch_get_enabled() every time anyway. - * + * * The DBusWatch can be queried for the file descriptor to watch using * dbus_watch_get_unix_fd() or dbus_watch_get_socket(), and for the * events to watch for using dbus_watch_get_flags(). The flags @@ -4896,7 +4896,7 @@ dbus_connection_dispatch (DBusConnection *connection) * dbus_watch_handle() cannot be called during the * DBusAddWatchFunction, as the connection will not be ready to handle * that watch yet. - * + * * It is not allowed to reference a DBusWatch after it has been passed * to remove_function. * @@ -4913,7 +4913,7 @@ dbus_connection_dispatch (DBusConnection *connection) * may not invoke any methods on DBusConnection or it will deadlock. * See the comments in the code or http://lists.freedesktop.org/archives/dbus/2007-July/tread.html#8144 * if you encounter this issue and want to attempt writing a patch. - * + * * @param connection the connection. * @param add_function function to begin monitoring a new descriptor. * @param remove_function function to stop monitoring a descriptor. @@ -4933,7 +4933,7 @@ dbus_connection_set_watch_functions (DBusConnection *connection, dbus_bool_t retval; _dbus_return_val_if_fail (connection != NULL, FALSE); - + CONNECTION_LOCK (connection); retval = _dbus_watch_list_set_functions (connection->watches, @@ -4952,7 +4952,7 @@ dbus_connection_set_watch_functions (DBusConnection *connection, * When using Qt, typically the DBusAddTimeoutFunction would create a * QTimer. When using GLib, the DBusAddTimeoutFunction would call * g_timeout_add. - * + * * The DBusTimeoutToggledFunction notifies the application that the * timeout has been enabled or disabled. Call * dbus_timeout_get_enabled() to check this. A disabled timeout should @@ -4996,7 +4996,7 @@ dbus_connection_set_timeout_functions (DBusConnection *connection, dbus_bool_t retval; _dbus_return_val_if_fail (connection != NULL, FALSE); - + CONNECTION_LOCK (connection); retval = _dbus_timeout_list_set_functions (connection->timeouts, @@ -5033,7 +5033,7 @@ dbus_connection_set_wakeup_main_function (DBusConnection *connection, DBusFreeFunction old_free_data; _dbus_return_if_fail (connection != NULL); - + CONNECTION_LOCK (connection); old_data = connection->wakeup_main_data; old_free_data = connection->free_wakeup_main_data; @@ -5041,7 +5041,7 @@ dbus_connection_set_wakeup_main_function (DBusConnection *connection, connection->wakeup_main_function = wakeup_main_function; connection->wakeup_main_data = data; connection->free_wakeup_main_data = free_data_function; - + CONNECTION_UNLOCK (connection); /* Callback outside the lock */ @@ -5079,7 +5079,7 @@ dbus_connection_set_dispatch_status_function (DBusConnection *connec DBusFreeFunction old_free_data; _dbus_return_if_fail (connection != NULL); - + CONNECTION_LOCK (connection); old_data = connection->dispatch_status_data; old_free_data = connection->free_dispatch_status_data; @@ -5087,7 +5087,7 @@ dbus_connection_set_dispatch_status_function (DBusConnection *connec connection->dispatch_status_function = function; connection->dispatch_status_data = data; connection->free_dispatch_status_data = free_data_function; - + CONNECTION_UNLOCK (connection); /* Callback outside the lock */ @@ -5109,7 +5109,7 @@ dbus_connection_set_dispatch_status_function (DBusConnection *connec * * Right now the returned descriptor is always a socket, but * that is not guaranteed. - * + * * @param connection the connection * @param fd return location for the file descriptor. * @returns #TRUE if fd is successfully obtained. @@ -5125,7 +5125,7 @@ dbus_connection_get_unix_fd (DBusConnection *connection, /* FIXME do this on a lower level */ return FALSE; #endif - + return dbus_connection_get_socket(connection, fd); } @@ -5139,7 +5139,7 @@ dbus_connection_get_unix_fd (DBusConnection *connection, * If the connection is not socket-based, this function will return FALSE, * even if the connection does have a file descriptor of some kind. * i.e. this function always returns specifically a socket file descriptor. - * + * * @param connection the connection * @param fd return location for the file descriptor. * @returns #TRUE if fd is successfully obtained. @@ -5152,9 +5152,9 @@ dbus_connection_get_socket(DBusConnection *connection, _dbus_return_val_if_fail (connection != NULL, FALSE); _dbus_return_val_if_fail (connection->transport != NULL, FALSE); - + CONNECTION_LOCK (connection); - + retval = _dbus_transport_get_socket_fd (connection->transport, fd); @@ -5206,7 +5206,7 @@ dbus_connection_get_unix_user (DBusConnection *connection, #ifdef DBUS_WIN _dbus_assert (!result); #endif - + CONNECTION_UNLOCK (connection); return result; @@ -5295,7 +5295,7 @@ dbus_connection_get_adt_audit_session_data (DBusConnection *connection, * However, the function will never be called, because there are * no UNIX user ids to pass to it, or at least none of the existing * auth protocols would allow authenticating as a UNIX user on Windows. - * + * * @param connection the connection * @param function the predicate * @param data data to pass to the predicate @@ -5311,7 +5311,7 @@ dbus_connection_set_unix_user_function (DBusConnection *connection, DBusFreeFunction old_free_function = NULL; _dbus_return_if_fail (connection != NULL); - + CONNECTION_LOCK (connection); _dbus_transport_set_unix_user_function (connection->transport, function, data, free_data_function, @@ -5368,7 +5368,7 @@ _dbus_connection_get_linux_security_label (DBusConnection *connection, * The return value indicates whether the user SID is available; * if it's available but we don't have the memory to copy it, * then the return value is #TRUE and #NULL is given as the SID. - * + * * @todo We would like to be able to say "You can ask the bus to tell * you the user of another connection though if you like; this is done * with dbus_bus_get_windows_user()." But this has to be implemented @@ -5399,7 +5399,7 @@ dbus_connection_get_windows_user (DBusConnection *connection, #ifdef DBUS_UNIX _dbus_assert (!result); #endif - + CONNECTION_UNLOCK (connection); return result; @@ -5420,7 +5420,7 @@ dbus_connection_get_windows_user (DBusConnection *connection, * be invoked when the connection is freed or a new function is set. * However, the function will never be called, because there is no * way right now to authenticate as a Windows user on UNIX. - * + * * @param connection the connection * @param function the predicate * @param data data to pass to the predicate @@ -5436,7 +5436,7 @@ dbus_connection_set_windows_user_function (DBusConnection *connecti DBusFreeFunction old_free_function = NULL; _dbus_return_if_fail (connection != NULL); - + CONNECTION_LOCK (connection); _dbus_transport_set_windows_user_function (connection->transport, function, data, free_data_function, @@ -5453,7 +5453,7 @@ dbus_connection_set_windows_user_function (DBusConnection *connecti * #TRUE (the default is #FALSE), then the connection can proceed even if * the client does not authenticate as some user identity, i.e. clients * can connect anonymously. - * + * * This setting interacts with the available authorization mechanisms * (see dbus_server_set_auth_mechanisms()). Namely, an auth mechanism * such as ANONYMOUS that supports anonymous auth must be included in @@ -5469,7 +5469,7 @@ dbus_connection_set_windows_user_function (DBusConnection *connecti * You can override the rules for connections authorized as a * user identity with dbus_connection_set_unix_user_function() * and dbus_connection_set_windows_user_function(). - * + * * @param connection the connection * @param value whether to allow authentication as an anonymous user */ @@ -5478,7 +5478,7 @@ dbus_connection_set_allow_anonymous (DBusConnection *connection, dbus_bool_t value) { _dbus_return_if_fail (connection != NULL); - + CONNECTION_LOCK (connection); _dbus_transport_set_allow_anonymous (connection->transport, value); CONNECTION_UNLOCK (connection); @@ -5506,7 +5506,7 @@ dbus_connection_set_route_peer_messages (DBusConnection *connection, dbus_bool_t value) { _dbus_return_if_fail (connection != NULL); - + CONNECTION_LOCK (connection); connection->route_peer_messages = value; CONNECTION_UNLOCK (connection); @@ -5540,7 +5540,7 @@ dbus_connection_add_filter (DBusConnection *connection, DBusFreeFunction free_data_function) { DBusMessageFilter *filter; - + _dbus_return_val_if_fail (connection != NULL, FALSE); _dbus_return_val_if_fail (function != NULL, FALSE); @@ -5564,11 +5564,11 @@ dbus_connection_add_filter (DBusConnection *connection, * so we don't run the free_user_data_function * if the add_filter() fails */ - + filter->function = function; filter->user_data = user_data; filter->free_user_data_function = free_data_function; - + CONNECTION_UNLOCK (connection); return TRUE; } @@ -5592,14 +5592,14 @@ dbus_connection_remove_filter (DBusConnection *connection, { DBusList *link; DBusMessageFilter *filter; - + _dbus_return_if_fail (connection != NULL); _dbus_return_if_fail (function != NULL); - + CONNECTION_LOCK (connection); filter = NULL; - + link = _dbus_list_get_last_link (&connection->filter_list); while (link != NULL) { @@ -5610,14 +5610,14 @@ dbus_connection_remove_filter (DBusConnection *connection, { _dbus_list_remove_link (&connection->filter_list, link); filter->function = NULL; - + break; } - + link = _dbus_list_get_prev_link (&connection->filter_list, link); filter = NULL; } - + CONNECTION_UNLOCK (connection); #ifndef DBUS_DISABLE_CHECKS @@ -5628,14 +5628,14 @@ dbus_connection_remove_filter (DBusConnection *connection, return; } #endif - + /* Call application code */ if (filter->free_user_data_function) (* filter->free_user_data_function) (filter->user_data); filter->free_user_data_function = NULL; filter->user_data = NULL; - + _dbus_message_filter_unref (filter); } @@ -5665,7 +5665,7 @@ _dbus_connection_register_object_path (DBusConnection *connection, char **decomposed_path; dbus_bool_t retval; - if (!_dbus_decompose_path (path, strlen (path), &decomposed_path, NULL)) + if (!_dbus_decompose_path (path, (int) strlen (path), &decomposed_path, NULL)) return FALSE; CONNECTION_LOCK (connection); @@ -5841,7 +5841,7 @@ dbus_connection_unregister_object_path (DBusConnection *connection, _dbus_return_val_if_fail (path != NULL, FALSE); _dbus_return_val_if_fail (path[0] == '/', FALSE); - if (!_dbus_decompose_path (path, strlen (path), &decomposed_path, NULL)) + if (!_dbus_decompose_path (path, (int) strlen (path), &decomposed_path, NULL)) return FALSE; CONNECTION_LOCK (connection); @@ -5875,10 +5875,10 @@ dbus_connection_get_object_path_data (DBusConnection *connection, _dbus_return_val_if_fail (data_p != NULL, FALSE); *data_p = NULL; - - if (!_dbus_decompose_path (path, strlen (path), &decomposed_path, NULL)) + + if (!_dbus_decompose_path (path, (int) strlen (path), &decomposed_path, NULL)) return FALSE; - + CONNECTION_LOCK (connection); *data_p = _dbus_object_tree_get_user_data_unlocked (connection->objects, (const char**) decomposed_path); @@ -5912,7 +5912,7 @@ dbus_connection_list_registered (DBusConnection *connection, _dbus_return_val_if_fail (parent_path[0] == '/', FALSE); _dbus_return_val_if_fail (child_entries != NULL, FALSE); - if (!_dbus_decompose_path (parent_path, strlen (parent_path), &decomposed_path, NULL)) + if (!_dbus_decompose_path (parent_path, (int) strlen (parent_path), &decomposed_path, NULL)) return FALSE; CONNECTION_LOCK (connection); @@ -5935,7 +5935,7 @@ static DBusDataSlotAllocator slot_allocator = * The passed-in slot must be initialized to -1, and is filled in * with the slot ID. If the passed-in slot is not -1, it's assumed * to be already allocated, and its refcount is incremented. - * + * * The allocated slot is global, i.e. all DBusConnection objects will * have a slot with the given integer ID reserved. * @@ -5964,7 +5964,7 @@ void dbus_connection_free_data_slot (dbus_int32_t *slot_p) { _dbus_return_if_fail (*slot_p >= 0); - + _dbus_data_slot_allocator_free (&slot_allocator, slot_p); } @@ -6002,14 +6002,14 @@ dbus_connection_set_data (DBusConnection *connection, _dbus_return_val_if_fail (connection != NULL, FALSE); _dbus_return_val_if_fail (slot >= 0, FALSE); - + SLOTS_LOCK (connection); retval = _dbus_data_slot_list_set (&slot_allocator, &connection->slot_list, slot, data, free_data_func, &old_free_func, &old_data); - + SLOTS_UNLOCK (connection); if (retval) @@ -6053,7 +6053,7 @@ dbus_connection_get_data (DBusConnection *connection, res = _dbus_data_slot_list_get (&slot_allocator, &connection->slot_list, slot); - + SLOTS_UNLOCK (connection); return res; @@ -6067,7 +6067,7 @@ dbus_connection_get_data (DBusConnection *connection, */ void dbus_connection_set_change_sigpipe (dbus_bool_t will_modify_sigpipe) -{ +{ _dbus_modify_sigpipe = will_modify_sigpipe != FALSE; } @@ -6075,7 +6075,7 @@ dbus_connection_set_change_sigpipe (dbus_bool_t will_modify_sigpipe) * Specifies the maximum size message this connection is allowed to * receive. Larger messages will result in disconnecting the * connection. - * + * * @param connection a #DBusConnection * @param size maximum message size the connection can receive, in bytes */ @@ -6084,7 +6084,7 @@ dbus_connection_set_max_message_size (DBusConnection *connection, long size) { _dbus_return_if_fail (connection != NULL); - + CONNECTION_LOCK (connection); _dbus_transport_set_max_message_size (connection->transport, size); @@ -6103,7 +6103,7 @@ dbus_connection_get_max_message_size (DBusConnection *connection) long res; _dbus_return_val_if_fail (connection != NULL, 0); - + CONNECTION_LOCK (connection); res = _dbus_transport_get_max_message_size (connection->transport); CONNECTION_UNLOCK (connection); @@ -6163,7 +6163,7 @@ dbus_connection_get_max_message_unix_fds (DBusConnection *connection) * * Thus, the max live messages size can actually be exceeded * by up to the maximum size of a single message. - * + * * Also, if we read say 1024 bytes off the wire in a single read(), * and that contains a half-dozen small messages, we may exceed the * size max by that amount. But this should be inconsequential. @@ -6179,7 +6179,7 @@ dbus_connection_set_max_received_size (DBusConnection *connection, long size) { _dbus_return_if_fail (connection != NULL); - + CONNECTION_LOCK (connection); _dbus_transport_set_max_received_size (connection->transport, size); @@ -6198,7 +6198,7 @@ dbus_connection_get_max_received_size (DBusConnection *connection) long res; _dbus_return_val_if_fail (connection != NULL, 0); - + CONNECTION_LOCK (connection); res = _dbus_transport_get_max_received_size (connection->transport); CONNECTION_UNLOCK (connection); diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c index c7f81e5..950a7eb 100644 --- a/dbus/dbus-internals.c +++ b/dbus/dbus-internals.c @@ -4,7 +4,7 @@ * Copyright (C) 2002, 2003 Red Hat, Inc. * * Licensed under the Academic Free License version 2.1 - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -14,7 +14,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA @@ -39,7 +39,7 @@ /** * @defgroup DBusInternals D-Bus secret internal implementation details * @brief Documentation useful when developing or debugging D-Bus itself. - * + * */ /** @@ -53,7 +53,7 @@ * @def _dbus_assert * * Aborts with an error message if the condition is false. - * + * * @param condition condition which must be true. */ @@ -62,7 +62,7 @@ * * Aborts with an error message if called. * The given explanation will be printed. - * + * * @param explanation explanation of what happened if the code was reached. */ @@ -151,7 +151,7 @@ /** * @typedef DBusForeachFunction - * + * * Used to iterate over each item in a collection, such as * a DBusList. */ @@ -234,7 +234,7 @@ _dbus_warn (const char *format, if (!warn_initted) init_warnings (); - + va_start (args, format); vfprintf (stderr, format, args); va_end (args); @@ -259,12 +259,12 @@ _dbus_warn_check_failed(const char *format, ...) { va_list args; - + if (!warn_initted) init_warnings (); fprintf (stderr, "process %lu: ", _dbus_pid_for_log ()); - + va_start (args, format); vfprintf (stderr, format, args); va_end (args); @@ -317,19 +317,19 @@ _dbus_verbose_init (void) /** @def DBUS_IS_DIR_SEPARATOR(c) * macro for checking if character c is a patch separator - * + * * @todo move to a header file so that others can use this too */ -#ifdef DBUS_WIN +#ifdef DBUS_WIN #define DBUS_IS_DIR_SEPARATOR(c) (c == '\\' || c == '/') #else #define DBUS_IS_DIR_SEPARATOR(c) (c == '/') #endif -/** - remove source root from file path - the source root is determined by -*/ +/** + remove source root from file path + the source root is determined by +*/ static char *_dbus_file_path_extract_elements_from_tail(const char *file,int level) { int prefix = 0; @@ -385,8 +385,8 @@ void _dbus_verbose_real ( #ifdef DBUS_CPP_SUPPORTS_VARIABLE_MACRO_ARGUMENTS const char *file, - const int line, - const char *function, + const int line, + const char *function, #endif const char *format, ...) @@ -394,7 +394,7 @@ _dbus_verbose_real ( va_list args; static dbus_bool_t need_pid = TRUE; int len; - + /* things are written a bit oddly here so that * in the non-verbose case we just have the one * conditional and return immediately. @@ -415,7 +415,7 @@ _dbus_verbose_real ( #endif /* Only print pid again if the next line is a new line */ - len = strlen (format); + len = (int) strlen (format); if (format[len-1] == '\n') need_pid = TRUE; else @@ -529,7 +529,7 @@ _dbus_trace_ref (const char *obj_name, * Duplicates a string. Result must be freed with * dbus_free(). Returns #NULL if memory allocation fails. * If the string to be duplicated is #NULL, returns #NULL. - * + * * @param str string to duplicate. * @returns newly-allocated copy. */ @@ -538,10 +538,10 @@ _dbus_strdup (const char *str) { size_t len; char *copy; - + if (str == NULL) return NULL; - + len = strlen (str); copy = dbus_malloc (len + 1); @@ -549,7 +549,7 @@ _dbus_strdup (const char *str) return NULL; memcpy (copy, str, len + 1); - + return copy; } @@ -572,7 +572,7 @@ _dbus_memdup (const void *mem, return NULL; memcpy (copy, mem, n_bytes); - + return copy; } @@ -580,7 +580,7 @@ _dbus_memdup (const void *mem, * Duplicates a string array. Result may be freed with * dbus_free_string_array(). Returns #NULL if memory allocation fails. * If the array to be duplicated is #NULL, returns #NULL. - * + * * @param array array to duplicate. * @returns newly-allocated copy. */ @@ -590,7 +590,7 @@ _dbus_dup_string_array (const char **array) int len; int i; char **copy; - + if (array == NULL) return NULL; @@ -619,7 +619,7 @@ _dbus_dup_string_array (const char **array) /** * Checks whether a string array contains the given string. - * + * * @param array array to search. * @param str string to look for * @returns #TRUE if array contains string @@ -658,7 +658,7 @@ _dbus_generate_uuid (DBusGUID *uuid) _dbus_get_real_time (&now, NULL); uuid->as_uint32s[DBUS_UUID_LENGTH_WORDS - 1] = DBUS_UINT32_TO_BE (now); - + _dbus_generate_random_bytes_buffer (uuid->as_bytes, DBUS_UUID_LENGTH_BYTES - 4); } @@ -686,7 +686,7 @@ _dbus_read_uuid_file_without_creating (const DBusString *filename, DBusString contents; DBusString decoded; int end; - + if (!_dbus_string_init (&contents)) { _DBUS_SET_OOM (error); @@ -699,7 +699,7 @@ _dbus_read_uuid_file_without_creating (const DBusString *filename, _DBUS_SET_OOM (error); return FALSE; } - + if (!_dbus_file_get_contents (&contents, filename, error)) goto error; @@ -747,7 +747,7 @@ _dbus_read_uuid_file_without_creating (const DBusString *filename, _DBUS_ASSERT_ERROR_IS_CLEAR (error); return TRUE; - + error: _DBUS_ASSERT_ERROR_IS_SET (error); _dbus_string_free (&contents); @@ -775,19 +775,19 @@ _dbus_write_uuid_file (const DBusString *filename, _DBUS_SET_OOM (error); return FALSE; } - + if (!_dbus_uuid_encode (uuid, &encoded)) { _DBUS_SET_OOM (error); goto error; } - + if (!_dbus_string_append_byte (&encoded, '\n')) { _DBUS_SET_OOM (error); goto error; } - + if (!_dbus_string_save_to_file (&encoded, filename, TRUE, error)) goto error; @@ -795,11 +795,11 @@ _dbus_write_uuid_file (const DBusString *filename, _DBUS_ASSERT_ERROR_IS_CLEAR (error); return TRUE; - + error: _DBUS_ASSERT_ERROR_IS_SET (error); _dbus_string_free (&encoded); - return FALSE; + return FALSE; } /** @@ -856,7 +856,7 @@ static DBusGUID machine_uuid; * machine at least until it next reboots, though it also * makes some effort to be the same forever, it may change if the * machine is reconfigured or its hardware is modified. - * + * * @param uuid_str string to append hex-encoded machine uuid to * @returns #FALSE if no memory */ @@ -864,7 +864,7 @@ dbus_bool_t _dbus_get_local_machine_uuid_encoded (DBusString *uuid_str) { dbus_bool_t ok; - + if (!_DBUS_LOCK (machine_uuid)) return FALSE; @@ -874,7 +874,7 @@ _dbus_get_local_machine_uuid_encoded (DBusString *uuid_str) if (!_dbus_read_local_machine_uuid (&machine_uuid, FALSE, &error)) - { + { #ifndef DBUS_ENABLE_EMBEDDED_TESTS /* For the test suite, we may not be installed so just continue silently * here. But in a production build, we want to be nice and loud about @@ -884,9 +884,9 @@ _dbus_get_local_machine_uuid_encoded (DBusString *uuid_str) "See the manual page for dbus-uuidgen to correct this issue.\n", error.message); #endif - + dbus_error_free (&error); - + _dbus_generate_uuid (&machine_uuid); } } @@ -953,7 +953,7 @@ _dbus_real_assert_not_reached (const char *explanation, _dbus_abort (); } #endif /* DBUS_DISABLE_ASSERT */ - + #ifdef DBUS_ENABLE_EMBEDDED_TESTS static dbus_bool_t run_failing_each_malloc (int n_mallocs, @@ -962,9 +962,9 @@ run_failing_each_malloc (int n_mallocs, void *data) { n_mallocs += 10; /* fudge factor to ensure reallocs etc. are covered */ - + while (n_mallocs >= 0) - { + { _dbus_set_fail_alloc_counter (n_mallocs); _dbus_verbose ("\n===\n%s: (will fail malloc %d with %d failures)\n===\n", @@ -973,14 +973,14 @@ run_failing_each_malloc (int n_mallocs, if (!(* func) (data)) return FALSE; - + n_mallocs -= 1; } _dbus_set_fail_alloc_counter (_DBUS_INT_MAX); return TRUE; -} +} /** * Tests how well the given function responds to out-of-memory @@ -1006,14 +1006,14 @@ _dbus_test_oom_handling (const char *description, int i; /* Run once to see about how many mallocs are involved */ - + _dbus_set_fail_alloc_counter (_DBUS_INT_MAX); _dbus_verbose ("Running once to count mallocs\n"); - + if (!(* func) (data)) return FALSE; - + approx_mallocs = _DBUS_INT_MAX - _dbus_get_fail_alloc_counter (); _dbus_verbose ("\n=================\n%s: about %d mallocs total\n=================\n", @@ -1043,7 +1043,7 @@ _dbus_test_oom_handling (const char *description, return FALSE; ++i; } - + _dbus_verbose ("\n=================\n%s: all iterations passed\n=================\n", description); diff --git a/dbus/dbus-marshal-basic.c b/dbus/dbus-marshal-basic.c index 74fe3f9..4455c29 100644 --- a/dbus/dbus-marshal-basic.c +++ b/dbus/dbus-marshal-basic.c @@ -462,7 +462,7 @@ _dbus_marshal_read_uint32 (const DBusString *str, *new_pos = pos + 4; _dbus_assert (pos + 4 <= _dbus_string_get_length (str)); - + return _dbus_unpack_uint32 (byte_order, _dbus_string_get_const_data (str) + pos); } @@ -505,7 +505,7 @@ _dbus_marshal_read_basic (const DBusString *str, /* Below we volatile types to avoid aliasing issues; * see http://bugs.freedesktop.org/show_bug.cgi?id=20137 */ - + switch (type) { case DBUS_TYPE_BYTE: @@ -696,7 +696,7 @@ marshal_len_followed_by_bytes (int marshal_as, if (insert_at > _dbus_string_get_length (str)) _dbus_warn ("insert_at = %d string len = %d data_len = %d\n", insert_at, _dbus_string_get_length (str), data_len); - + if (marshal_as == MARSHAL_AS_BYTE_ARRAY) value_len = data_len; else @@ -710,7 +710,7 @@ marshal_len_followed_by_bytes (int marshal_as, { _dbus_assert (data_len <= DBUS_MAXIMUM_SIGNATURE_LENGTH); _dbus_assert (data_len <= 255); /* same as max sig len right now */ - + if (!_dbus_string_insert_byte (str, pos, data_len)) goto oom; @@ -757,7 +757,7 @@ marshal_string (DBusString *str, { return marshal_len_followed_by_bytes (MARSHAL_AS_STRING, str, insert_at, value, - strlen (value), + (int) strlen (value), byte_order, pos_after); } @@ -769,7 +769,7 @@ marshal_signature (DBusString *str, { return marshal_len_followed_by_bytes (MARSHAL_AS_SIGNATURE, str, insert_at, value, - strlen (value), + (int) strlen (value), DBUS_COMPILER_BYTE_ORDER, /* irrelevant */ pos_after); } @@ -899,7 +899,7 @@ _dbus_swap_array (unsigned char *data, */ d = data; end = d + (n_elements * alignment); - + if (alignment == 8) { while (d != end) @@ -919,7 +919,7 @@ _dbus_swap_array (unsigned char *data, else { _dbus_assert (alignment == 2); - + while (d != end) { *((dbus_uint16_t*)d) = DBUS_UINT16_SWAP_LE_BE (*((dbus_uint16_t*)d)); @@ -962,12 +962,12 @@ marshal_fixed_multi (DBusString *str, int len_in_bytes; _dbus_assert (n_elements <= DBUS_MAXIMUM_ARRAY_LENGTH / alignment); - + old_string_len = _dbus_string_get_length (str); len_in_bytes = n_elements * alignment; array_start = insert_at; - + /* Note that we do alignment padding unconditionally * even if the array is empty; this means that * padding + len is always equal to the number of bytes @@ -989,7 +989,7 @@ marshal_fixed_multi (DBusString *str, if (pos_after) *pos_after = array_start + len_in_bytes; - + return TRUE; error: @@ -1026,7 +1026,7 @@ _dbus_marshal_write_fixed_multi (DBusString *str, int *pos_after) { const void* vp = *(const DBusBasicValue**)value; - + _dbus_assert (dbus_type_is_fixed (element_type)); _dbus_assert (n_elements >= 0); @@ -1034,7 +1034,7 @@ _dbus_marshal_write_fixed_multi (DBusString *str, _dbus_verbose ("writing %d elements of %s\n", n_elements, _dbus_type_to_string (element_type)); #endif - + switch (element_type) { case DBUS_TYPE_BYTE: @@ -1081,7 +1081,7 @@ _dbus_marshal_skip_basic (const DBusString *str, { _dbus_assert (byte_order == DBUS_LITTLE_ENDIAN || byte_order == DBUS_BIG_ENDIAN); - + switch (type) { case DBUS_TYPE_BYTE: @@ -1111,7 +1111,7 @@ _dbus_marshal_skip_basic (const DBusString *str, int len; len = _dbus_marshal_read_uint32 (str, *pos, byte_order, pos); - + *pos += len + 1; /* length plus nul */ } break; @@ -1237,7 +1237,7 @@ _dbus_type_to_string (int typecode) case DBUS_TYPE_INT64: return "int64"; case DBUS_TYPE_UINT64: - return "uint64"; + return "uint64"; case DBUS_TYPE_DOUBLE: return "double"; case DBUS_TYPE_STRING: @@ -1477,11 +1477,11 @@ _dbus_marshal_read_fixed_multi (const DBusString *str, _dbus_verbose ("reading %d elements of %s\n", n_elements, _dbus_type_to_string (element_type)); #endif - + alignment = _dbus_type_get_alignment (element_type); pos = _DBUS_ALIGN_VALUE (pos, alignment); - + array_len = n_elements * alignment; *(const DBusBasicValue**) value = (void*) _dbus_string_get_const_data_len (str, pos, array_len); @@ -1499,7 +1499,7 @@ swap_test_array (void *array, if (alignment == 1) return; - + _dbus_string_init_const_len (&t, array, len_bytes); swap_array (&t, 0, len_bytes / alignment, byte_order, alignment); } @@ -1659,7 +1659,7 @@ _dbus_marshal_test (void) /* Marshal unsigned 16 integers */ MARSHAL_TEST (UINT16, DBUS_BIG_ENDIAN, 0x1234); MARSHAL_TEST (UINT16, DBUS_LITTLE_ENDIAN, 0x1234); - + /* Marshal signed integers */ MARSHAL_TEST (INT32, DBUS_BIG_ENDIAN, -12345678); MARSHAL_TEST (INT32, DBUS_LITTLE_ENDIAN, -12345678); @@ -1707,7 +1707,7 @@ _dbus_marshal_test (void) MARSHAL_TEST_FIXED_ARRAY (INT16, DBUS_LITTLE_ENDIAN, array2); MARSHAL_TEST_FIXED_ARRAY (UINT16, DBUS_BIG_ENDIAN, array2); MARSHAL_TEST_FIXED_ARRAY (UINT16, DBUS_LITTLE_ENDIAN, array2); - + MARSHAL_TEST_FIXED_ARRAY (INT32, DBUS_BIG_ENDIAN, array4); MARSHAL_TEST_FIXED_ARRAY (INT32, DBUS_LITTLE_ENDIAN, array4); MARSHAL_TEST_FIXED_ARRAY (UINT32, DBUS_BIG_ENDIAN, array4); @@ -1715,7 +1715,7 @@ _dbus_marshal_test (void) MARSHAL_TEST_FIXED_ARRAY (BYTE, DBUS_BIG_ENDIAN, array1); MARSHAL_TEST_FIXED_ARRAY (BYTE, DBUS_LITTLE_ENDIAN, array1); - + MARSHAL_TEST_FIXED_ARRAY (INT64, DBUS_BIG_ENDIAN, array8); MARSHAL_TEST_FIXED_ARRAY (INT64, DBUS_LITTLE_ENDIAN, array8); diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index 22da695..4588afa 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -173,9 +173,9 @@ _dbus_message_byteswap (DBusMessage *message) return; _dbus_verbose ("Swapping message into compiler byte order\n"); - + get_const_signature (&message->header, &type_str, &type_pos); - + _dbus_marshal_byteswap (type_str, type_pos, byte_order, DBUS_COMPILER_BYTE_ORDER, @@ -243,14 +243,14 @@ void _dbus_message_get_unix_fds(DBusMessage *message, * Sets the serial number of a message. * This can only be done once on a message. * - * DBusConnection will automatically set the serial to an appropriate value - * when the message is sent; this function is only needed when encapsulating + * DBusConnection will automatically set the serial to an appropriate value + * when the message is sent; this function is only needed when encapsulating * messages in another protocol, or otherwise bypassing DBusConnection. * * @param message the message * @param serial the serial */ -void +void dbus_message_set_serial (DBusMessage *message, dbus_uint32_t serial) { @@ -375,7 +375,7 @@ _dbus_message_remove_counter (DBusMessage *message, * reference to a message in the outgoing queue and change it * underneath us. Messages are locked when they enter the outgoing * queue (dbus_connection_send_message()), and the library complains - * if the message is modified while locked. This function may also + * if the message is modified while locked. This function may also * called externally, for applications wrapping D-Bus in another protocol. * * @param message the message to lock. @@ -591,7 +591,7 @@ dbus_message_get_cached (void) _dbus_assert (_dbus_atomic_get (&message->refcount) == 0); _dbus_assert (message->counters == NULL); - + _DBUS_UNLOCK (message_cache); return message; @@ -725,7 +725,7 @@ dbus_message_cache_or_finalize (DBusMessage *message) _dbus_assert (_dbus_atomic_get (&message->refcount) == 0); _DBUS_UNLOCK (message_cache); - + if (!was_cached) dbus_message_finalize (message); } @@ -947,7 +947,7 @@ _dbus_message_iter_get_args_valist (DBusMessageIter *iter, const char *s; _dbus_type_reader_read_basic (&array, (void *) &s); - + str_array[j] = _dbus_strdup (s); if (str_array[j] == NULL) { @@ -955,9 +955,9 @@ _dbus_message_iter_get_args_valist (DBusMessageIter *iter, _DBUS_SET_OOM (error); goto out; } - + ++j; - + if (!_dbus_type_reader_next (&array)) _dbus_assert (j == n_elements); } @@ -1098,7 +1098,7 @@ _dbus_message_iter_get_args_valist (DBusMessageIter *iter, * * The D-Bus specification goes into some more detail about header fields and * message types. - * + * * @{ */ @@ -1281,7 +1281,7 @@ dbus_message_new_empty_header (void) * Usually you want to use dbus_message_new_method_call(), * dbus_message_new_method_return(), dbus_message_new_signal(), * or dbus_message_new_error() instead. - * + * * @param message_type type of message * @returns new message or #NULL if no memory */ @@ -1321,7 +1321,7 @@ dbus_message_new (int message_type) * * Destination, path, interface, and method name can't contain * any invalid characters (see the D-Bus specification). - * + * * @param destination name that the message should be sent to or #NULL * @param path object path the message should be sent to * @param iface interface to invoke method on, or #NULL @@ -1414,7 +1414,7 @@ dbus_message_new_method_return (DBusMessage *method_call) * * Path, interface, and signal name must all be valid (the D-Bus * specification defines the syntax of these fields). - * + * * @param path the path to the object emitting the signal * @param iface the interface the signal is emitted from * @param name name of the signal @@ -1531,7 +1531,7 @@ dbus_message_new_error (DBusMessage *reply_to, * * @todo add _DBUS_GNUC_PRINTF to this (requires moving _DBUS_GNUC_PRINTF to * public header, see DBUS_DEPRECATED for an example) - * + * * @param reply_to the original message * @param error_name the error name * @param error_format the error message format as with printf @@ -1853,7 +1853,7 @@ dbus_message_append_args_valist (DBusMessage *message, char buf[2]; element_type = va_arg (var_args, int); - + buf[0] = element_type; buf[1] = '\0'; if (!dbus_message_iter_open_container (&iter, @@ -1870,7 +1870,7 @@ dbus_message_append_args_valist (DBusMessage *message, value = va_arg (var_args, const DBusBasicValue**); n_elements = va_arg (var_args, int); - + if (!dbus_message_iter_append_fixed_array (&array, element_type, value, @@ -1885,12 +1885,12 @@ dbus_message_append_args_valist (DBusMessage *message, const char **value; int n_elements; int i; - + value_p = va_arg (var_args, const char***); n_elements = va_arg (var_args, int); value = *value_p; - + i = 0; while (i < n_elements) { @@ -1967,7 +1967,7 @@ dbus_message_append_args_valist (DBusMessage *message, * * If more arguments than requested are present, the requested * arguments are returned and the extra arguments are ignored. - * + * * @todo support DBUS_TYPE_STRUCT and DBUS_TYPE_VARIANT and complex arrays * * @param message the message @@ -2031,7 +2031,7 @@ _dbus_message_iter_init_common (DBusMessage *message, * message, we need to get in the right byte order */ ensure_byte_order (message); - + real->message = message; real->changed_stamp = message->changed_stamp; real->iter_type = iter_type; @@ -2046,7 +2046,7 @@ _dbus_message_iter_init_common (DBusMessage *message, * Some types of argument can only be read with #DBusMessageIter * however. * - * The easiest way to iterate is like this: + * The easiest way to iterate is like this: * @code * dbus_message_iter_init (message, &iter); * while ((current_type = dbus_message_iter_get_arg_type (&iter)) != DBUS_TYPE_INVALID) @@ -2055,7 +2055,7 @@ _dbus_message_iter_init_common (DBusMessage *message, * * #DBusMessageIter contains no allocated memory; it need not be * freed, and can be copied by assignment or memcpy(). - * + * * @param message the message * @param iter pointer to an iterator to initialize * @returns #FALSE if the message has no arguments @@ -2212,7 +2212,7 @@ dbus_message_iter_recurse (DBusMessageIter *iter, * the variant's value. * * The returned string must be freed with dbus_free(). - * + * * @param iter the message iterator * @returns the contained signature, or NULL if out of memory */ @@ -2338,7 +2338,7 @@ dbus_message_iter_get_basic (DBusMessageIter *iter, * @todo introduce a variant of this get_n_elements that returns * the number of elements, though with a non-fixed array it will not * be very efficient, so maybe it's not good. - * + * * @param iter the iterator * @returns the number of bytes in the array */ @@ -2369,20 +2369,20 @@ dbus_message_iter_get_array_len (DBusMessageIter *iter) * The value argument should be the address of a location to store the * returned array. So for int32 it should be a "const dbus_int32_t**" * The returned value is by reference and should not be freed. - * + * * This function should only be used if dbus_type_is_fixed() returns * #TRUE for the element type. * * If an array's elements are not fixed in size, you have to recurse * into the array with dbus_message_iter_recurse() and read the * elements one by one. - * + * * Because the array is not copied, this function runs in constant * time and is fast; it's much preferred over walking the entire array * with an iterator. (However, you can always use * dbus_message_iter_recurse(), even for fixed-length types; * dbus_message_iter_get_fixed_array() is just an optimization.) - * + * * @param iter the iterator * @param value location to store the block * @param n_elements number of elements in the block @@ -2867,7 +2867,7 @@ dbus_message_iter_open_container (DBusMessageIter *iter, contained_signature != NULL) || (type == DBUS_TYPE_ARRAY && contained_signature != NULL), FALSE); - + /* this would fail if the contained_signature is a dict entry, since * dict entries are invalid signatures standalone (they must be in * an array) @@ -2897,7 +2897,7 @@ dbus_message_iter_open_container (DBusMessageIter *iter, type, NULL, 0, &real_sub->u.writer); - } + } } @@ -2976,7 +2976,7 @@ dbus_message_iter_abandon_container (DBusMessageIter *iter, * required to reply. * * On the protocol level this toggles #DBUS_HEADER_FLAG_NO_REPLY_EXPECTED - * + * * @param message the message * @param no_reply #TRUE if no reply is desired */ @@ -3018,7 +3018,7 @@ dbus_message_get_no_reply (DBusMessage *message) * The flag is set to #TRUE by default, i.e. auto starting is the default. * * On the protocol level this toggles #DBUS_HEADER_FLAG_NO_AUTO_START - * + * * @param message the message * @param auto_start #TRUE if auto-starting is desired */ @@ -3088,7 +3088,7 @@ dbus_message_set_path (DBusMessage *message, * * The returned string becomes invalid if the message is * modified, since it points into the wire-marshaled message data. - * + * * @param message the message * @returns the path (should not be freed) or #NULL */ @@ -3122,7 +3122,7 @@ dbus_message_has_path (DBusMessage *message, { const char *msg_path; msg_path = dbus_message_get_path (message); - + if (msg_path == NULL) { if (path == NULL) @@ -3133,7 +3133,7 @@ dbus_message_has_path (DBusMessage *message, if (path == NULL) return FALSE; - + if (strcmp (msg_path, path) == 0) return TRUE; @@ -3152,7 +3152,7 @@ dbus_message_has_path (DBusMessage *message, * and the path "/" becomes { NULL }. * * See also dbus_message_get_path(). - * + * * @todo this could be optimized by using the len from the message * instead of calling strlen() again * @@ -3174,7 +3174,7 @@ dbus_message_get_path_decomposed (DBusMessage *message, v = dbus_message_get_path (message); if (v != NULL) { - if (!_dbus_decompose_path (v, strlen (v), + if (!_dbus_decompose_path (v, (int) strlen (v), path, NULL)) return FALSE; } @@ -3189,7 +3189,7 @@ dbus_message_get_path_decomposed (DBusMessage *message, * * The interface name must contain only valid characters as defined * in the D-Bus specification. - * + * * @param message the message * @param iface the interface or #NULL to unset * @returns #FALSE if not enough memory @@ -3251,7 +3251,7 @@ dbus_message_has_interface (DBusMessage *message, { const char *msg_interface; msg_interface = dbus_message_get_interface (message); - + if (msg_interface == NULL) { if (iface == NULL) @@ -3262,7 +3262,7 @@ dbus_message_has_interface (DBusMessage *message, if (iface == NULL) return FALSE; - + if (strcmp (msg_interface, iface) == 0) return TRUE; @@ -3305,7 +3305,7 @@ dbus_message_set_member (DBusMessage *message, * * The returned string becomes invalid if the message is * modified, since it points into the wire-marshaled message data. - * + * * @param message the message * @returns the member name (should not be freed) or #NULL */ @@ -3337,7 +3337,7 @@ dbus_message_has_member (DBusMessage *message, { const char *msg_member; msg_member = dbus_message_get_member (message); - + if (msg_member == NULL) { if (member == NULL) @@ -3348,7 +3348,7 @@ dbus_message_has_member (DBusMessage *message, if (member == NULL) return FALSE; - + if (strcmp (msg_member, member) == 0) return TRUE; @@ -3389,7 +3389,7 @@ dbus_message_set_error_name (DBusMessage *message, * * The returned string becomes invalid if the message is * modified, since it points into the wire-marshaled message data. - * + * * @param message the message * @returns the error name (should not be freed) or #NULL */ @@ -3416,7 +3416,7 @@ dbus_message_get_error_name (DBusMessage *message) * * The destination name must contain only valid characters as defined * in the D-Bus specification. - * + * * @param message the message * @param destination the destination name or #NULL to unset * @returns #FALSE if not enough memory @@ -3499,7 +3499,7 @@ dbus_message_set_sender (DBusMessage *message, * Note, the returned sender is always the unique bus name. * Connections may own multiple other bus names, but those * are not found in the sender field. - * + * * The returned string becomes invalid if the message is * modified, since it points into the wire-marshaled message data. * @@ -3867,7 +3867,7 @@ _dbus_message_loader_new (void) loader = dbus_new0 (DBusMessageLoader, 1); if (loader == NULL) return NULL; - + loader->refcount = 1; loader->corrupted = FALSE; @@ -4109,7 +4109,7 @@ load_message (DBusMessageLoader *loader, dbus_uint32_t n_unix_fds = 0; mode = DBUS_VALIDATION_MODE_DATA_IS_UNTRUSTED; - + oom = FALSE; #if 0 @@ -4152,7 +4152,7 @@ load_message (DBusMessageLoader *loader, if (mode != DBUS_VALIDATION_MODE_WE_TRUST_THIS_DATA_ABSOLUTELY) { get_const_signature (&message->header, &type_str, &type_pos); - + /* Because the bytes_remaining arg is NULL, this validates that the * body is the right length */ @@ -4169,7 +4169,7 @@ load_message (DBusMessageLoader *loader, loader->corrupted = TRUE; loader->corruption_reason = validity; - + goto failed; } } @@ -4273,7 +4273,7 @@ load_message (DBusMessageLoader *loader, /* does nothing if the message isn't in the list */ _dbus_list_remove_last (&loader->messages, message); - + if (oom) _dbus_assert (!loader->corrupted); else @@ -4728,7 +4728,7 @@ dbus_message_marshal (DBusMessage *msg, _dbus_return_val_if_fail (msg != NULL, FALSE); _dbus_return_val_if_fail (marshalled_data_p != NULL, FALSE); _dbus_return_val_if_fail (len_p != NULL, FALSE); - + if (!_dbus_string_init (&tmp)) return FALSE; @@ -4835,10 +4835,10 @@ dbus_message_demarshal (const char *str, * @param buf data to be marshalled * @param len the length of @p buf * @returns -1 if there was no valid data to be demarshalled, 0 if there wasn't enough data to determine how much should be demarshalled. Otherwise returns the number of bytes to be demarshalled - * + * */ -int -dbus_message_demarshal_bytes_needed(const char *buf, +int +dbus_message_demarshal_bytes_needed(const char *buf, int len) { DBusString str; @@ -4852,7 +4852,7 @@ dbus_message_demarshal_bytes_needed(const char *buf, if (len > DBUS_MAXIMUM_MESSAGE_LENGTH) len = DBUS_MAXIMUM_MESSAGE_LENGTH; _dbus_string_init_const_len (&str, buf, len); - + validity = DBUS_VALID; have_message = _dbus_header_have_message_untrusted(DBUS_MAXIMUM_MESSAGE_LENGTH, diff --git a/dbus/dbus-object-tree.c b/dbus/dbus-object-tree.c index e2a3b73..43a74cc 100644 --- a/dbus/dbus-object-tree.c +++ b/dbus/dbus-object-tree.c @@ -108,7 +108,7 @@ _dbus_object_tree_new (DBusConnection *connection) if (tree->root == NULL) goto oom; tree->root->invoke_as_fallback = TRUE; - + return tree; oom: @@ -188,7 +188,7 @@ find_subtree_recurse (DBusObjectSubtree *subtree, _dbus_verbose (" searching children of %s for %s\n", subtree->name, path[0]); #endif - + i = 0; j = subtree->n_subtrees; while (i < j) @@ -203,7 +203,7 @@ find_subtree_recurse (DBusObjectSubtree *subtree, path[0], subtree->subtrees[k]->name, v); #endif - + if (v == 0) { if (index_in_parent) @@ -219,7 +219,7 @@ find_subtree_recurse (DBusObjectSubtree *subtree, DBusObjectSubtree *next; next = find_subtree_recurse (subtree->subtrees[k], - &path[1], create_if_not_found, + &path[1], create_if_not_found, index_in_parent, exact_match); if (next == NULL && subtree->invoke_as_fallback) @@ -237,7 +237,7 @@ find_subtree_recurse (DBusObjectSubtree *subtree, } else return find_subtree_recurse (subtree->subtrees[k], - &path[1], create_if_not_found, + &path[1], create_if_not_found, index_in_parent, exact_match); } else if (v < 0) @@ -254,7 +254,7 @@ find_subtree_recurse (DBusObjectSubtree *subtree, _dbus_verbose (" no match found, current tree %s, create_if_not_found = %d\n", subtree->name, create_if_not_found); #endif - + if (create_if_not_found) { DBusObjectSubtree* child; @@ -264,7 +264,7 @@ find_subtree_recurse (DBusObjectSubtree *subtree, _dbus_verbose (" creating subtree %s\n", path[0]); #endif - + child = _dbus_object_subtree_new (path[0], NULL, NULL); if (child == NULL) @@ -288,16 +288,16 @@ find_subtree_recurse (DBusObjectSubtree *subtree, subtree->max_subtrees = new_max_subtrees; } - /* The binary search failed, so i == j points to the + /* The binary search failed, so i == j points to the place the child should be inserted. */ child_pos = i; _dbus_assert (child_pos < new_n_subtrees && new_n_subtrees <= subtree->max_subtrees); if (child_pos + 1 < new_n_subtrees) { - memmove (&subtree->subtrees[child_pos+1], - &subtree->subtrees[child_pos], - (new_n_subtrees - child_pos - 1) * + memmove (&subtree->subtrees[child_pos+1], + &subtree->subtrees[child_pos], + (new_n_subtrees - child_pos - 1) * sizeof subtree->subtrees[0]); } subtree->subtrees[child_pos] = child; @@ -308,7 +308,7 @@ find_subtree_recurse (DBusObjectSubtree *subtree, child->parent = subtree; return find_subtree_recurse (child, - &path[1], create_if_not_found, + &path[1], create_if_not_found, index_in_parent, exact_match); } else @@ -330,7 +330,7 @@ find_subtree (DBusObjectTree *tree, #if VERBOSE_FIND _dbus_verbose ("Looking for exact registered subtree\n"); #endif - + subtree = find_subtree_recurse (tree->root, path, FALSE, index_in_parent, NULL); if (subtree && subtree->message_function == NULL) @@ -361,7 +361,7 @@ find_handler (DBusObjectTree *tree, _dbus_assert (exact_match != NULL); *exact_match = FALSE; /* ensure always initialized */ - + return find_subtree_recurse (tree->root, path, FALSE, NULL, exact_match); } @@ -650,7 +650,7 @@ _dbus_object_tree_unregister_and_unlock (DBusObjectTree *tree, _dbus_warn ("Attempted to unregister path (path[0] = %s path[1] = %s) which isn't registered\n", path[0] ? path[0] : "null", (path[0] && path[1]) ? path[1] : "null"); - goto unlock; + goto unlock; } #else _dbus_assert (found_subtree == TRUE); @@ -732,12 +732,12 @@ _dbus_object_tree_list_registered_unlocked (DBusObjectTree *tree, { DBusObjectSubtree *subtree; char **retval; - + _dbus_assert (parent_path != NULL); _dbus_assert (child_entries != NULL); *child_entries = NULL; - + subtree = lookup_subtree (tree, parent_path); if (subtree == NULL) { @@ -764,7 +764,7 @@ _dbus_object_tree_list_registered_unlocked (DBusObjectTree *tree, } out: - + *child_entries = retval; return retval != NULL; } @@ -786,11 +786,11 @@ handle_default_introspect_and_unlock (DBusObjectTree *tree, /* We have the connection lock here */ already_unlocked = FALSE; - + _dbus_verbose (" considering default Introspect() handler...\n"); reply = NULL; - + if (!dbus_message_is_method_call (message, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) @@ -802,12 +802,12 @@ handle_default_introspect_and_unlock (DBusObjectTree *tree, _dbus_verbose ("unlock\n"); _dbus_connection_unlock (tree->connection); } - + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } _dbus_verbose (" using default Introspect() handler!\n"); - + if (!_dbus_string_init (&xml)) { #ifdef DBUS_ENABLE_EMBEDDED_TESTS @@ -829,7 +829,7 @@ handle_default_introspect_and_unlock (DBusObjectTree *tree, if (!_dbus_string_append (&xml, DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE)) goto out; - + if (!_dbus_string_append (&xml, "\n")) goto out; @@ -854,19 +854,19 @@ handle_default_introspect_and_unlock (DBusObjectTree *tree, v_STRING = _dbus_string_get_const_data (&xml); if (!dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &v_STRING)) goto out; - + #ifdef DBUS_ENABLE_EMBEDDED_TESTS if (tree->connection) #endif { already_unlocked = TRUE; - + if (!_dbus_connection_send_and_unlock (tree->connection, reply, NULL)) goto out; } - + result = DBUS_HANDLER_RESULT_HANDLED; - + out: #ifdef DBUS_ENABLE_EMBEDDED_TESTS if (tree->connection) @@ -878,12 +878,12 @@ handle_default_introspect_and_unlock (DBusObjectTree *tree, _dbus_connection_unlock (tree->connection); } } - + _dbus_string_free (&xml); dbus_free_string_array (children); if (reply) dbus_message_unref (reply); - + return result; } @@ -912,11 +912,11 @@ _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree, DBusList *link; DBusHandlerResult result; DBusObjectSubtree *subtree; - + #if 0 _dbus_verbose ("Dispatch of message by object path\n"); #endif - + path = NULL; if (!dbus_message_get_path_decomposed (message, &path)) { @@ -927,7 +927,7 @@ _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree, _dbus_verbose ("unlock\n"); _dbus_connection_unlock (tree->connection); } - + _dbus_verbose ("No memory to get decomposed path\n"); return DBUS_HANDLER_RESULT_NEED_MEMORY; @@ -942,14 +942,14 @@ _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree, _dbus_verbose ("unlock\n"); _dbus_connection_unlock (tree->connection); } - + _dbus_verbose ("No path field in message\n"); return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } - + /* Find the deepest path that covers the path in the message */ subtree = find_handler (tree, (const char**) path, &exact_match); - + if (found_object) *found_object = !!subtree; @@ -1003,7 +1003,7 @@ _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree, #if 0 _dbus_verbose (" (invoking a handler)\n"); #endif - + #ifdef DBUS_ENABLE_EMBEDDED_TESTS if (tree->connection) #endif @@ -1052,14 +1052,14 @@ _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree, _dbus_connection_unlock (tree->connection); } } - + while (list != NULL) { link = _dbus_list_get_first_link (&list); _dbus_object_subtree_unref (link->data); _dbus_list_remove_link (&list, link); } - + dbus_free_string_array (path); return result; @@ -1082,7 +1082,7 @@ _dbus_object_tree_get_user_data_unlocked (DBusObjectTree *tree, _dbus_assert (tree != NULL); _dbus_assert (path != NULL); - + /* Find the deepest path that covers the path in the message */ subtree = find_handler (tree, (const char**) path, &exact_match); @@ -1110,7 +1110,7 @@ allocate_subtree_object (const char *name) _dbus_assert (name != NULL); - len = strlen (name); + len = (int) strlen (name); subtree = dbus_malloc0 (MAX (front_padding + (len + 1), sizeof (DBusObjectSubtree))); @@ -1214,7 +1214,7 @@ _dbus_object_tree_list_registered_and_unlock (DBusObjectTree *tree, result = _dbus_object_tree_list_registered_unlocked (tree, parent_path, child_entries); - + #ifdef DBUS_ENABLE_EMBEDDED_TESTS if (tree->connection) #endif @@ -1234,7 +1234,7 @@ _dbus_object_tree_list_registered_and_unlock (DBusObjectTree *tree, * Decompose an object path. A path of just "/" is * represented as an empty vector of strings. * The path need not be nul terminated. - * + * * @param data the path data * @param len the length of the path string * @param path address to store new object path @@ -1252,12 +1252,12 @@ _dbus_decompose_path (const char* data, _dbus_assert (data != NULL); _dbus_assert (path != NULL); - + #if VERBOSE_DECOMPOSE _dbus_verbose ("Decomposing path \"%s\"\n", data); #endif - + n_components = 0; if (len > 1) /* if path is not just "/" */ { @@ -1270,7 +1270,7 @@ _dbus_decompose_path (const char* data, ++i; } } - + retval = dbus_new0 (char*, n_components + 1); if (retval == NULL) @@ -1284,7 +1284,7 @@ _dbus_decompose_path (const char* data, while (comp < n_components) { _dbus_assert (i < len); - + if (data[i] == '/') ++i; j = i; @@ -1301,7 +1301,7 @@ _dbus_decompose_path (const char* data, _dbus_verbose (" (component in [%d,%d))\n", i, j); #endif - + retval[comp] = _dbus_memdup (&data[i], j - i + 1); if (retval[comp] == NULL) { @@ -1318,11 +1318,11 @@ _dbus_decompose_path (const char* data, i = j; } _dbus_assert (i == len); - + *path = retval; if (path_len) *path_len = n_components; - + return TRUE; } @@ -1345,16 +1345,16 @@ flatten_path (const char **path) else { int i; - + i = 0; while (path[i]) { if (!_dbus_string_append_byte (&str, '/')) goto nomem; - + if (!_dbus_string_append (&str, path[i])) goto nomem; - + ++i; } } @@ -1379,7 +1379,7 @@ flatten_path (const char **path) #include "dbus-test.h" #include -typedef enum +typedef enum { STR_EQUAL, STR_PREFIX, @@ -1516,7 +1516,7 @@ do_register (DBusObjectTree *tree, _dbus_assert (_dbus_object_tree_get_user_data_unlocked (tree, path) == &tree_test_data[i]); - + return TRUE; } @@ -1533,7 +1533,7 @@ do_test_dispatch (DBusObjectTree *tree, char *flat; message = NULL; - + flat = flatten_path (path); if (flat == NULL) goto oom; @@ -1630,18 +1630,18 @@ run_decompose_tests (void) int expected_len; if (!_dbus_decompose_path (decompose_tests[i].path, - strlen (decompose_tests[i].path), + (int) strlen (decompose_tests[i].path), &result, &result_len)) return FALSE; - expected_len = string_array_length (decompose_tests[i].result); - + expected_len = (int) string_array_length (decompose_tests[i].result); + if (result_len != (int) string_array_length ((const char**)result) || expected_len != result_len || path_contains (decompose_tests[i].result, (const char**) result) != STR_EQUAL) { - int real_len = string_array_length ((const char**)result); + int real_len = (int) string_array_length ((const char**)result); _dbus_warn ("Expected decompose of %s to have len %d, returned %d, appears to have %d\n", decompose_tests[i].path, expected_len, result_len, real_len); @@ -1661,7 +1661,7 @@ run_decompose_tests (void) ++i; } - + return TRUE; } @@ -1702,7 +1702,7 @@ object_tree_test_iteration (void *data) if (!run_decompose_tests ()) return FALSE; - + tree = NULL; tree = _dbus_object_tree_new (NULL); @@ -1731,7 +1731,7 @@ object_tree_test_iteration (void *data) _dbus_assert (find_handler (tree, path6, &exact_match) == tree->root && !exact_match); _dbus_assert (find_handler (tree, path7, &exact_match) == tree->root && !exact_match); _dbus_assert (find_handler (tree, path8, &exact_match) == tree->root && !exact_match); - + if (!do_register (tree, path1, TRUE, 1, tree_test_data)) goto out; @@ -1779,20 +1779,20 @@ object_tree_test_iteration (void *data) _dbus_assert (!find_subtree (tree, path6, NULL)); _dbus_assert (!find_subtree (tree, path7, NULL)); _dbus_assert (!find_subtree (tree, path8, NULL)); - + if (!do_register (tree, path4, TRUE, 4, tree_test_data)) goto out; _dbus_assert (find_subtree (tree, path0, NULL)); _dbus_assert (find_subtree (tree, path1, NULL)); _dbus_assert (find_subtree (tree, path2, NULL)); - _dbus_assert (find_subtree (tree, path3, NULL)); + _dbus_assert (find_subtree (tree, path3, NULL)); _dbus_assert (find_subtree (tree, path4, NULL)); _dbus_assert (!find_subtree (tree, path5, NULL)); _dbus_assert (!find_subtree (tree, path6, NULL)); _dbus_assert (!find_subtree (tree, path7, NULL)); _dbus_assert (!find_subtree (tree, path8, NULL)); - + if (!do_register (tree, path5, TRUE, 5, tree_test_data)) goto out; @@ -1864,7 +1864,7 @@ object_tree_test_iteration (void *data) _dbus_assert (find_handler (tree, path6, &exact_match) != tree->root && exact_match); _dbus_assert (find_handler (tree, path7, &exact_match) != tree->root && exact_match); _dbus_assert (find_handler (tree, path8, &exact_match) != tree->root && exact_match); - + /* test the list_registered function */ { @@ -1875,7 +1875,7 @@ object_tree_test_iteration (void *data) _dbus_object_tree_list_registered_unlocked (tree, path1, &child_entries); if (child_entries != NULL) { - nb = string_array_length ((const char**)child_entries); + nb = (int) string_array_length ((const char**)child_entries); _dbus_assert (nb == 1); dbus_free_string_array (child_entries); } @@ -1883,7 +1883,7 @@ object_tree_test_iteration (void *data) _dbus_object_tree_list_registered_unlocked (tree, path2, &child_entries); if (child_entries != NULL) { - nb = string_array_length ((const char**)child_entries); + nb = (int) string_array_length ((const char**)child_entries); _dbus_assert (nb == 2); dbus_free_string_array (child_entries); } @@ -1891,7 +1891,7 @@ object_tree_test_iteration (void *data) _dbus_object_tree_list_registered_unlocked (tree, path8, &child_entries); if (child_entries != NULL) { - nb = string_array_length ((const char**)child_entries); + nb = (int) string_array_length ((const char**)child_entries); _dbus_assert (nb == 0); dbus_free_string_array (child_entries); } @@ -1899,7 +1899,7 @@ object_tree_test_iteration (void *data) _dbus_object_tree_list_registered_unlocked (tree, root, &child_entries); if (child_entries != NULL) { - nb = string_array_length ((const char**)child_entries); + nb = (int) string_array_length ((const char**)child_entries); _dbus_assert (nb == 3); dbus_free_string_array (child_entries); } @@ -1952,7 +1952,7 @@ object_tree_test_iteration (void *data) _dbus_assert (find_subtree (tree, path6, NULL)); _dbus_assert (find_subtree (tree, path7, NULL)); _dbus_assert (find_subtree (tree, path8, NULL)); - + _dbus_object_tree_unregister_and_unlock (tree, path1); _dbus_assert (_dbus_object_tree_get_user_data_unlocked (tree, path1) == NULL); @@ -1978,7 +1978,7 @@ object_tree_test_iteration (void *data) _dbus_assert (find_subtree (tree, path6, NULL)); _dbus_assert (find_subtree (tree, path7, NULL)); _dbus_assert (find_subtree (tree, path8, NULL)); - + _dbus_object_tree_unregister_and_unlock (tree, path3); _dbus_assert (_dbus_object_tree_get_user_data_unlocked (tree, path3) == NULL); @@ -1991,7 +1991,7 @@ object_tree_test_iteration (void *data) _dbus_assert (find_subtree (tree, path6, NULL)); _dbus_assert (find_subtree (tree, path7, NULL)); _dbus_assert (find_subtree (tree, path8, NULL)); - + _dbus_object_tree_unregister_and_unlock (tree, path4); _dbus_assert (_dbus_object_tree_get_user_data_unlocked (tree, path4) == NULL); @@ -2004,7 +2004,7 @@ object_tree_test_iteration (void *data) _dbus_assert (find_subtree (tree, path6, NULL)); _dbus_assert (find_subtree (tree, path7, NULL)); _dbus_assert (find_subtree (tree, path8, NULL)); - + _dbus_object_tree_unregister_and_unlock (tree, path5); _dbus_assert (_dbus_object_tree_get_user_data_unlocked (tree, path5) == NULL); @@ -2017,7 +2017,7 @@ object_tree_test_iteration (void *data) _dbus_assert (find_subtree (tree, path6, NULL)); _dbus_assert (find_subtree (tree, path7, NULL)); _dbus_assert (find_subtree (tree, path8, NULL)); - + _dbus_object_tree_unregister_and_unlock (tree, path6); _dbus_assert (_dbus_object_tree_get_user_data_unlocked (tree, path6) == NULL); @@ -2056,7 +2056,7 @@ object_tree_test_iteration (void *data) _dbus_assert (!find_subtree (tree, path6, NULL)); _dbus_assert (!find_subtree (tree, path7, NULL)); _dbus_assert (!find_subtree (tree, path8, NULL)); - + i = 0; while (i < (int) _DBUS_N_ELEMENTS (tree_test_data)) { @@ -2260,7 +2260,7 @@ object_tree_test_iteration (void *data) #endif /* Register it all again, and test dispatch */ - + if (!do_register (tree, path0, TRUE, 0, tree_test_data)) goto out; if (!do_register (tree, path1, FALSE, 1, tree_test_data)) @@ -2302,7 +2302,7 @@ object_tree_test_iteration (void *data) goto out; if (!do_test_dispatch (tree, path8, 8, tree_test_data, _DBUS_N_ELEMENTS (tree_test_data))) goto out; - + out: if (tree) { diff --git a/dbus/dbus-sha.c b/dbus/dbus-sha.c index febfba2..21d289e 100644 --- a/dbus/dbus-sha.c +++ b/dbus/dbus-sha.c @@ -501,7 +501,7 @@ _dbus_sha_compute (const DBusString *data, goto error; _dbus_string_free (&digest); - + return TRUE; error: @@ -550,7 +550,7 @@ static dbus_bool_t check_sha_str (const char *input, const char *expected) { - return check_sha_binary (input, strlen (input), expected); + return check_sha_binary (input, (int) strlen (input), expected); } static dbus_bool_t @@ -563,7 +563,7 @@ decode_compact_string (const DBusString *line, int next; long val; int length_bytes; - + offset = 0; next = 0; @@ -575,7 +575,7 @@ decode_compact_string (const DBusString *line, } _dbus_string_skip_blank (line, next, &next); - + offset = next; if (!_dbus_string_parse_int (line, offset, &val, &next)) { @@ -583,7 +583,7 @@ decode_compact_string (const DBusString *line, _dbus_string_get_const_data (line)); return FALSE; } - + if (!(val == 0 || val == 1)) { fprintf (stderr, "the value 'b' must be 0 or 1, see sha-1/Readme.txt\n"); @@ -591,19 +591,19 @@ decode_compact_string (const DBusString *line, } _dbus_string_skip_blank (line, next, &next); - + current_b = val; n_bits = 0; - + while (next < _dbus_string_get_length (line)) { int total_bits; - + offset = next; if (_dbus_string_get_byte (line, offset) == '^') break; - + if (!_dbus_string_parse_int (line, offset, &val, &next)) { fprintf (stderr, "could not parse bit count in compact string\n"); @@ -617,7 +617,7 @@ decode_compact_string (const DBusString *line, int byte_containing_next_bit = n_bits / 8; int bit_containing_next_bit = 7 - (n_bits % 8); unsigned char old_byte; - + if (byte_containing_next_bit >= _dbus_string_get_length (decoded)) { if (!_dbus_string_set_length (decoded, byte_containing_next_bit + 1)) @@ -632,19 +632,19 @@ decode_compact_string (const DBusString *line, current_b, byte_containing_next_bit, bit_containing_next_bit, old_byte); #endif - + _dbus_string_set_byte (decoded, byte_containing_next_bit, old_byte); - + ++n_bits; } _dbus_string_skip_blank (line, next, &next); - + current_b = !current_b; } length_bytes = (n_bits / 8 + ((n_bits % 8) ? 1 : 0)); - + if (_dbus_string_get_length (decoded) != length_bytes) { fprintf (stderr, "Expected length %d bytes %d bits for compact string, got %d bytes\n", @@ -663,10 +663,10 @@ get_next_expected_result (DBusString *results, dbus_bool_t retval; retval = FALSE; - + if (!_dbus_string_init (&line)) _dbus_assert_not_reached ("no memory"); - + next_iteration: while (_dbus_string_pop_line (results, &line)) { @@ -686,7 +686,7 @@ get_next_expected_result (DBusString *results, else { int i; - + if (!_dbus_string_move (&line, 0, result, 0)) _dbus_assert_not_reached ("no memory"); @@ -722,13 +722,13 @@ get_next_expected_result (DBusString *results, ++i; } - + break; } } - + retval = TRUE; - + /* out: */ _dbus_string_free (&line); return retval; @@ -749,7 +749,7 @@ process_test_data (const char *test_data_dir) DBusError error = DBUS_ERROR_INIT; retval = FALSE; - + if (!_dbus_string_init (&tests_file)) _dbus_assert_not_reached ("no memory"); @@ -764,7 +764,7 @@ process_test_data (const char *test_data_dir) if (!_dbus_string_init (&line)) _dbus_assert_not_reached ("no memory"); - + if (!_dbus_string_append (&tests_file, test_data_dir)) _dbus_assert_not_reached ("no memory"); @@ -820,7 +820,7 @@ process_test_data (const char *test_data_dir) * we'd have to do a little bit more implementation * to use those tests. */ - + printf (" (ending tests due to Type 3 tests seen - this is normal)\n"); break; } @@ -837,13 +837,13 @@ process_test_data (const char *test_data_dir) dbus_bool_t success; success = FALSE; - + if (!_dbus_string_init (&next_line)) _dbus_assert_not_reached ("no memory"); if (!_dbus_string_init (&expected)) _dbus_assert_not_reached ("no memory"); - + if (!_dbus_string_init (&test)) _dbus_assert_not_reached ("no memory"); @@ -862,14 +862,14 @@ process_test_data (const char *test_data_dir) _dbus_string_get_length (&line))) _dbus_assert_not_reached ("no memory"); } - + if (!decode_compact_string (&line, &test)) { fprintf (stderr, "Failed to decode line %d as a compact string\n", line_no); goto failure; } - + if (!_dbus_sha_compute (&test, &result)) _dbus_assert_not_reached ("no memory for SHA-1 result"); @@ -878,9 +878,9 @@ process_test_data (const char *test_data_dir) fprintf (stderr, "Failed to read an expected result\n"); goto failure; } - + if (!_dbus_string_equal (&result, &expected)) - { + { fprintf (stderr, " for line %d got hash %s expected %s\n", line_no, _dbus_string_get_const_data (&result), @@ -909,7 +909,7 @@ process_test_data (const char *test_data_dir) printf ("Passed the %d SHA-1 tests in the test file\n", success_count); - + out: _dbus_string_free (&tests_file); _dbus_string_free (&results_file); @@ -939,7 +939,7 @@ _dbus_sha_test (const char *test_data_dir) } else printf ("No test data dir\n"); - + i = 0; while (i < 256) { diff --git a/dbus/dbus-spawn-win.c b/dbus/dbus-spawn-win.c index f7b56d1..64d6a90 100644 --- a/dbus/dbus-spawn-win.c +++ b/dbus/dbus-spawn-win.c @@ -12,13 +12,13 @@ /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ /* dbus-spawn-win32.c Wrapper around g_spawn - * + * * Copyright (C) 2002, 2003, 2004 Red Hat, Inc. * Copyright (C) 2003 CodeFactory AB * Copyright (C) 2005 Novell, Inc. * * Licensed under the Academic Free License version 2.1 - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -28,7 +28,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA @@ -507,7 +507,7 @@ compose_string (char **strings, char separator) if (!strings || !strings[0]) return 0; for (i = 0; strings[i]; i++) - n += strlen (strings[i]) + 1; + n += (int) strlen (strings[i]) + 1; n++; buf = p = malloc (n); @@ -606,7 +606,7 @@ babysitter (void *parameter) sitter->have_spawn_errno = TRUE; sitter->spawn_errno = GetLastError(); } - + PING(); SetEvent (sitter->start_sync_event); @@ -652,7 +652,7 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, DBusBabysitter *sitter; HANDLE sitter_thread; DWORD sitter_thread_id; - + _DBUS_ASSERT_ERROR_IS_CLEAR (error); _dbus_assert (argv[0] != NULL); diff --git a/dbus/dbus-string-util.c b/dbus/dbus-string-util.c index 3babc05..76d3f2b 100644 --- a/dbus/dbus-string-util.c +++ b/dbus/dbus-string-util.c @@ -1,11 +1,11 @@ /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ /* dbus-string-util.c Would be in dbus-string.c, but not used in libdbus - * + * * Copyright (C) 2002, 2003, 2004, 2005 Red Hat, Inc. * Copyright (C) 2006 Ralf Habacker * * Licensed under the Academic Free License version 2.1 - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -15,7 +15,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA @@ -37,7 +37,7 @@ * Returns whether a string ends with the given suffix * * @todo memcmp might make this faster. - * + * * @param a the string * @param c_str the C-style string * @returns #TRUE if the string ends with the suffix @@ -53,11 +53,11 @@ _dbus_string_ends_with_c_str (const DBusString *a, const DBusRealString *real_a = (const DBusRealString*) a; DBUS_GENERIC_STRING_PREAMBLE (real_a); _dbus_assert (c_str != NULL); - - c_str_len = strlen (c_str); + + c_str_len = (int) strlen (c_str); if (((unsigned long)real_a->len) < c_str_len) return FALSE; - + ap = real_a->str + (real_a->len - c_str_len); bp = (const unsigned char*) c_str; a_end = real_a->str + real_a->len; @@ -65,14 +65,14 @@ _dbus_string_ends_with_c_str (const DBusString *a, { if (*ap != *bp) return FALSE; - + ++ap; ++bp; } _dbus_assert (*ap == '\0'); _dbus_assert (*bp == '\0'); - + return TRUE; } @@ -103,7 +103,7 @@ _dbus_string_find_byte_backward (const DBusString *str, { if (real->str[i] == byte) break; - + --i; } @@ -129,14 +129,14 @@ test_hex_roundtrip (const unsigned char *data, int end; if (len < 0) - len = strlen (data); - + len = (int) strlen (data); + if (!_dbus_string_init (&orig)) _dbus_assert_not_reached ("could not init string"); if (!_dbus_string_init (&encoded)) _dbus_assert_not_reached ("could not init string"); - + if (!_dbus_string_init (&decoded)) _dbus_assert_not_reached ("could not init string"); @@ -148,13 +148,13 @@ test_hex_roundtrip (const unsigned char *data, if (!_dbus_string_hex_decode (&encoded, 0, &end, &decoded, 0)) _dbus_assert_not_reached ("could not decode"); - + _dbus_assert (_dbus_string_get_length (&encoded) == end); if (!_dbus_string_equal (&orig, &decoded)) { const char *s; - + printf ("Original string %d bytes encoded %d bytes decoded %d bytes\n", _dbus_string_get_length (&orig), _dbus_string_get_length (&encoded), @@ -164,10 +164,10 @@ test_hex_roundtrip (const unsigned char *data, printf ("Decoded: %s\n", s); _dbus_assert_not_reached ("original string not the same as string decoded from hex"); } - + _dbus_string_free (&orig); _dbus_string_free (&encoded); - _dbus_string_free (&decoded); + _dbus_string_free (&decoded); } typedef void (* TestRoundtripFunc) (const unsigned char *data, @@ -196,7 +196,7 @@ test_roundtrips (TestRoundtripFunc func) { unsigned char buf[512]; int i; - + i = 0; while (i < _DBUS_N_ELEMENTS (buf)) { @@ -219,7 +219,7 @@ test_roundtrips (TestRoundtripFunc func) * @todo Need to write tests for _dbus_string_copy() and * _dbus_string_move() moving to/from each of start/middle/end of a * string. Also need tests for _dbus_string_move_len () - * + * * @returns #TRUE on success. */ dbus_bool_t @@ -237,7 +237,7 @@ _dbus_string_test (void) while (i < _DBUS_N_ELEMENTS (lens)) { int j; - + if (!_dbus_string_init (&str)) _dbus_assert_not_reached ("failed to init string"); @@ -255,7 +255,7 @@ _dbus_string_test (void) } --j; } - + _dbus_string_free (&str); ++i; @@ -286,7 +286,7 @@ _dbus_string_test (void) _dbus_assert (_dbus_string_equal_substring (&other, 4, 1, &str, 4)); _dbus_assert (_dbus_string_equal_substring (&other, 5, 0, &str, 5)); - + _dbus_string_init_const (&other, "World"); _dbus_assert (_dbus_string_equal_substring (&str, 6, 5, &other, 0)); _dbus_assert (_dbus_string_equal_substring (&str, 7, 4, &other, 1)); @@ -301,9 +301,9 @@ _dbus_string_test (void) _dbus_assert (_dbus_string_equal_substring (&other, 3, 2, &str, 9)); _dbus_assert (_dbus_string_equal_substring (&other, 4, 1, &str, 10)); _dbus_assert (_dbus_string_equal_substring (&other, 5, 0, &str, 11)); - + _dbus_string_free (&str); - + /* Test appending data */ if (!_dbus_string_init (&str)) _dbus_assert_not_reached ("failed to init string"); @@ -320,14 +320,14 @@ _dbus_string_test (void) _dbus_assert_not_reached ("failed to append byte to string\n"); _dbus_assert (_dbus_string_get_length (&str) == i * 2 + 2); - + ++i; } _dbus_string_free (&str); /* Check steal_data */ - + if (!_dbus_string_init (&str)) _dbus_assert_not_reached ("failed to init string"); @@ -335,7 +335,7 @@ _dbus_string_test (void) _dbus_assert_not_reached ("could not append to string"); i = _dbus_string_get_length (&str); - + if (!_dbus_string_steal_data (&str, &s)) _dbus_assert_not_reached ("failed to steal data"); @@ -345,7 +345,7 @@ _dbus_string_test (void) dbus_free (s); /* Check move */ - + if (!_dbus_string_append (&str, "Hello World")) _dbus_assert_not_reached ("could not append to string"); @@ -353,7 +353,7 @@ _dbus_string_test (void) if (!_dbus_string_init (&other)) _dbus_assert_not_reached ("could not init string"); - + if (!_dbus_string_move (&str, 0, &other, 0)) _dbus_assert_not_reached ("could not move"); @@ -362,7 +362,7 @@ _dbus_string_test (void) if (!_dbus_string_append (&str, "Hello World")) _dbus_assert_not_reached ("could not append to string"); - + if (!_dbus_string_move (&str, 0, &other, _dbus_string_get_length (&other))) _dbus_assert_not_reached ("could not move"); @@ -371,25 +371,25 @@ _dbus_string_test (void) if (!_dbus_string_append (&str, "Hello World")) _dbus_assert_not_reached ("could not append to string"); - + if (!_dbus_string_move (&str, 0, &other, _dbus_string_get_length (&other) / 2)) _dbus_assert_not_reached ("could not move"); _dbus_assert (_dbus_string_get_length (&str) == 0); _dbus_assert (_dbus_string_get_length (&other) == i * 3); - + _dbus_string_free (&other); /* Check copy */ - + if (!_dbus_string_append (&str, "Hello World")) _dbus_assert_not_reached ("could not append to string"); i = _dbus_string_get_length (&str); - + if (!_dbus_string_init (&other)) _dbus_assert_not_reached ("could not init string"); - + if (!_dbus_string_copy (&str, 0, &other, 0)) _dbus_assert_not_reached ("could not copy"); @@ -411,7 +411,7 @@ _dbus_string_test (void) _dbus_assert (_dbus_string_get_length (&other) == i * 3); _dbus_assert (_dbus_string_equal_c_str (&other, "Hello WorldHello WorldHello World")); - + _dbus_string_free (&str); _dbus_string_free (&other); @@ -419,15 +419,15 @@ _dbus_string_test (void) if (!_dbus_string_init (&str)) _dbus_assert_not_reached ("failed to init string"); - + if (!_dbus_string_append (&str, "Hello World")) _dbus_assert_not_reached ("could not append to string"); i = _dbus_string_get_length (&str); - + if (!_dbus_string_init (&other)) _dbus_assert_not_reached ("could not init string"); - + if (!_dbus_string_replace_len (&str, 0, _dbus_string_get_length (&str), &other, 0, _dbus_string_get_length (&other))) _dbus_assert_not_reached ("could not replace"); @@ -435,7 +435,7 @@ _dbus_string_test (void) _dbus_assert (_dbus_string_get_length (&str) == i); _dbus_assert (_dbus_string_get_length (&other) == i); _dbus_assert (_dbus_string_equal_c_str (&other, "Hello World")); - + if (!_dbus_string_replace_len (&str, 0, _dbus_string_get_length (&str), &other, 5, 1)) _dbus_assert_not_reached ("could not replace center space"); @@ -445,13 +445,13 @@ _dbus_string_test (void) _dbus_assert (_dbus_string_equal_c_str (&other, "HelloHello WorldWorld")); - + if (!_dbus_string_replace_len (&str, 1, 1, &other, _dbus_string_get_length (&other) - 1, 1)) _dbus_assert_not_reached ("could not replace end character"); - + _dbus_assert (_dbus_string_get_length (&str) == i); _dbus_assert (_dbus_string_get_length (&other) == i * 2 - 1); _dbus_assert (_dbus_string_equal_c_str (&other, @@ -467,12 +467,12 @@ _dbus_string_test (void) if (!_dbus_string_init (&str)) _dbus_assert_not_reached ("failed to init string"); - + if (!_dbus_string_append (&str, "Hello World")) _dbus_assert_not_reached ("could not append to string"); i = _dbus_string_get_length (&str); - + if (!_dbus_string_init (&other)) _dbus_assert_not_reached ("could not init string"); @@ -545,7 +545,7 @@ _dbus_string_test (void) _dbus_string_free (&other); /* Check insert/set/get byte */ - + if (!_dbus_string_init (&str)) _dbus_assert_not_reached ("failed to init string"); @@ -569,7 +569,7 @@ _dbus_string_test (void) if (!_dbus_string_insert_bytes (&str, _dbus_string_get_length (&str), 1, 'W')) _dbus_assert_not_reached ("can't insert byte"); - + _dbus_assert (_dbus_string_get_byte (&str, 0) == 255); _dbus_assert (_dbus_string_get_byte (&str, 1) == 'H'); _dbus_assert (_dbus_string_get_byte (&str, 2) == 'Z'); @@ -583,9 +583,9 @@ _dbus_string_test (void) _dbus_assert (_dbus_string_get_byte (&str, 10) == 'W'); _dbus_string_free (&str); - + /* Check append/parse int/double */ - + if (!_dbus_string_init (&str)) _dbus_assert_not_reached ("failed to init string"); @@ -608,7 +608,7 @@ _dbus_string_test (void) if (!_dbus_string_append (&str, "Hello")) _dbus_assert_not_reached ("couldn't append to string"); - + if (!_dbus_string_find (&str, 0, "He", &i)) _dbus_assert_not_reached ("didn't find 'He'"); _dbus_assert (i == 0); @@ -616,7 +616,7 @@ _dbus_string_test (void) if (!_dbus_string_find (&str, 0, "Hello", &i)) _dbus_assert_not_reached ("didn't find 'Hello'"); _dbus_assert (i == 0); - + if (!_dbus_string_find (&str, 0, "ello", &i)) _dbus_assert_not_reached ("didn't find 'ello'"); _dbus_assert (i == 1); @@ -631,7 +631,7 @@ _dbus_string_test (void) if (_dbus_string_find (&str, 4, "lo", &i)) _dbus_assert_not_reached ("did find 'lo'"); - + if (!_dbus_string_find (&str, 0, "l", &i)) _dbus_assert_not_reached ("didn't find 'l'"); _dbus_assert (i == 2); @@ -643,13 +643,13 @@ _dbus_string_test (void) if (!_dbus_string_find (&str, 0, "", &i)) _dbus_assert_not_reached ("didn't find ''"); _dbus_assert (i == 0); - + if (_dbus_string_find (&str, 0, "Hello!", NULL)) _dbus_assert_not_reached ("Did find 'Hello!'"); if (_dbus_string_find (&str, 0, "Oh, Hello", NULL)) _dbus_assert_not_reached ("Did find 'Oh, Hello'"); - + if (_dbus_string_find (&str, 0, "ill", NULL)) _dbus_assert_not_reached ("Did find 'ill'"); @@ -681,7 +681,7 @@ _dbus_string_test (void) if (!_dbus_string_find_byte_backward (&str, 2, 'e', &i)) _dbus_assert_not_reached ("Didn't find 'e'"); _dbus_assert (i == 1); - + _dbus_string_free (&str); /* Hex encoding */ @@ -697,28 +697,28 @@ _dbus_string_test (void) _dbus_string_free (&other); test_roundtrips (test_hex_roundtrip); - + _dbus_string_free (&str); - { - int found, found_len; + { + int found, found_len; _dbus_string_init_const (&str, "012\r\n567\n90"); - + if (!_dbus_string_find_eol (&str, 0, &found, &found_len) || found != 3 || found_len != 2) - _dbus_assert_not_reached ("Did not find '\\r\\n'"); - if (found != 3 || found_len != 2) - _dbus_assert_not_reached ("invalid return values"); - - if (!_dbus_string_find_eol (&str, 5, &found, &found_len)) - _dbus_assert_not_reached ("Did not find '\\n'"); - if (found != 8 || found_len != 1) - _dbus_assert_not_reached ("invalid return values"); - - if (_dbus_string_find_eol (&str, 9, &found, &found_len)) - _dbus_assert_not_reached ("Found not expected '\\n'"); - else if (found != 11 || found_len != 0) - _dbus_assert_not_reached ("invalid return values '\\n'"); + _dbus_assert_not_reached ("Did not find '\\r\\n'"); + if (found != 3 || found_len != 2) + _dbus_assert_not_reached ("invalid return values"); + + if (!_dbus_string_find_eol (&str, 5, &found, &found_len)) + _dbus_assert_not_reached ("Did not find '\\n'"); + if (found != 8 || found_len != 1) + _dbus_assert_not_reached ("invalid return values"); + + if (_dbus_string_find_eol (&str, 9, &found, &found_len)) + _dbus_assert_not_reached ("Found not expected '\\n'"); + else if (found != 11 || found_len != 0) + _dbus_assert_not_reached ("invalid return values '\\n'"); found = -1; found_len = -1; @@ -727,7 +727,7 @@ _dbus_string_test (void) _dbus_assert_not_reached ("found an eol in an empty string"); _dbus_assert (found == 0); _dbus_assert (found_len == 0); - + found = -1; found_len = -1; _dbus_string_init_const (&str, "foobar"); @@ -753,36 +753,36 @@ _dbus_string_test (void) /* third line is empty */ #define THIRD_LINE "" #define FOURTH_LINE "this is a fourth line" - + if (!_dbus_string_init (&str)) _dbus_assert_not_reached ("no memory"); if (!_dbus_string_append (&str, FIRST_LINE "\n" SECOND_LINE "\r\n" THIRD_LINE "\n" FOURTH_LINE)) _dbus_assert_not_reached ("no memory"); - + if (!_dbus_string_init (&line)) _dbus_assert_not_reached ("no memory"); - + if (!_dbus_string_pop_line (&str, &line)) _dbus_assert_not_reached ("failed to pop first line"); _dbus_assert (_dbus_string_equal_c_str (&line, FIRST_LINE)); - + if (!_dbus_string_pop_line (&str, &line)) _dbus_assert_not_reached ("failed to pop second line"); _dbus_assert (_dbus_string_equal_c_str (&line, SECOND_LINE)); - + if (!_dbus_string_pop_line (&str, &line)) _dbus_assert_not_reached ("failed to pop third line"); _dbus_assert (_dbus_string_equal_c_str (&line, THIRD_LINE)); - + if (!_dbus_string_pop_line (&str, &line)) _dbus_assert_not_reached ("failed to pop fourth line"); _dbus_assert (_dbus_string_equal_c_str (&line, FOURTH_LINE)); - + _dbus_string_free (&str); _dbus_string_free (&line); } diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c index 98d9f2b..1f5a446 100644 --- a/dbus/dbus-string.c +++ b/dbus/dbus-string.c @@ -1,11 +1,11 @@ /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ /* dbus-string.c String utility class (internal to D-Bus implementation) - * + * * Copyright (C) 2002, 2003, 2004, 2005 Red Hat, Inc. * Copyright (C) 2006 Ralf Habacker * * Licensed under the Academic Free License version 2.1 - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -15,7 +15,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA @@ -48,12 +48,12 @@ * used (or extended and then used) rather than the libc stuff in * string.h. The string class is a bit inconvenient at spots because * it handles out-of-memory failures and tries to be extra-robust. - * + * * A DBusString has a maximum length set at initialization time; this * can be used to ensure that a buffer doesn't get too big. The * _dbus_string_lengthen() method checks for overflow, and for max * length being exceeded. - * + * * Try to avoid conversion to a plain C string, i.e. add methods on * the string object instead, only convert to C string when passing * things out to the public API. In particular, no sprintf, strcpy, @@ -84,15 +84,15 @@ fixup_alignment (DBusRealString *real) /* we have to have extra space in real->allocated for the align offset and nul byte */ _dbus_assert (real->len <= real->allocated - _DBUS_STRING_ALLOCATION_PADDING); - + old_align_offset = real->align_offset; real_block = real->str - old_align_offset; - + aligned = _DBUS_ALIGN_ADDRESS (real_block, 8); real->align_offset = aligned - real_block; real->str = aligned; - + if (old_align_offset != real->align_offset) { /* Here comes the suck */ @@ -123,7 +123,7 @@ undo_alignment (DBusRealString *real) * Initializes a string that can be up to the given allocation size * before it has to realloc. The string starts life with zero length. * The string must eventually be freed with _dbus_string_free(). - * + * * @param str memory to hold the string * @param allocate_size amount to preallocate * @returns #TRUE on success, #FALSE if no memory @@ -145,29 +145,29 @@ _dbus_string_init_preallocated (DBusString *str, * since we also use this function to reset * an existing string, e.g. in _dbus_string_steal_data() */ - + real->str = dbus_malloc (_DBUS_STRING_ALLOCATION_PADDING + allocate_size); if (real->str == NULL) - return FALSE; - + return FALSE; + real->allocated = _DBUS_STRING_ALLOCATION_PADDING + allocate_size; real->len = 0; real->str[real->len] = '\0'; - + real->constant = FALSE; real->locked = FALSE; real->invalid = FALSE; real->align_offset = 0; - + fixup_alignment (real); - + return TRUE; } /** * Initializes a string. The string starts life with zero length. The * string must eventually be freed with _dbus_string_free(). - * + * * @param str memory to hold the string * @returns #TRUE on success, #FALSE if no memory */ @@ -182,7 +182,7 @@ _dbus_string_init (DBusString *str) * (should be static), and the string may never be modified. * It is safe but not necessary to call _dbus_string_free() * on a const string. The string has a length limit of MAXINT - 8. - * + * * @param str memory to use for the string * @param value a string to be stored in str (not copied!!!) */ @@ -191,9 +191,9 @@ _dbus_string_init_const (DBusString *str, const char *value) { _dbus_assert (value != NULL); - + _dbus_string_init_const_len (str, value, - strlen (value)); + (int) strlen (value)); } /** @@ -201,7 +201,7 @@ _dbus_string_init_const (DBusString *str, * not copied (should be static), and the string may never be * modified. It is safe but not necessary to call _dbus_string_free() * on a const string. - * + * * @param str memory to use for the string * @param value a string to be stored in str (not copied!!!) * @param len the length to use @@ -212,14 +212,14 @@ _dbus_string_init_const_len (DBusString *str, int len) { DBusRealString *real; - + _dbus_assert (str != NULL); _dbus_assert (len == 0 || value != NULL); _dbus_assert (len <= _DBUS_STRING_MAX_LENGTH); _dbus_assert (len >= 0); - + real = (DBusRealString*) str; - + real->str = (unsigned char*) value; real->len = len; real->allocated = real->len + _DBUS_STRING_ALLOCATION_PADDING; /* a lie, just to avoid special-case assertions... */ @@ -260,7 +260,7 @@ _dbus_string_free (DBusString *str) { DBusRealString *real = (DBusRealString*) str; DBUS_GENERIC_STRING_PREAMBLE (real); - + if (real->constant) return; @@ -317,7 +317,7 @@ compact (DBusRealString *real, */ void _dbus_string_lock (DBusString *str) -{ +{ DBUS_LOCKED_STRING_PREAMBLE (str); /* can lock multiple times */ real->locked = TRUE; @@ -424,11 +424,11 @@ open_gap (int len, if (len > _DBUS_STRING_MAX_LENGTH - dest->len) return FALSE; /* detected overflow of dest->len + len below */ - + if (!set_length (dest, dest->len + len)) return FALSE; - memmove (dest->str + insert_at + len, + memmove (dest->str + insert_at + len, dest->str + insert_at, dest->len - len - insert_at); @@ -451,7 +451,7 @@ char* _dbus_string_get_data (DBusString *str) { DBUS_STRING_PREAMBLE (str); - + return (char*) real->str; } #endif /* _dbus_string_get_data */ @@ -468,7 +468,7 @@ const char* _dbus_string_get_const_data (const DBusString *str) { DBUS_CONST_STRING_PREAMBLE (str); - + return (const char*) real->str; } #endif /* _dbus_string_get_const_data */ @@ -496,7 +496,7 @@ _dbus_string_get_data_len (DBusString *str, _dbus_assert (len >= 0); _dbus_assert (start <= real->len); _dbus_assert (len <= real->len - start); - + return (char*) real->str + start; } @@ -520,7 +520,7 @@ _dbus_string_get_const_data_len (const DBusString *str, _dbus_assert (len >= 0); _dbus_assert (start <= real->len); _dbus_assert (len <= real->len - start); - + return (const char*) real->str + start; } #endif /* _dbus_string_get_const_data_len */ @@ -542,7 +542,7 @@ _dbus_string_set_byte (DBusString *str, DBUS_STRING_PREAMBLE (str); _dbus_assert (i < real->len); _dbus_assert (i >= 0); - + real->str[i] = byte; } #endif /* _dbus_string_set_byte */ @@ -565,7 +565,7 @@ _dbus_string_get_byte (const DBusString *str, DBUS_CONST_STRING_PREAMBLE (str); _dbus_assert (start <= real->len); _dbus_assert (start >= 0); - + return real->str[start]; } #endif /* _dbus_string_get_byte */ @@ -593,10 +593,10 @@ _dbus_string_insert_bytes (DBusString *str, if (n_bytes == 0) return TRUE; - + if (!open_gap (n_bytes, real, i)) return FALSE; - + memset (real->str + i, byte, n_bytes); return TRUE; @@ -618,7 +618,7 @@ _dbus_string_insert_byte (DBusString *str, DBUS_STRING_PREAMBLE (str); _dbus_assert (i <= real->len); _dbus_assert (i >= 0); - + if (!open_gap (1, real, i)) return FALSE; @@ -645,7 +645,7 @@ _dbus_string_steal_data (DBusString *str, _dbus_assert (data_return != NULL); undo_alignment (real); - + *data_return = (char*) real->str; /* reset the string */ @@ -674,7 +674,7 @@ _dbus_string_copy_data (const DBusString *str, { DBUS_CONST_STRING_PREAMBLE (str); _dbus_assert (data_return != NULL); - + *data_return = dbus_malloc (real->len + 1); if (*data_return == NULL) return FALSE; @@ -688,7 +688,7 @@ _dbus_string_copy_data (const DBusString *str, * Copies the contents of a DBusString into a different buffer. It is * a bug if avail_len is too short to hold the string contents. nul * termination is not copied, just the supplied bytes. - * + * * @param str a string * @param buffer a C buffer to copy data to * @param avail_len maximum length of C buffer @@ -702,15 +702,15 @@ _dbus_string_copy_to_buffer (const DBusString *str, _dbus_assert (avail_len >= 0); _dbus_assert (avail_len >= real->len); - + memcpy (buffer, real->str, real->len); } /** * Copies the contents of a DBusString into a different buffer. It is * a bug if avail_len is too short to hold the string contents plus a - * nul byte. - * + * nul byte. + * * @param str a string * @param buffer a C buffer to copy data to * @param avail_len maximum length of C buffer @@ -724,7 +724,7 @@ _dbus_string_copy_to_buffer_with_nul (const DBusString *str, _dbus_assert (avail_len >= 0); _dbus_assert (avail_len > real->len); - + memcpy (buffer, real->str, real->len+1); } @@ -739,7 +739,7 @@ int _dbus_string_get_length (const DBusString *str) { DBUS_CONST_STRING_PREAMBLE (str); - + return real->len; } #endif /* !_dbus_string_get_length */ @@ -760,12 +760,12 @@ dbus_bool_t _dbus_string_lengthen (DBusString *str, int additional_length) { - DBUS_STRING_PREAMBLE (str); + DBUS_STRING_PREAMBLE (str); _dbus_assert (additional_length >= 0); if (_DBUS_UNLIKELY (additional_length > _DBUS_STRING_MAX_LENGTH - real->len)) return FALSE; /* would overflow */ - + return set_length (real, real->len + additional_length); } @@ -825,13 +825,13 @@ align_insert_point_then_open_gap (DBusString *str, insert_at = *insert_at_p; _dbus_assert (insert_at <= real->len); - + gap_pos = _DBUS_ALIGN_VALUE (insert_at, alignment); new_len = real->len + (gap_pos - insert_at) + gap_size; - + if (_DBUS_UNLIKELY (new_len > (unsigned long) _DBUS_STRING_MAX_LENGTH)) return FALSE; - + delta = new_len - real->len; _dbus_assert (delta >= 0); @@ -853,7 +853,7 @@ align_insert_point_then_open_gap (DBusString *str, } *insert_at_p = gap_pos; - + return TRUE; } @@ -865,7 +865,7 @@ align_length_then_lengthen (DBusString *str, int insert_at; insert_at = _dbus_string_get_length (str); - + return align_insert_point_then_open_gap (str, &insert_at, alignment, then_lengthen_by); @@ -936,14 +936,14 @@ _dbus_string_append (DBusString *str, const char *buffer) { unsigned long buffer_len; - + DBUS_STRING_PREAMBLE (str); _dbus_assert (buffer != NULL); - - buffer_len = strlen (buffer); + + buffer_len = (int) strlen (buffer); if (buffer_len > (unsigned long) _DBUS_STRING_MAX_LENGTH) return FALSE; - + return append (real, buffer, buffer_len); } @@ -974,7 +974,7 @@ _dbus_string_insert_2_aligned (DBusString *str, const unsigned char octets[2]) { DBUS_STRING_PREAMBLE (str); - + if (!align_insert_point_then_open_gap (str, &insert_at, 2, 2)) return FALSE; @@ -998,7 +998,7 @@ _dbus_string_insert_4_aligned (DBusString *str, const unsigned char octets[4]) { DBUS_STRING_PREAMBLE (str); - + if (!align_insert_point_then_open_gap (str, &insert_at, 4, 4)) return FALSE; @@ -1022,12 +1022,12 @@ _dbus_string_insert_8_aligned (DBusString *str, const unsigned char octets[8]) { DBUS_STRING_PREAMBLE (str); - + if (!align_insert_point_then_open_gap (str, &insert_at, 8, 8)) return FALSE; _dbus_assert (_DBUS_ALIGN_VALUE (insert_at, 8) == (unsigned) insert_at); - + ASSIGN_8_OCTETS (real->str + insert_at, octets); return TRUE; @@ -1050,7 +1050,7 @@ _dbus_string_insert_alignment (DBusString *str, int alignment) { DBUS_STRING_PREAMBLE (str); - + if (!align_insert_point_then_open_gap (str, insert_at, alignment, 0)) return FALSE; @@ -1091,7 +1091,7 @@ _dbus_string_append_printf_valist (DBusString *str, { goto out; } - + vsprintf ((char*) (real->str + (real->len - len)), format, args_copy); ret = TRUE; @@ -1117,7 +1117,7 @@ _dbus_string_append_printf (DBusString *str, { va_list args; dbus_bool_t retval; - + va_start (args, format); retval = _dbus_string_append_printf_valist (str, format, args); va_end (args); @@ -1174,7 +1174,7 @@ delete (DBusRealString *real, { if (len == 0) return; - + memmove (real->str + start, real->str + start + len, real->len - (start + len)); real->len -= len; real->str[real->len] = '\0'; @@ -1199,7 +1199,7 @@ _dbus_string_delete (DBusString *str, _dbus_assert (len >= 0); _dbus_assert (start <= real->len); _dbus_assert (len <= real->len - start); - + delete (real, start, len); } @@ -1215,7 +1215,7 @@ copy (DBusRealString *source, if (!open_gap (len, dest, insert_at)) return FALSE; - + memmove (dest->str + insert_at, source->str + start, len); @@ -1263,7 +1263,7 @@ _dbus_string_move (DBusString *source, { DBusRealString *real_source = (DBusRealString*) source; _dbus_assert (start <= real_source->len); - + return _dbus_string_move_len (source, start, real_source->len - start, dest, insert_at); @@ -1337,7 +1337,7 @@ _dbus_string_move_len (DBusString *source, (a)->allocated = (b)->allocated; \ (a)->align_offset = (b)->align_offset; \ } while (0) - + DBusRealString tmp; ASSIGN_DATA (&tmp, real_source); @@ -1352,10 +1352,10 @@ _dbus_string_move_len (DBusString *source, real_dest, insert_at)) return FALSE; - + delete (real_source, start, len); - + return TRUE; } } @@ -1382,7 +1382,7 @@ _dbus_string_copy_len (const DBusString *source, _dbus_assert (len >= 0); _dbus_assert (start <= real_source->len); _dbus_assert (len <= real_source->len - start); - + return copy (real_source, start, len, real_dest, insert_at); @@ -1549,7 +1549,7 @@ _dbus_string_split_on_byte (DBusString *source, ((Char) < 0x10000 ? 3 : \ ((Char) < 0x200000 ? 4 : \ ((Char) < 0x4000000 ? 5 : 6))))) - + /** * Gets a UTF-8 value. * @@ -1634,32 +1634,32 @@ _dbus_string_find_eol (const DBusString *str, DBUS_CONST_STRING_PREAMBLE (str); _dbus_assert (start <= real->len); _dbus_assert (start >= 0); - + i = start; while (i < real->len) { - if (real->str[i] == '\r') + if (real->str[i] == '\r') { if ((i+1) < real->len && real->str[i+1] == '\n') /* "\r\n" */ { - if (found) + if (found) *found = i; if (found_len) *found_len = 2; return TRUE; - } + } else /* only "\r" */ { - if (found) + if (found) *found = i; if (found_len) *found_len = 1; return TRUE; } - } + } else if (real->str[i] == '\n') /* only "\n" */ { - if (found) + if (found) *found = i; if (found_len) *found_len = 1; @@ -1673,7 +1673,7 @@ _dbus_string_find_eol (const DBusString *str, if (found_len) *found_len = 0; - + return FALSE; } @@ -1723,14 +1723,14 @@ _dbus_string_find_to (const DBusString *str, if (real->str[i] == substr[0]) { int j = i + 1; - + while (j < end) { if (substr[j - i] == '\0') break; else if (real->str[j] != substr[j - i]) break; - + ++j; } @@ -1741,14 +1741,14 @@ _dbus_string_find_to (const DBusString *str, return TRUE; } } - + ++i; } if (found) *found = end; - - return FALSE; + + return FALSE; } /** @@ -1770,7 +1770,7 @@ _dbus_string_find_blank (const DBusString *str, DBUS_CONST_STRING_PREAMBLE (str); _dbus_assert (start <= real->len); _dbus_assert (start >= 0); - + i = start; while (i < real->len) { @@ -1781,13 +1781,13 @@ _dbus_string_find_blank (const DBusString *str, *found = i; return TRUE; } - + ++i; } if (found) *found = real->len; - + return FALSE; } @@ -1808,18 +1808,18 @@ _dbus_string_skip_blank (const DBusString *str, DBUS_CONST_STRING_PREAMBLE (str); _dbus_assert (start <= real->len); _dbus_assert (start >= 0); - + i = start; while (i < real->len) { if (!DBUS_IS_ASCII_BLANK (real->str[i])) break; - + ++i; } _dbus_assert (i == real->len || !DBUS_IS_ASCII_WHITE (real->str[i])); - + if (end) *end = i; } @@ -1842,18 +1842,18 @@ _dbus_string_skip_white (const DBusString *str, DBUS_CONST_STRING_PREAMBLE (str); _dbus_assert (start <= real->len); _dbus_assert (start >= 0); - + i = start; while (i < real->len) { if (!DBUS_IS_ASCII_WHITE (real->str[i])) break; - + ++i; } _dbus_assert (i == real->len || !(DBUS_IS_ASCII_WHITE (real->str[i]))); - + if (end) *end = i; } @@ -1875,7 +1875,7 @@ _dbus_string_skip_white_reverse (const DBusString *str, DBUS_CONST_STRING_PREAMBLE (str); _dbus_assert (end <= real->len); _dbus_assert (end >= 0); - + i = end; while (i > 0) { @@ -1885,7 +1885,7 @@ _dbus_string_skip_white_reverse (const DBusString *str, } _dbus_assert (i >= 0 && (i == 0 || !(DBUS_IS_ASCII_WHITE (real->str[i-1])))); - + if (start) *start = i; } @@ -1900,7 +1900,7 @@ _dbus_string_skip_white_reverse (const DBusString *str, * written purely for test code, * e.g. dbus-message-builder.c). Probably should be enforced as test * code only with ifdef DBUS_ENABLE_EMBEDDED_TESTS - * + * * @param source the source string * @param dest the destination string (contents are replaced) * @returns #FALSE if no memory, or source has length 0 @@ -1910,9 +1910,9 @@ _dbus_string_pop_line (DBusString *source, DBusString *dest) { int eol, eol_len; - + _dbus_string_set_length (dest, 0); - + eol = 0; eol_len = 0; if (!_dbus_string_find_eol (source, 0, &eol, &eol_len)) @@ -1929,10 +1929,10 @@ _dbus_string_pop_line (DBusString *source, /* remember eol can be 0 if it's an empty line, but eol_len should not be zero also * since find_eol returned TRUE */ - + if (!_dbus_string_move_len (source, 0, eol + eol_len, dest, 0)) return FALSE; - + /* remove line ending */ if (!_dbus_string_set_length (dest, eol)) { @@ -1954,7 +1954,7 @@ void _dbus_string_delete_first_word (DBusString *str) { int i; - + if (_dbus_string_find_blank (str, 0, &i)) _dbus_string_skip_blank (str, i, &i); @@ -1972,7 +1972,7 @@ void _dbus_string_delete_leading_blanks (DBusString *str) { int i; - + _dbus_string_skip_blank (str, 0, &i); if (i > 0) @@ -1982,19 +1982,19 @@ _dbus_string_delete_leading_blanks (DBusString *str) /** * Deletes leading and trailing whitespace - * + * * @param str the string */ void _dbus_string_chop_white(DBusString *str) { int i; - + _dbus_string_skip_white (str, 0, &i); if (i > 0) _dbus_string_delete (str, 0, i); - + _dbus_string_skip_white_reverse (str, _dbus_string_get_length (str), &i); _dbus_string_set_length (str, i); @@ -2031,7 +2031,7 @@ _dbus_string_equal (const DBusString *a, { if (*ap != *bp) return FALSE; - + ++ap; ++bp; } @@ -2076,7 +2076,7 @@ _dbus_string_equal_len (const DBusString *a, { if (*ap != *bp) return FALSE; - + ++ap; ++bp; } @@ -2120,7 +2120,7 @@ _dbus_string_equal_substring (const DBusString *a, _dbus_assert (a_len <= real_a->len - a_start); _dbus_assert (b_start >= 0); _dbus_assert (b_start <= real_b->len); - + if (a_len > real_b->len - b_start) return FALSE; @@ -2131,13 +2131,13 @@ _dbus_string_equal_substring (const DBusString *a, { if (*ap != *bp) return FALSE; - + ++ap; ++bp; } _dbus_assert (bp <= (real_b->str + real_b->len)); - + return TRUE; } @@ -2158,7 +2158,7 @@ _dbus_string_equal_c_str (const DBusString *a, const DBusRealString *real_a = (const DBusRealString*) a; DBUS_GENERIC_STRING_PREAMBLE (real_a); _dbus_assert (c_str != NULL); - + ap = real_a->str; bp = (const unsigned char*) c_str; a_end = real_a->str + real_a->len; @@ -2166,14 +2166,14 @@ _dbus_string_equal_c_str (const DBusString *a, { if (*ap != *bp) return FALSE; - + ++ap; ++bp; } if (ap != a_end || *bp) return FALSE; - + return TRUE; } @@ -2194,7 +2194,7 @@ _dbus_string_starts_with_c_str (const DBusString *a, const DBusRealString *real_a = (const DBusRealString*) a; DBUS_GENERIC_STRING_PREAMBLE (real_a); _dbus_assert (c_str != NULL); - + ap = real_a->str; bp = (const unsigned char*) c_str; a_end = real_a->str + real_a->len; @@ -2202,7 +2202,7 @@ _dbus_string_starts_with_c_str (const DBusString *a, { if (*ap != *bp) return FALSE; - + ++ap; ++bp; } @@ -2233,7 +2233,7 @@ _dbus_string_append_byte_as_hex (DBusString *str, if (!_dbus_string_append_byte (str, hexdigits[(byte >> 4)])) return FALSE; - + if (!_dbus_string_append_byte (str, hexdigits[(byte & 0x0f)])) { @@ -2265,23 +2265,23 @@ _dbus_string_hex_encode (const DBusString *source, const unsigned char *p; const unsigned char *end; dbus_bool_t retval; - + _dbus_assert (start <= _dbus_string_get_length (source)); if (!_dbus_string_init (&result)) return FALSE; retval = FALSE; - + p = (const unsigned char*) _dbus_string_get_const_data (source); end = p + _dbus_string_get_length (source); p += start; - + while (p != end) { if (!_dbus_string_append_byte_as_hex (&result, *p)) goto out; - + ++p; } @@ -2317,7 +2317,7 @@ _dbus_string_hex_decode (const DBusString *source, const unsigned char *end; dbus_bool_t retval; dbus_bool_t high_bits; - + _dbus_assert (start <= _dbus_string_get_length (source)); if (!_dbus_string_init (&result)) @@ -2329,7 +2329,7 @@ _dbus_string_hex_decode (const DBusString *source, p = (const unsigned char*) _dbus_string_get_const_data (source); end = p + _dbus_string_get_length (source); p += start; - + while (p != end) { unsigned int val; @@ -2406,7 +2406,7 @@ _dbus_string_hex_decode (const DBusString *source, unsigned char b; len = _dbus_string_get_length (&result); - + b = _dbus_string_get_byte (&result, len - 1); b |= val; @@ -2427,9 +2427,9 @@ _dbus_string_hex_decode (const DBusString *source, *end_return = p - (const unsigned char*) _dbus_string_get_const_data (source); retval = TRUE; - + out: - _dbus_string_free (&result); + _dbus_string_free (&result); return retval; } @@ -2440,7 +2440,7 @@ _dbus_string_hex_decode (const DBusString *source, * * @todo this is inconsistent with most of DBusString in that * it allows a start,len range that extends past the string end. - * + * * @param str the string * @param start first byte index to check * @param len number of bytes to check @@ -2457,20 +2457,20 @@ _dbus_string_validate_ascii (const DBusString *str, _dbus_assert (start >= 0); _dbus_assert (start <= real->len); _dbus_assert (len >= 0); - + if (len > real->len - start) return FALSE; - + s = real->str + start; end = s + len; while (s != end) { if (_DBUS_UNLIKELY (!_DBUS_ISASCII (*s))) return FALSE; - + ++s; } - + return TRUE; } @@ -2545,7 +2545,7 @@ _dbus_string_toupper_ascii (const DBusString *str, * * @todo this is inconsistent with most of DBusString in that * it allows a start,len range that extends past the string end. - * + * * @param str the string * @param start first byte index to check * @param len number of bytes to check @@ -2570,13 +2570,13 @@ _dbus_string_validate_utf8 (const DBusString *str, * UTF-8. Also, this function seems to be a performance * bottleneck in profiles. */ - + if (_DBUS_UNLIKELY (len > real->len - start)) return FALSE; - + p = real->str + start; end = p + len; - + while (p < end) { int i, mask, char_len; @@ -2585,19 +2585,19 @@ _dbus_string_validate_utf8 (const DBusString *str, /* nul bytes considered invalid */ if (*p == '\0') break; - + /* Special-case ASCII; this makes us go a lot faster in * D-Bus profiles where we are typically validating * function names and such. We have to know that * all following checks will pass for ASCII though, * comments follow ... - */ + */ if (*p < 128) { ++p; continue; } - + UTF8_COMPUTE (*p, mask, char_len); if (_DBUS_UNLIKELY (char_len == 0)) /* ASCII: char_len == 1 */ @@ -2606,7 +2606,7 @@ _dbus_string_validate_utf8 (const DBusString *str, /* check that the expected number of bytes exists in the remaining length */ if (_DBUS_UNLIKELY ((end - p) < char_len)) /* ASCII: p < end and char_len == 1 */ break; - + UTF8_GET (result, p, i, mask, char_len); /* Check for overlong UTF-8 */ @@ -2623,7 +2623,7 @@ _dbus_string_validate_utf8 (const DBusString *str, /* UNICODE_VALID should have caught it */ _dbus_assert (result != (dbus_unichar_t)-1); - + p += char_len; } @@ -2643,7 +2643,7 @@ _dbus_string_validate_utf8 (const DBusString *str, * * @todo this is inconsistent with most of DBusString in that * it allows a start,len range that extends past the string end. - * + * * @param str the string * @param start first byte index to check * @param len number of bytes to check @@ -2660,10 +2660,10 @@ _dbus_string_validate_nul (const DBusString *str, _dbus_assert (start >= 0); _dbus_assert (len >= 0); _dbus_assert (start <= real->len); - + if (len > real->len - start) return FALSE; - + s = real->str + start; end = s + len; while (s != end) @@ -2672,7 +2672,7 @@ _dbus_string_validate_nul (const DBusString *str, return FALSE; ++s; } - + return TRUE; } diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c index e83c539..f0204af 100644 --- a/dbus/dbus-sysdeps-util-win.c +++ b/dbus/dbus-sysdeps-util-win.c @@ -1,11 +1,11 @@ /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ /* dbus-sysdeps-util.c Would be in dbus-sysdeps.c, but not used in libdbus - * + * * Copyright (C) 2002, 2003, 2004, 2005 Red Hat, Inc. * Copyright (C) 2003 CodeFactory AB * * Licensed under the Academic Free License version 2.1 - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -15,7 +15,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA @@ -117,7 +117,7 @@ _dbus_write_pid_file (const DBusString *filename, } total = 0; - bytes_to_write = strlen (pidstr);; + bytes_to_write = (int) strlen (pidstr);; while (total < bytes_to_write) { @@ -335,19 +335,19 @@ _dbus_system_logv (DBusSystemLogSeverity severity, const char *msg, va_list args { char *s = ""; char buf[1024]; - - switch(severity) + + switch(severity) { case DBUS_SYSTEM_LOG_INFO: s = "info"; break; case DBUS_SYSTEM_LOG_WARNING: s = "warning"; break; case DBUS_SYSTEM_LOG_SECURITY: s = "security"; break; case DBUS_SYSTEM_LOG_FATAL: s = "fatal"; break; } - + sprintf(buf,"%s%s",s,msg); vsprintf(buf,buf,args); OutputDebugStringA(buf); - + if (severity == DBUS_SYSTEM_LOG_FATAL) exit (1); } @@ -428,7 +428,7 @@ _dbus_stat(const DBusString *filename, LocalFree (sd); return FALSE; } - + /* FIXME */ statbuf->uid = _dbus_win_sid_to_uid_t (owner_sid); statbuf->gid = _dbus_win_sid_to_uid_t (group_sid); @@ -721,7 +721,7 @@ dbus_bool_t _dbus_windows_user_is_process_owner (const char *windows_sid) * Should always fail on Windows (set the error to * #DBUS_ERROR_NOT_SUPPORTED). * - * @param uid UID of person to check + * @param uid UID of person to check * @param error return location for errors * @returns #TRUE if the UID is the same as the console user and there are no errors */ @@ -789,9 +789,9 @@ _dbus_unix_groups_from_uid (dbus_uid_t uid, /** @} */ /* DBusString stuff */ /************************************************************************ - + error handling - + ************************************************************************/ diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 6e59c5e..3d341d1 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -1,6 +1,6 @@ /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ /* dbus-sysdeps.c Wrappers around system/libc features (internal to D-BUS implementation) - * + * * Copyright (C) 2002, 2003 Red Hat, Inc. * Copyright (C) 2003 CodeFactory AB * Copyright (C) 2005 Novell, Inc. @@ -9,7 +9,7 @@ * Copyright (C) 2006-2013 Ralf Habacker * * Licensed under the Academic Free License version 2.1 - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -19,7 +19,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA @@ -306,7 +306,7 @@ _dbus_win_error_from_last_error (void) { case 0: return DBUS_ERROR_FAILED; - + case ERROR_NO_MORE_FILES: case ERROR_TOO_MANY_OPEN_FILES: return DBUS_ERROR_LIMITS_EXCEEDED; /* kernel out of memory */ @@ -325,7 +325,7 @@ _dbus_win_error_from_last_error (void) case ERROR_PATH_NOT_FOUND: return DBUS_ERROR_FILE_NOT_FOUND; } - + return DBUS_ERROR_FAILED; } @@ -365,8 +365,8 @@ _dbus_win_free_error_string (char *string) * the data it reads to the DBusString buffer. It appends * up to the given count, and returns the same value * and same errno as read(). The only exception is that - * _dbus_read_socket() handles EINTR for you. - * _dbus_read_socket() can return ENOMEM, even though + * _dbus_read_socket() handles EINTR for you. + * _dbus_read_socket() can return ENOMEM, even though * regular UNIX read doesn't. * * @param fd the file descriptor to read from @@ -397,10 +397,10 @@ _dbus_read_socket (int fd, data = _dbus_string_get_data_len (buffer, start, count); again: - + _dbus_verbose ("recv: count=%d fd=%d\n", count, fd); bytes_read = recv (fd, data, count, 0); - + if (bytes_read == SOCKET_ERROR) { DBUS_SOCKET_SET_ERRNO(); @@ -414,7 +414,7 @@ _dbus_read_socket (int fd, { if (errno == EINTR) goto again; - else + else { /* put length back (note that this doesn't actually realloc anything) */ _dbus_string_set_length (buffer, start); @@ -438,7 +438,7 @@ _dbus_read_socket (int fd, /** * Thin wrapper around the write() system call that writes a part of a * DBusString and handles EINTR for you. - * + * * @param fd the file descriptor to write * @param buffer the buffer to write data from * @param start the first byte in the buffer to write @@ -472,7 +472,7 @@ _dbus_write_socket (int fd, if (bytes_written < 0 && errno == EINTR) goto again; - + #if 0 if (bytes_written > 0) _dbus_verbose_bytes_of_string (buffer, start, bytes_written); @@ -499,10 +499,10 @@ _dbus_close_socket (int fd, if (closesocket (fd) == SOCKET_ERROR) { DBUS_SOCKET_SET_ERRNO (); - + if (errno == EINTR) goto again; - + dbus_set_error (error, _dbus_error_from_errno (errno), "Could not close socket: socket=%d, , %s", fd, _dbus_strerror_from_errno ()); @@ -618,16 +618,16 @@ _dbus_write_socket_two (int fd, vectors[1].len = len2; again: - + _dbus_verbose ("WSASend: len1+2=%d+%d fd=%d\n", len1, len2, fd); - rc = WSASend (fd, + rc = WSASend (fd, vectors, - data2 ? 2 : 1, + data2 ? 2 : 1, &bytes_written, - 0, - NULL, + 0, + NULL, NULL); - + if (rc == SOCKET_ERROR) { DBUS_SOCKET_SET_ERRNO (); @@ -636,10 +636,10 @@ _dbus_write_socket_two (int fd, } else _dbus_verbose ("WSASend: = %ld\n", bytes_written); - + if (bytes_written < 0 && errno == EINTR) goto again; - + return bytes_written; } @@ -654,7 +654,7 @@ _dbus_socket_is_invalid (int fd) /** * Opens the client side of a Windows named pipe. The connection D-BUS * file descriptor index is returned. It is set up as nonblocking. - * + * * @param path the path to named pipe socket * @param error return location for error code * @returns connection D-BUS file descriptor or -1 on error @@ -726,13 +726,13 @@ out: /************************************************************************ - + UTF / string code - + ************************************************************************/ /** - * Measure the message length without terminating nul + * Measure the message length without terminating nul */ int _dbus_printf_string_upper_bound (const char *format, va_list args) @@ -864,8 +864,8 @@ _dbus_win_utf16_to_utf8 (const wchar_t *str, /************************************************************************ - - + + ************************************************************************/ dbus_bool_t @@ -937,7 +937,7 @@ out1: /** * The only reason this is separate from _dbus_getpid() is to allow it * on Windows for logging but not for other purposes. - * + * * @returns process ID to put in log messages */ unsigned long @@ -1039,9 +1039,9 @@ failed: #endif /************************************************************************ - + pipes - + ************************************************************************/ /** @@ -1366,7 +1366,7 @@ _dbus_poll (DBusPollFD *fds, #endif for (i = 0; i < n_fds; i++) { - DBusPollFD *fdp = &fds[i]; + DBusPollFD *fdp = &fds[i]; if (fdp->events & _DBUS_POLLIN) FD_SET (fdp->fd, &read_set); @@ -1441,19 +1441,19 @@ _dbus_poll (DBusPollFD *fds, /****************************************************************************** - + Original CVS version of dbus-sysdeps.c - + ******************************************************************************/ /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ /* dbus-sysdeps.c Wrappers around system/libc features (internal to D-Bus implementation) - * + * * Copyright (C) 2002, 2003 Red Hat, Inc. * Copyright (C) 2003 CodeFactory AB * Copyright (C) 2005 Novell, Inc. * * Licensed under the Academic Free License version 2.1 - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -1463,7 +1463,7 @@ Original CVS version of dbus-sysdeps.c * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA @@ -1483,7 +1483,7 @@ _dbus_exit (int code) } /** - * Creates a socket and connects to a socket at the given host + * Creates a socket and connects to a socket at the given host * and port. The connection fd is returned, and is set up as * nonblocking. * @@ -1568,7 +1568,7 @@ _dbus_connect_tcp_socket_with_nonce (const char *host, } _DBUS_ASSERT_ERROR_IS_CLEAR(error); - if (connect (fd, (struct sockaddr*) tmp->ai_addr, tmp->ai_addrlen) == SOCKET_ERROR) + if (connect (fd, (struct sockaddr*) tmp->ai_addr, (int) tmp->ai_addrlen) == SOCKET_ERROR) { DBUS_SOCKET_SET_ERRNO (); closesocket(fd); @@ -1632,7 +1632,7 @@ _dbus_connect_tcp_socket_with_nonce (const char *host, * If inaddr_any is specified, the hostname is ignored. * * @param host the host name to listen on - * @param port the port to listen on, if zero a free port will be used + * @param port the port to listen on, if zero a free port will be used * @param family the address family to listen on, NULL for all * @param retport string to return the actual port listened on * @param fds_p location to store returned file descriptors @@ -1720,7 +1720,7 @@ _dbus_listen_tcp_socket (const char *host, } _DBUS_ASSERT_ERROR_IS_CLEAR(error); - if (bind (fd, (struct sockaddr*) tmp->ai_addr, tmp->ai_addrlen) == SOCKET_ERROR) + if (bind (fd, (struct sockaddr*) tmp->ai_addr, (int) tmp->ai_addrlen) == SOCKET_ERROR) { DBUS_SOCKET_SET_ERRNO (); closesocket (fd); @@ -1804,7 +1804,7 @@ _dbus_listen_tcp_socket (const char *host, } } } - + tmp = tmp->ai_next; } freeaddrinfo(ai); @@ -1867,7 +1867,7 @@ _dbus_accept (int listen_fd) } _dbus_verbose ("client fd %d accepted\n", client_fd); - + return client_fd; } @@ -1896,13 +1896,13 @@ _dbus_send_credentials_socket (int handle, * pipe client without having to use impersonation?) * * client closes its handles and is done. - * + * * Ralf: Why not sending credentials over the given this connection ? - * Using named pipes makes it impossible to be connected from a unix client. + * Using named pipes makes it impossible to be connected from a unix client. * */ int bytes_written; - DBusString buf; + DBusString buf; _dbus_string_init_const_len (&buf, "\0", 1); again: @@ -1968,7 +1968,7 @@ _dbus_read_credentials_socket (int handle, { bytes_read = _dbus_read_socket (handle, &buf, 1 ); - if (bytes_read > 0) + if (bytes_read > 0) _dbus_verbose ("got one zero byte from server\n"); _dbus_string_free (&buf); @@ -1996,8 +1996,8 @@ out: } /** -* Checks to make sure the given directory is -* private to the user +* Checks to make sure the given directory is +* private to the user * * @param dir the name of the directory * @param error error return @@ -2060,7 +2060,7 @@ _dbus_concat_dir_and_file (DBusString *dir, /** * Adds the credentials corresponding to the given username. * - * @param credentials credentials to fill in + * @param credentials credentials to fill in * @param username the username * @returns #TRUE if the username existed and we got some credentials */ @@ -2113,10 +2113,10 @@ end: * is required, that is done in dbus-auth.c. The username here * need not be anything human-readable, it can be the machine-readable * form i.e. a user id. - * + * * @param str the string to append to * @returns #FALSE on no memory - * @todo to which class belongs this + * @todo to which class belongs this */ dbus_bool_t _dbus_append_user_from_current_process (DBusString *str) @@ -2290,7 +2290,7 @@ _dbus_generate_random_bytes (DBusString *str, } /** - * Gets the temporary files directory by inspecting the environment variables + * Gets the temporary files directory by inspecting the environment variables * TMPDIR, TMP, and TEMP in that order. If none of those are set "/tmp" is returned * * @returns location of temp directory, or #NULL if no memory for locking @@ -2339,7 +2339,7 @@ _dbus_get_tmpdir(void) * * @param filename the filename * @param error error location - * + * * @returns #TRUE if unlink() succeeded */ dbus_bool_t @@ -2683,7 +2683,7 @@ static dbus_uint32_t fromAscii(char ascii) return ascii - 'A' + 10; if(ascii >= 'a' && ascii <= 'f') return ascii - 'a' + 10; - return 0; + return 0; } dbus_bool_t _dbus_read_local_machine_uuid (DBusGUID *machine_id, @@ -2702,7 +2702,7 @@ dbus_bool_t _dbus_read_local_machine_uuid (DBusGUID *machine_id, if(!GetCurrentHwProfileA(&info)) { dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); // FIXME - return FALSE; + return FALSE; } // Form: {12340001-4980-1920-6788-123456789012} @@ -2729,7 +2729,7 @@ dbus_bool_t _dbus_read_local_machine_uuid (DBusGUID *machine_id, (fromAscii(lpc[7]) << 24) | (fromAscii(lpc[8]) << 28)); machine_id->as_uint32s[1] = u; - + lpc += 10; // 6788-1234 u = ((fromAscii(lpc[0]) << 0) | @@ -2741,7 +2741,7 @@ dbus_bool_t _dbus_read_local_machine_uuid (DBusGUID *machine_id, (fromAscii(lpc[7]) << 24) | (fromAscii(lpc[8]) << 28)); machine_id->as_uint32s[2] = u; - + lpc += 9; // 56789012 u = ((fromAscii(lpc[0]) << 0) | @@ -2788,7 +2788,7 @@ static void _dbus_global_unlock (HANDLE mutex) { ReleaseMutex (mutex); - CloseHandle (mutex); + CloseHandle (mutex); } // for proper cleanup in dbus-daemon @@ -2903,7 +2903,7 @@ _dbus_daemon_is_session_bus_address_published (const char *scope) hDBusDaemonMutex = CreateMutexA( NULL, FALSE, _dbus_string_get_const_data(&mutex_name) ); /* The client uses mutex ownership to detect a running server, so the server should do so too. - Fortunally the client deletes the mutex in the lock protected area, so checking presence + Fortunally the client deletes the mutex in the lock protected area, so checking presence will work too. */ _dbus_global_unlock( lock ); @@ -2966,7 +2966,7 @@ _dbus_daemon_publish_session_bus_address (const char* address, const char *scope // create shm hDBusSharedMem = CreateFileMappingA( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, - 0, strlen( address ) + 1, _dbus_string_get_const_data(&shm_name) ); + 0, (int) strlen( address ) + 1, _dbus_string_get_const_data(&shm_name) ); _dbus_assert( hDBusSharedMem ); shared_addr = MapViewOfFile( hDBusSharedMem, FILE_MAP_WRITE, 0, 0, 0 ); @@ -3180,7 +3180,7 @@ out: _DBUS_ASSERT_ERROR_IS_CLEAR (error); else _DBUS_ASSERT_ERROR_IS_SET (error); - + _dbus_global_unlock (mutex); return retval; @@ -3261,7 +3261,7 @@ _dbus_atomic_get (DBusAtomic *atomic) * caches should be nuked. Of course any caches that need explicit reload * are probably broken, but c'est la vie. * - * + * */ void _dbus_flush_caches (void) @@ -3281,7 +3281,7 @@ _dbus_get_is_errno_eagain_or_ewouldblock (int e) } /** - * return the absolute path of the dbus installation + * return the absolute path of the dbus installation * * @param prefix buffer for installation path * @param len length of buffer @@ -3323,9 +3323,9 @@ _dbus_get_install_root(char *prefix, int len) return TRUE; } -/** - find config file either from installation or build root according to - the following path layout +/** + find config file either from installation or build root according to + the following path layout install-root/ bin/dbus-daemon[d].exe etc/.conf *or* etc/dbus-1/.conf @@ -3334,9 +3334,9 @@ _dbus_get_install_root(char *prefix, int len) build-root/ bin/dbus-daemon[d].exe - bus/.conf + bus/.conf */ -dbus_bool_t +dbus_bool_t _dbus_get_config_file_name(DBusString *config_file, char *s) { char path[MAX_PATH*2]; @@ -3349,13 +3349,13 @@ _dbus_get_config_file_name(DBusString *config_file, char *s) return FALSE; strcat(path,"etc\\"); strcat(path,s); - if (_dbus_file_exists(path)) + if (_dbus_file_exists(path)) { - // find path from executable + // find path from executable if (!_dbus_string_append (config_file, path)) return FALSE; } - else + else { if (!_dbus_get_install_root(path,path_size)) return FALSE; @@ -3363,8 +3363,8 @@ _dbus_get_config_file_name(DBusString *config_file, char *s) return FALSE; strcat(path,"etc\\dbus-1\\"); strcat(path,s); - - if (_dbus_file_exists(path)) + + if (_dbus_file_exists(path)) { if (!_dbus_string_append (config_file, path)) return FALSE; @@ -3377,8 +3377,8 @@ _dbus_get_config_file_name(DBusString *config_file, char *s) return FALSE; strcat(path,"bus\\"); strcat(path,s); - - if (_dbus_file_exists(path)) + + if (_dbus_file_exists(path)) { if (!_dbus_string_append (config_file, path)) return FALSE; @@ -3386,7 +3386,7 @@ _dbus_get_config_file_name(DBusString *config_file, char *s) } } return TRUE; -} +} /* See comment in dbus-sysdeps-unix.c */ dbus_bool_t @@ -3406,10 +3406,10 @@ _dbus_lookup_session_address (dbus_bool_t *supported, * * On UNIX the directory is ~/.dbus-keyrings while on Windows it should probably * be something else, since the dotfile convention is not normal on Windows. - * + * * @param directory string to append directory to * @param credentials credentials the directory should be for - * + * * @returns #FALSE on no memory */ dbus_bool_t @@ -3423,7 +3423,7 @@ _dbus_append_keyring_directory_for_credentials (DBusString *directory, _dbus_assert (credentials != NULL); _dbus_assert (!_dbus_credentials_are_anonymous (credentials)); - + if (!_dbus_string_init (&homedir)) return FALSE; @@ -3438,11 +3438,11 @@ _dbus_append_keyring_directory_for_credentials (DBusString *directory, { _dbus_string_append(&homedir,homepath); } - + #ifdef DBUS_ENABLE_EMBEDDED_TESTS { const char *override; - + override = _dbus_getenv ("DBUS_TEST_HOMEDIR"); if (override != NULL && *override != '\0') { @@ -3479,7 +3479,7 @@ _dbus_append_keyring_directory_for_credentials (DBusString *directory, if (!_dbus_concat_dir_and_file (&homedir, &dotdir)) goto failed; - + if (!_dbus_string_copy (&homedir, 0, directory, _dbus_string_get_length (directory))) { goto failed; @@ -3487,8 +3487,8 @@ _dbus_append_keyring_directory_for_credentials (DBusString *directory, _dbus_string_free (&homedir); return TRUE; - - failed: + + failed: _dbus_string_free (&homedir); return FALSE; } @@ -3498,7 +3498,7 @@ _dbus_append_keyring_directory_for_credentials (DBusString *directory, * @param file full path to the file * @returns #TRUE if file exists */ -dbus_bool_t +dbus_bool_t _dbus_file_exists (const char *file) { DWORD attributes = GetFileAttributesA (file); @@ -3506,7 +3506,7 @@ _dbus_file_exists (const char *file) if (attributes != INVALID_FILE_ATTRIBUTES && GetLastError() != ERROR_PATH_NOT_FOUND) return TRUE; else - return FALSE; + return FALSE; } /** diff --git a/tools/dbus-monitor.c b/tools/dbus-monitor.c index 9cec0a7..b4c6a63 100644 --- a/tools/dbus-monitor.c +++ b/tools/dbus-monitor.c @@ -58,7 +58,7 @@ monitor_filter_func (DBusConnection *connection, _dbus_get_real_time (&sec, &usec); print_message (message, FALSE, sec, usec); - + if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected")) @@ -426,7 +426,7 @@ main (int argc, char *argv[]) /* Prepend a rule (and a comma) to enable the monitor to eavesdrop. * Prepending allows the user to add eavesdrop=false at command line * in order to disable eavesdropping when needed */ - filter_len = strlen (EAVESDROPPING_RULE) + 1 + strlen (arg) + 1; + filter_len = (int) strlen (EAVESDROPPING_RULE) + 1 + (int) strlen (arg) + 1; filters = (char **) realloc (filters, numFilters * sizeof (char *)); if (filters == NULL) @@ -440,7 +440,7 @@ main (int argc, char *argv[]) } dbus_error_init (&error); - + if (address != NULL) { connection = dbus_connection_open (address, &error);