printers: Remove unnecessary checks on result of g_variant_get

This always returns a value or hits an assertion.
This commit is contained in:
Robert Ancell 2019-11-21 21:56:08 +13:00 committed by Robert Ancell
parent 815db8f404
commit 2b9815dbf8
2 changed files with 127 additions and 145 deletions

View file

@ -480,8 +480,6 @@ get_ppd_item_from_output (GVariant *output)
g_autoptr(GVariant) array = NULL; g_autoptr(GVariant) array = NULL;
g_variant_get (output, "(@a(ss))", &array); g_variant_get (output, "(@a(ss))", &array);
if (array)
{
for (j = 0; j < G_N_ELEMENTS (match_levels) && !ppd_item; j++) for (j = 0; j < G_N_ELEMENTS (match_levels) && !ppd_item; j++)
{ {
g_autoptr(GVariantIter) iter = NULL; g_autoptr(GVariantIter) iter = NULL;
@ -509,7 +507,6 @@ get_ppd_item_from_output (GVariant *output)
} }
} }
} }
}
return ppd_item; return ppd_item;
} }
@ -1007,19 +1004,15 @@ get_missing_executables_cb (GObject *source_object,
if (output) if (output)
{ {
g_autoptr(GVariant) array = NULL; g_autoptr(GVariant) array = NULL;
g_variant_get (output, "(@as)", &array);
if (array)
{
g_autoptr(GVariantIter) iter = NULL; g_autoptr(GVariantIter) iter = NULL;
const gchar *executable; const gchar *executable;
g_variant_get (output, "(@as)", &array);
g_variant_get (array, "as", &iter); g_variant_get (array, "as", &iter);
while (g_variant_iter_next (iter, "&s", &executable)) while (g_variant_iter_next (iter, "&s", &executable))
executables = g_list_append (executables, g_strdup (executable)); executables = g_list_append (executables, g_strdup (executable));
} }
}
else if (error->domain == G_DBUS_ERROR && else if (error->domain == G_DBUS_ERROR &&
(error->code == G_DBUS_ERROR_SERVICE_UNKNOWN || (error->code == G_DBUS_ERROR_SERVICE_UNKNOWN ||
error->code == G_DBUS_ERROR_UNKNOWN_METHOD)) error->code == G_DBUS_ERROR_UNKNOWN_METHOD))

View file

@ -1910,8 +1910,6 @@ get_ppd_names_async_dbus_scb (GObject *source_object,
g_variant_get (output, "(@a(ss))", g_variant_get (output, "(@a(ss))",
&array); &array);
if (array)
{
for (j = 0; j < G_N_ELEMENTS (match_levels) && n < data->count; j++) for (j = 0; j < G_N_ELEMENTS (match_levels) && n < data->count; j++)
{ {
g_autoptr(GVariantIter) iter = NULL; g_autoptr(GVariantIter) iter = NULL;
@ -1946,7 +1944,6 @@ get_ppd_names_async_dbus_scb (GObject *source_object,
} }
} }
} }
}
else else
{ {
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
@ -2124,6 +2121,7 @@ get_device_attributes_async_dbus_cb (GObject *source_object,
{ {
const gchar *ret_error; const gchar *ret_error;
g_autoptr(GVariant) devices_variant = NULL; g_autoptr(GVariant) devices_variant = NULL;
gint index = -1;
g_variant_get (output, "(&s@a{ss})", g_variant_get (output, "(&s@a{ss})",
&ret_error, &ret_error,
@ -2134,10 +2132,6 @@ get_device_attributes_async_dbus_cb (GObject *source_object,
g_warning ("cups-pk-helper: getting of attributes for printer %s failed: %s", data->printer_name, ret_error); g_warning ("cups-pk-helper: getting of attributes for printer %s failed: %s", data->printer_name, ret_error);
} }
if (devices_variant)
{
gint index = -1;
if (data->device_uri) if (data->device_uri)
{ {
g_autoptr(GVariantIter) iter = NULL; g_autoptr(GVariantIter) iter = NULL;
@ -2188,7 +2182,6 @@ get_device_attributes_async_dbus_cb (GObject *source_object,
} }
} }
} }
}
else else
{ {
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
@ -3261,6 +3254,9 @@ get_cups_devices_async_dbus_cb (GObject *source_object,
const gchar *ret_error; const gchar *ret_error;
g_autoptr(GVariant) devices_variant = NULL; g_autoptr(GVariant) devices_variant = NULL;
gboolean is_network_device; gboolean is_network_device;
g_autoptr(GVariantIter) iter = NULL;
const gchar *key, *value;
gint index = -1, max_index = -1, i;
g_variant_get (output, "(&s@a{ss})", g_variant_get (output, "(&s@a{ss})",
&ret_error, &ret_error,
@ -3271,12 +3267,6 @@ get_cups_devices_async_dbus_cb (GObject *source_object,
g_warning ("cups-pk-helper: getting of CUPS devices failed: %s", ret_error); g_warning ("cups-pk-helper: getting of CUPS devices failed: %s", ret_error);
} }
if (devices_variant)
{
g_autoptr(GVariantIter) iter = NULL;
const gchar *key, *value;
gint index = -1, max_index = -1, i;
g_variant_get (devices_variant, "a{ss}", &iter); g_variant_get (devices_variant, "a{ss}", &iter);
while (g_variant_iter_next (iter, "{&s&s}", &key, &value)) while (g_variant_iter_next (iter, "{&s&s}", &key, &value))
{ {
@ -3332,7 +3322,6 @@ get_cups_devices_async_dbus_cb (GObject *source_object,
g_free (devices); g_free (devices);
} }
} }
}
else else
{ {
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))