On Wed, Jul 18, 2012 at 09:33:58AM +0000, Cong Wang wrote:
On Fri, 13 Jul 2012 at 07:37 GMT, Jovanka Gulicoska
<jovanka.gulicoska(a)gmail.com> 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;
The style we have here is the standard libvirt format, since it becomes
clearer to use the goto when you add further code in the method.
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|