Use DBUS_ERROR_INIT instead of dbus_error_init wherever it's clearly equivalent
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Wed, 10 Oct 2007 10:41:57 +0000 (11:41 +0100)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Thu, 11 Oct 2007 16:26:30 +0000 (17:26 +0100)
15 files changed:
dbus/dbus-address.c
dbus/dbus-auth-script.c
dbus/dbus-auth-util.c
dbus/dbus-connection.c
dbus/dbus-internals.c
dbus/dbus-keyring.c
dbus/dbus-message-util.c
dbus/dbus-server.c
dbus/dbus-sha.c
dbus/dbus-spawn-win.c
dbus/dbus-spawn.c
dbus/dbus-sysdeps-util-win.c
dbus/dbus-transport-socket.c
dbus/dbus-transport.c
dbus/dbus-userdb.c

index 0b87b8e..28e8842 100644 (file)
@@ -698,12 +698,10 @@ dbus_bool_t
 _dbus_address_test (void)
 {
   DBusAddressEntry **entries;
-  int len;  
-  DBusError error;
+  int len;
+  DBusError error = DBUS_ERROR_INIT;
   int i;
 
-  dbus_error_init (&error);
-
   i = 0;
   while (i < _DBUS_N_ELEMENTS (escape_tests))
     {
index a4102af..93d6f78 100644 (file)
@@ -244,7 +244,7 @@ dbus_bool_t
 _dbus_auth_script_run (const DBusString *filename)
 {
   DBusString file;
-  DBusError error;
+  DBusError error = DBUS_ERROR_INIT;
   DBusString line;
   dbus_bool_t retval;
   int line_no;
@@ -276,7 +276,6 @@ _dbus_auth_script_run (const DBusString *filename)
       return FALSE;
     }
 
-  dbus_error_init (&error);
   if (!_dbus_file_get_contents (&file, filename, &error))    {
       _dbus_warn ("Getting contents of %s failed: %s\n",
                   _dbus_string_get_const_data (filename), error.message);
index 4562789..e501904 100644 (file)
@@ -44,7 +44,7 @@ process_test_subdir (const DBusString          *test_base_dir,
   DBusString filename;
   DBusDirIter *dir;
   dbus_bool_t retval;
-  DBusError error;
+  DBusError error = DBUS_ERROR_INIT;
 
   retval = FALSE;
   dir = NULL;
@@ -65,7 +65,6 @@ process_test_subdir (const DBusString          *test_base_dir,
   if (!_dbus_string_init (&filename))
     _dbus_assert_not_reached ("didn't allocate filename string\n");
 
-  dbus_error_init (&error);
   dir = _dbus_directory_open (&test_directory, &error);
   if (dir == NULL)
     {
index b6ecc36..e6848c1 100644 (file)
@@ -1709,8 +1709,8 @@ _dbus_connection_open_internal (const char     *address,
 {
   DBusConnection *connection;
   DBusAddressEntry **entries;
-  DBusError tmp_error;
-  DBusError first_error;
+  DBusError tmp_error = DBUS_ERROR_INIT;
+  DBusError first_error = DBUS_ERROR_INIT;
   int len, i;
 
   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
@@ -1725,8 +1725,6 @@ _dbus_connection_open_internal (const char     *address,
   
   connection = NULL;
 
-  dbus_error_init (&tmp_error);
-  dbus_error_init (&first_error);
   for (i = 0; i < len; i++)
     {
       if (shared)
@@ -5327,15 +5325,13 @@ dbus_connection_register_object_path (DBusConnection              *connection,
 {
   char **decomposed_path;
   dbus_bool_t retval;
-  DBusError error;
+  DBusError error = DBUS_ERROR_INIT;
 
   _dbus_return_val_if_fail (connection != NULL, FALSE);
   _dbus_return_val_if_fail (path != NULL, FALSE);
   _dbus_return_val_if_fail (path[0] == '/', FALSE);
   _dbus_return_val_if_fail (vtable != NULL, FALSE);
 
-  dbus_error_init (&error);
-
   if (!_dbus_decompose_path (path, strlen (path), &decomposed_path, NULL))
     return FALSE;
 
@@ -5430,15 +5426,13 @@ dbus_connection_register_fallback (DBusConnection              *connection,
 {
   char **decomposed_path;
   dbus_bool_t retval;
-  DBusError error;
+  DBusError error = DBUS_ERROR_INIT;
 
   _dbus_return_val_if_fail (connection != NULL, FALSE);
   _dbus_return_val_if_fail (path != NULL, FALSE);
   _dbus_return_val_if_fail (path[0] == '/', FALSE);
   _dbus_return_val_if_fail (vtable != NULL, FALSE);
 
-  dbus_error_init (&error);
-
   if (!_dbus_decompose_path (path, strlen (path), &decomposed_path, NULL))
     return FALSE;
 
index fdc08d3..c99bee1 100644 (file)
@@ -668,9 +668,7 @@ _dbus_read_uuid_file (const DBusString *filename,
                       dbus_bool_t       create_if_not_found,
                       DBusError        *error)
 {
-  DBusError read_error;
-
-  dbus_error_init (&read_error);
+  DBusError read_error = DBUS_ERROR_INIT;
 
   if (_dbus_read_uuid_file_without_creating (filename, uuid, &read_error))
     return TRUE;
@@ -719,8 +717,8 @@ _dbus_get_local_machine_uuid_encoded (DBusString *uuid_str)
   _DBUS_LOCK (machine_uuid);
   if (machine_uuid_initialized_generation != _dbus_current_generation)
     {
-      DBusError error;
-      dbus_error_init (&error);
+      DBusError error = DBUS_ERROR_INIT;
+
       if (!_dbus_read_local_machine_uuid (&machine_uuid, FALSE,
                                           &error))
         {          
index 4b7182d..de6a5ea 100644 (file)
@@ -201,9 +201,8 @@ _dbus_keyring_lock (DBusKeyring *keyring)
   n_timeouts = 0;
   while (n_timeouts < MAX_LOCK_TIMEOUTS)
     {
-      DBusError error;
+      DBusError error = DBUS_ERROR_INIT;
 
-      dbus_error_init (&error);
       if (_dbus_create_file_exclusively (&keyring->filename_lock,
                                          &error))
         break;
@@ -219,13 +218,11 @@ _dbus_keyring_lock (DBusKeyring *keyring)
 
   if (n_timeouts == MAX_LOCK_TIMEOUTS)
     {
-      DBusError error;
-      
+      DBusError error = DBUS_ERROR_INIT;
+
       _dbus_verbose ("Lock file timed out %d times, assuming stale\n",
                      n_timeouts);
 
-      dbus_error_init (&error);
-
       if (!_dbus_delete_file (&keyring->filename_lock, &error))
         {
           _dbus_verbose ("Couldn't delete old lock file: %s\n",
@@ -250,8 +247,8 @@ _dbus_keyring_lock (DBusKeyring *keyring)
 static void
 _dbus_keyring_unlock (DBusKeyring *keyring)
 {
-  DBusError error;
-  dbus_error_init (&error);
+  DBusError error = DBUS_ERROR_INIT;
+
   if (!_dbus_delete_file (&keyring->filename_lock, &error))
     {
       _dbus_warn ("Failed to delete lock file: %s\n",
index f82d4f4..0fa010c 100644 (file)
@@ -276,12 +276,11 @@ dbus_internal_do_not_use_load_message_file (const DBusString    *filename,
                                             DBusString          *data)
 {
   dbus_bool_t retval;
-  DBusError error;
-  
+  DBusError error = DBUS_ERROR_INIT;
+
   retval = FALSE;
 
   _dbus_verbose ("Loading raw %s\n", _dbus_string_get_const_data (filename));
-  dbus_error_init (&error);
   if (!_dbus_file_get_contents (data, filename, &error))
     {
       _dbus_warn ("Could not load message file %s: %s\n",
@@ -450,7 +449,7 @@ process_test_subdir (const DBusString          *test_base_dir,
   DBusString filename;
   DBusDirIter *dir;
   dbus_bool_t retval;
-  DBusError error;
+  DBusError error = DBUS_ERROR_INIT;
 
   retval = FALSE;
   dir = NULL;
@@ -471,7 +470,6 @@ process_test_subdir (const DBusString          *test_base_dir,
   if (!_dbus_string_init (&filename))
     _dbus_assert_not_reached ("didn't allocate filename string\n");
 
-  dbus_error_init (&error);
   dir = _dbus_directory_open (&test_directory, &error);
   if (dir == NULL)
     {
@@ -701,7 +699,7 @@ static void
 verify_test_message (DBusMessage *message)
 {
   DBusMessageIter iter;
-  DBusError error;
+  DBusError error = DBUS_ERROR_INIT;
   dbus_int16_t our_int16;
   dbus_uint16_t our_uint16;
   dbus_int32_t our_int;
@@ -734,7 +732,6 @@ verify_test_message (DBusMessage *message)
 
   dbus_message_iter_init (message, &iter);
 
-  dbus_error_init (&error);
   if (!dbus_message_iter_get_args (&iter, &error,
                                    DBUS_TYPE_INT16, &our_int16,
                                    DBUS_TYPE_UINT16, &our_uint16,
@@ -1226,12 +1223,10 @@ _dbus_message_test (const char *test_data_dir)
       /* Marshal and demarshal the message. */
 
       DBusMessage *message2;
-      DBusError error;
+      DBusError error = DBUS_ERROR_INIT;
       char *marshalled = NULL;
       int len = 0;
 
-      dbus_error_init (&error);
-
       if (!dbus_message_marshal (message, &marshalled, &len))
         _dbus_assert_not_reached ("failed to marshal message");
 
index 755fada..f04829b 100644 (file)
@@ -543,7 +543,7 @@ dbus_server_listen (const char     *address,
   DBusServer *server;
   DBusAddressEntry **entries;
   int len, i;
-  DBusError first_connect_error;
+  DBusError first_connect_error = DBUS_ERROR_INIT;
   dbus_bool_t handled_once;
   
   _dbus_return_val_if_fail (address != NULL, NULL);
@@ -553,9 +553,8 @@ dbus_server_listen (const char     *address,
     return NULL;
 
   server = NULL;
-  dbus_error_init (&first_connect_error);
   handled_once = FALSE;
-  
+
   for (i = 0; i < len; i++)
     {
       int j;
@@ -563,9 +562,8 @@ dbus_server_listen (const char     *address,
       for (j = 0; j < (int) _DBUS_N_ELEMENTS (listen_funcs); ++j)
         {
           DBusServerListenResult result;
-          DBusError tmp_error;
-      
-          dbus_error_init (&tmp_error);
+          DBusError tmp_error = DBUS_ERROR_INIT;
+
           result = (* listen_funcs[j].func) (entries[i],
                                              &server,
                                              &tmp_error);
@@ -1167,11 +1165,10 @@ _dbus_server_test (void)
   
   for (i = 0; i < _DBUS_N_ELEMENTS (valid_addresses); i++)
     {
-      DBusError error;
+      DBusError error = DBUS_ERROR_INIT;
       char *address;
       char *id;
-      
-      dbus_error_init (&error);
+
       server = dbus_server_listen (valid_addresses[i], &error);
       if (server == NULL)
         {
index 9f1cdbb..8ec50b6 100644 (file)
@@ -745,8 +745,8 @@ process_test_data (const char *test_data_dir)
   int line_no;
   dbus_bool_t retval;
   int success_count;
-  DBusError error;
-  
+  DBusError error = DBUS_ERROR_INIT;
+
   retval = FALSE;
   
   if (!_dbus_string_init (&tests_file))
@@ -778,7 +778,6 @@ process_test_data (const char *test_data_dir)
   if (!_dbus_concat_dir_and_file (&results_file, &tmp))
     _dbus_assert_not_reached ("no memory");
 
-  dbus_error_init (&error);
   if (!_dbus_file_get_contents (&tests, &tests_file, &error))
     {
       fprintf (stderr, "could not load test data file %s: %s\n",
index 5ab8516..c2ad16b 100644 (file)
@@ -621,12 +621,8 @@ static dbus_bool_t
 check_spawn_nonexistent (void *data)
 {
   char *argv[4] = { NULL, NULL, NULL, NULL };
-  DBusBabysitter *sitter;
-  DBusError error;
-
-  sitter = NULL;
-
-  dbus_error_init (&error);
+  DBusBabysitter *sitter = NULL;
+  DBusError error = DBUS_ERROR_INIT;
 
   /*** Test launching nonexistent binary */
 
@@ -666,12 +662,8 @@ static dbus_bool_t
 check_spawn_segfault (void *data)
 {
   char *argv[4] = { NULL, NULL, NULL, NULL };
-  DBusBabysitter *sitter;
-  DBusError error;
-
-  sitter = NULL;
-
-  dbus_error_init (&error);
+  DBusBabysitter *sitter = NULL;
+  DBusError error = DBUS_ERROR_INIT;
 
   /*** Test launching segfault binary */
 
@@ -711,12 +703,8 @@ static dbus_bool_t
 check_spawn_exit (void *data)
 {
   char *argv[4] = { NULL, NULL, NULL, NULL };
-  DBusBabysitter *sitter;
-  DBusError error;
-
-  sitter = NULL;
-
-  dbus_error_init (&error);
+  DBusBabysitter *sitter = NULL;
+  DBusError error = DBUS_ERROR_INIT;
 
   /*** Test launching exit failure binary */
 
@@ -756,12 +744,8 @@ static dbus_bool_t
 check_spawn_and_kill (void *data)
 {
   char *argv[4] = { NULL, NULL, NULL, NULL };
-  DBusBabysitter *sitter;
-  DBusError error;
-
-  sitter = NULL;
-
-  dbus_error_init (&error);
+  DBusBabysitter *sitter = NULL;
+  DBusError error = DBUS_ERROR_INIT;
 
   /*** Test launching sleeping binary then killing it */
 
index 810536f..eaa9ef1 100644 (file)
@@ -366,11 +366,9 @@ read_data (DBusBabysitter *sitter,
 {
   int what;
   int got;
-  DBusError error;
+  DBusError error = DBUS_ERROR_INIT;
   ReadStatus r;
-  
-  dbus_error_init (&error);
-  
+
   r = read_ints (fd, &what, 1, &got, &error);
 
   switch (r)
@@ -1238,12 +1236,8 @@ static dbus_bool_t
 check_spawn_nonexistent (void *data)
 {
   char *argv[4] = { NULL, NULL, NULL, NULL };
-  DBusBabysitter *sitter;
-  DBusError error;
-  
-  sitter = NULL;
-  
-  dbus_error_init (&error);
+  DBusBabysitter *sitter = NULL;
+  DBusError error = DBUS_ERROR_INIT;
 
   /*** Test launching nonexistent binary */
   
@@ -1283,12 +1277,8 @@ static dbus_bool_t
 check_spawn_segfault (void *data)
 {
   char *argv[4] = { NULL, NULL, NULL, NULL };
-  DBusBabysitter *sitter;
-  DBusError error;
-  
-  sitter = NULL;
-  
-  dbus_error_init (&error);
+  DBusBabysitter *sitter = NULL;
+  DBusError error = DBUS_ERROR_INIT;
 
   /*** Test launching segfault binary */
   
@@ -1328,12 +1318,8 @@ static dbus_bool_t
 check_spawn_exit (void *data)
 {
   char *argv[4] = { NULL, NULL, NULL, NULL };
-  DBusBabysitter *sitter;
-  DBusError error;
-  
-  sitter = NULL;
-  
-  dbus_error_init (&error);
+  DBusBabysitter *sitter = NULL;
+  DBusError error = DBUS_ERROR_INIT;
 
   /*** Test launching exit failure binary */
   
@@ -1373,12 +1359,8 @@ static dbus_bool_t
 check_spawn_and_kill (void *data)
 {
   char *argv[4] = { NULL, NULL, NULL, NULL };
-  DBusBabysitter *sitter;
-  DBusError error;
-  
-  sitter = NULL;
-  
-  dbus_error_init (&error);
+  DBusBabysitter *sitter = NULL;
+  DBusError error = DBUS_ERROR_INIT;
 
   /*** Test launching sleeping binary then killing it */
 
index e4a30ba..8608ad0 100644 (file)
@@ -917,9 +917,8 @@ void
 _dbus_win_warn_win_error (const char *message,
                           int         code)
 {
-  DBusError error;
+  DBusError error = DBUS_ERROR_INIT;
 
-  dbus_error_init (&error);
   _dbus_win_set_error_from_win_error (&error, code);
   _dbus_warn ("%s: %s\n", message, error.message);
   dbus_error_free (&error);
index f6d0e9c..05e3f3a 100644 (file)
@@ -338,12 +338,11 @@ exchange_credentials (DBusTransport *transport,
                       dbus_bool_t    do_writing)
 {
   DBusTransportSocket *socket_transport = (DBusTransportSocket*) transport;
-  DBusError error;
+  DBusError error = DBUS_ERROR_INIT;
 
   _dbus_verbose ("exchange_credentials: do_reading = %d, do_writing = %d\n",
                   do_reading, do_writing);
 
-  dbus_error_init (&error);
   if (do_writing && transport->send_credentials_pending)
     {
       if (_dbus_send_credentials_socket (socket_transport->fd,
index ddd2031..313cd41 100644 (file)
@@ -354,8 +354,8 @@ _dbus_transport_open (DBusAddressEntry *entry,
   const char *expected_guid_orig;
   char *expected_guid;
   int i;
-  DBusError tmp_error;
-  
+  DBusError tmp_error = DBUS_ERROR_INIT;
+
   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
   
   transport = NULL;
@@ -368,7 +368,6 @@ _dbus_transport_open (DBusAddressEntry *entry,
       return NULL;
     }
 
-  dbus_error_init (&tmp_error);
   for (i = 0; i < (int) _DBUS_N_ELEMENTS (open_funcs); ++i)
     {
       DBusTransportOpenResult result;
index aded538..0e430b2 100644 (file)
@@ -239,15 +239,13 @@ init_system_db (void)
     
   if (system_db == NULL)
     {
-      DBusError error;
+      DBusError error = DBUS_ERROR_INIT;
       const DBusUserInfo *info;
       
       system_db = _dbus_user_database_new ();
       if (system_db == NULL)
         return FALSE;
 
-      dbus_error_init (&error);
-
       if (!_dbus_user_database_get_uid (system_db,
                                         _dbus_getuid (),
                                         &info,