[Spice-commits] src/usb-device-widget.c
Frediano Ziglio
fziglio at kemper.freedesktop.org
Fri Apr 20 17:51:57 UTC 2018
src/usb-device-widget.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
New commits:
commit a15deea3561f8382b2a16e8401ef8fb27408b4be
Author: Victor Toso <me at victortoso.com>
Date: Tue Apr 17 09:40:59 2018 +0200
usb-device-widget: remove goto/label
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 at redhat.com>
Reviewed-by: Eduardo Lima (Etrunko) <etrunko at redhat.com>
Acked-by: Frediano Ziglio <fziglio at redhat.com>
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);
}
More information about the Spice-commits
mailing list