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;