[gnome-control-center] printers: Remove use of goto



commit 0d913f7283236086e041d87e244d5f803f3d8bde
Author: Robert Ancell <robert ancell canonical com>
Date:   Fri Feb 12 14:45:23 2021 +1300

    printers: Remove use of goto

 panels/printers/pp-utils.c | 89 +++++++++++++++++++++++-----------------------
 1 file changed, 45 insertions(+), 44 deletions(-)
---
diff --git a/panels/printers/pp-utils.c b/panels/printers/pp-utils.c
index 5f95f8f32..aed1bb89d 100644
--- a/panels/printers/pp-utils.c
+++ b/panels/printers/pp-utils.c
@@ -1502,14 +1502,16 @@ printer_set_ppd_async (const gchar  *printer_name,
   if (printer_name == NULL ||
       printer_name[0] == '\0')
     {
-      goto out;
+      callback (printer_name, FALSE, user_data);
+      return;
     }
 
   bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
   if (!bus)
     {
       g_warning ("Failed to get system bus: %s", error->message);
-      goto out;
+      callback (printer_name, FALSE, user_data);
+      return;
     }
 
   g_dbus_connection_call (bus,
@@ -1529,11 +1531,6 @@ printer_set_ppd_async (const gchar  *printer_name,
                           cancellable,
                           printer_set_ppd_async_dbus_cb,
                           psp_data_new (printer_name, NULL, cancellable, callback, user_data));
-
-  return;
-
-out:
-  callback (printer_name, FALSE, user_data);
 }
 
 static void
@@ -1553,14 +1550,16 @@ printer_set_ppd_file_async_scb (GObject      *source_object,
   if (!success)
     {
       g_warning ("%s", error->message);
-      goto out;
+      data->callback (data->printer_name, FALSE, data->user_data);
+      return;
     }
 
   bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
   if (!bus)
     {
       g_warning ("Failed to get system bus: %s", error->message);
-      goto out;
+      data->callback (data->printer_name, FALSE, data->user_data);
+      return;
     }
 
   g_dbus_connection_call (bus,
@@ -1581,11 +1580,6 @@ printer_set_ppd_file_async_scb (GObject      *source_object,
                           printer_set_ppd_async_dbus_cb,
                           data);
    g_steal_pointer (&data);
-
-  return;
-
-out:
-  data->callback (data->printer_name, FALSE, data->user_data);
 }
 
 /*
@@ -1606,7 +1600,8 @@ printer_set_ppd_file_async (const gchar  *printer_name,
   if (printer_name == NULL ||
       printer_name[0] == '\0')
     {
-      goto out;
+      callback (printer_name, FALSE, user_data);
+      return;
     }
 
   /*
@@ -1625,15 +1620,8 @@ printer_set_ppd_file_async (const gchar  *printer_name,
                      NULL,
                      printer_set_ppd_file_async_scb,
                      psp_data_new (printer_name, g_file_get_path (destination_ppd_file), cancellable, 
callback, user_data));
-
-  return;
-
-out:
-  callback (printer_name, FALSE, user_data);
 }
 
-
-
 typedef void (*GPACallback) (gchar    **attribute_values,
                              gpointer   user_data);
 
@@ -1863,7 +1851,11 @@ get_ppd_names_async_cb (gchar    **attribute_values,
       g_free (data->result);
       data->result = NULL;
 
-      goto out;
+      data->callback (NULL,
+                      data->printer_name,
+                      TRUE,
+                      data->user_data);
+      return;
     }
 
   if (attribute_values)
@@ -1874,10 +1866,9 @@ get_ppd_names_async_cb (gchar    **attribute_values,
       g_free (attribute_values);
     }
 
-out:
   data->callback (data->result,
                   data->printer_name,
-                  g_cancellable_is_cancelled (data->cancellable),
+                  FALSE,
                   data->user_data);
 }
 
@@ -2001,16 +1992,32 @@ get_device_attributes_cb (gchar    *device_id,
   g_autoptr(GPNData) data = user_data;
 
   if (g_cancellable_is_cancelled (data->cancellable))
-    goto out;
+    {
+      data->callback (NULL,
+                      data->printer_name,
+                      TRUE,
+                      data->user_data);
+      return;
+    }
 
   if (!device_id || !device_make_and_model || !device_uri)
-    goto out;
+    {
+      data->callback (NULL,
+                      data->printer_name,
+                      FALSE,
+                      data->user_data);
+      return;
+    }
 
   bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
   if (!bus)
     {
       g_warning ("Failed to get system bus: %s", error->message);
-      goto out;
+      data->callback (NULL,
+                      data->printer_name,
+                      FALSE,
+                      data->user_data);
+      return;
     }
 
   g_dbus_connection_call (bus,
@@ -2029,14 +2036,6 @@ get_device_attributes_cb (gchar    *device_id,
                           get_ppd_names_async_dbus_scb,
                           data);
   g_steal_pointer (&data);
-
-  return;
-
-out:
-  data->callback (NULL,
-                  data->printer_name,
-                  g_cancellable_is_cancelled (data->cancellable),
-                  data->user_data);
 }
 
 /*
@@ -2273,16 +2272,23 @@ get_device_attributes_async_scb (GHashTable *result,
     }
 
   if (g_cancellable_is_cancelled (data->cancellable))
-    goto out;
+    {
+      data->callback (NULL, NULL, NULL, data->user_data);
+      return;
+    }
 
   if (!data->device_uri)
-    goto out;
+    {
+      data->callback (NULL, NULL, NULL, data->user_data);
+      return;
+    }
 
   bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
   if (!bus)
     {
       g_warning ("Failed to get system bus: %s", error->message);
-      goto out;
+      data->callback (NULL, NULL, NULL, data->user_data);
+      return;
     }
 
   data->backend_list = create_backends_list ();
@@ -2311,11 +2317,6 @@ get_device_attributes_async_scb (GHashTable *result,
                           get_device_attributes_async_dbus_cb,
                           data);
    g_steal_pointer (&data);
-
-  return;
-
-out:
-  data->callback (NULL, NULL, NULL, data->user_data);
 }
 
 /*


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