Re: [spice-gtk v1] usb-device-widget: remove goto/label

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

 



On 17/04/18 04:40, Victor Toso wrote:
> 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
> 

The code as is today does not bother me, but this patch is also fine for
me. Either way, if you think it is an improvement in readability, push it ;)

Reviewed-by: Eduardo Lima (Etrunko) <etrunko@xxxxxxxxxx>

> 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);
>  }
>  
> 


-- 
Eduardo de Barros Lima (Etrunko)
Software Engineer - RedHat
etrunko@xxxxxxxxxx
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]