From: Victor Toso <me@xxxxxxxxxxxxxx> The 'end' label is used only once and can be replaced by moving the code into the existing 'if (!devices)'. For convenience this patch also: * Explicit check against NULL * Added curly brackets to the moved 'for' * Moved variable 'i' to inner scope Signed-off-by: Victor Toso <victortoso@xxxxxxxxxx> --- src/usb-device-widget.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/usb-device-widget.c b/src/usb-device-widget.c index a3c0910..6dd3617 100644 --- a/src/usb-device-widget.c +++ b/src/usb-device-widget.c @@ -187,7 +187,6 @@ static void spice_usb_device_widget_constructed(GObject *gobject) GPtrArray *devices = NULL; GError *err = NULL; gchar *str; - int i; self = SPICE_USB_DEVICE_WIDGET(gobject); priv = self->priv; @@ -218,15 +217,15 @@ static void spice_usb_device_widget_constructed(GObject *gobject) G_CALLBACK(device_error_cb), self); devices = spice_usb_device_manager_get_devices(priv->manager); - if (!devices) - goto end; - - for (i = 0; i < devices->len; i++) - device_added_cb(NULL, g_ptr_array_index(devices, i), self); + if (devices != NULL) { + int i; + for (i = 0; i < devices->len; i++) { + device_added_cb(NULL, g_ptr_array_index(devices, i), self); + } - g_ptr_array_unref(devices); + g_ptr_array_unref(devices); + } -end: spice_usb_device_widget_update_status(self); } -- 2.16.2 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel