[glib/th/gdbus-slice-alloc: 2/11] gdbus: simplify error handling in g_dbus_connection_send_message_unlocked()




commit d77b8b5c0f6f9af1826da55b24d97cab52aa9f03
Author: Thomas Haller <thaller redhat com>
Date:   Sun Mar 28 09:08:27 2021 +0200

    gdbus: simplify error handling in g_dbus_connection_send_message_unlocked()
    
    "goto out" is a fine patter, especially when we are not using
    cleanup attribute.
    
    But in this case it was just unnecessary.

 gio/gdbusconnection.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)
---
diff --git a/gio/gdbusconnection.c b/gio/gdbusconnection.c
index bb1c735b9..d6bdcf2c3 100644
--- a/gio/gdbusconnection.c
+++ b/gio/gdbusconnection.c
@@ -1610,7 +1610,6 @@ g_dbus_connection_send_message_unlocked (GDBusConnection   *connection,
   guchar *blob;
   gsize blob_size;
   guint32 serial_to_use;
-  gboolean ret;
 
   CONNECTION_ENSURE_LOCK (connection);
 
@@ -1619,9 +1618,6 @@ g_dbus_connection_send_message_unlocked (GDBusConnection   *connection,
 
   /* TODO: check all necessary headers are present */
 
-  ret = FALSE;
-  blob = NULL;
-
   if (out_serial != NULL)
     *out_serial = 0;
 
@@ -1633,14 +1629,14 @@ g_dbus_connection_send_message_unlocked (GDBusConnection   *connection,
   if (!check_unclosed (connection,
                        (flags & SEND_MESSAGE_FLAGS_INITIALIZING) ? MAY_BE_UNINITIALIZED : 0,
                        error))
-    goto out;
+    return FALSE;
 
   blob = g_dbus_message_to_blob (message,
                                  &blob_size,
                                  connection->capabilities,
                                  error);
   if (blob == NULL)
-    goto out;
+    return FALSE;
 
   if (flags & G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL)
     serial_to_use = g_dbus_message_get_serial (message);
@@ -1686,18 +1682,13 @@ g_dbus_connection_send_message_unlocked (GDBusConnection   *connection,
     g_dbus_message_set_serial (message, serial_to_use);
 
   g_dbus_message_lock (message);
+
   _g_dbus_worker_send_message (connection->worker,
                                message,
                                (gchar*) blob,
                                blob_size);
-  blob = NULL; /* since _g_dbus_worker_send_message() steals the blob */
-
-  ret = TRUE;
 
- out:
-  g_free (blob);
-
-  return ret;
+  return TRUE;
 }
 
 /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]