Re: [glib PATCH V2] Add bindings for virStorageDownload() and virStorageUpload()

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

 



On Fri, 13 Jul 2012 at 07:37 GMT, Jovanka Gulicoska <jovanka.gulicoska@xxxxxxxxx> wrote:
> +gboolean gvir_storage_vol_download(GVirStorageVol *vol,
> +                                   GVirStream *stream,
> +                                   unsigned long long offset,
> +                                   unsigned long long length,
> +                                   guint flags,
> +                                   GError **err)
> +{
> +    virStreamPtr st = NULL;
> +    gboolean ret = FALSE;
> +
> +    g_object_get(stream, "handle", &st, NULL);
> +
> +    g_return_val_if_fail(GVIR_IS_STORAGE_VOL(vol), FALSE);
> +    g_return_val_if_fail(GVIR_IS_STREAM(stream), FALSE);
> +    g_return_val_if_fail(err == NULL || *err == NULL, FALSE);
> +
> +    if (virStorageVolDownload(vol->priv->handle, st, offset, length, 0) < 0) {
> +        gvir_set_error_literal(err,
> +                               GVIR_STORAGE_VOL_ERROR,
> +                               0,
> +                               "Unable to downlaod volume storage");
> +
> +        goto cleanup;
> +    }
> +
> +    ret = TRUE;
> +cleanup:
> +    if (st != NULL)
> +        virStreamFree(st);
> +    return ret;
> +}


That 'goto' is not necessary, you can refactor the code to eliminate it,
something like below:

      if (.... < 0)
          gvir_set_error_literal(...);
      else
          ret = TRUE;

      if (st != NULL)
          virStreamFree(st);
      return ret;      


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]