[libvirt] [libvirt-glib PATCHv4 1/7] gobject: Simplify gvir_connection_list*() implementations
Christophe Fergeau
cfergeau at redhat.com
Tue Jul 7 08:46:37 UTC 2015
On Wed, Jul 01, 2015 at 09:40:45PM +0100, Zeeshan Ali (Khattak) wrote:
> @@ -901,77 +801,31 @@ gboolean gvir_connection_fetch_storage_pools(GVirConnection *conn,
> if (g_cancellable_set_error_if_cancelled(cancellable, err))
> goto cleanup;
>
> - active = fetch_list(vconn,
> - "Storage Pools",
> - virConnectNumOfStoragePools,
> - virConnectListStoragePools,
> - cancellable,
> - &nactive,
> - &lerr);
> - if (lerr) {
> - g_propagate_error(err, lerr);
> - lerr = NULL;
> + npools = virConnectListAllStoragePools(vconn, &vpools, 0);
> + if (npools < 0) {
> + gvir_set_error(err, GVIR_CONNECTION_ERROR,
> + 0,
> + _("Failed to fetch list of pools"));
> goto cleanup;
> }
>
> if (g_cancellable_set_error_if_cancelled(cancellable, err))
> goto cleanup;
>
> - inactive = fetch_list(vconn,
> - "Storage Pools",
> - virConnectNumOfDefinedStoragePools,
> - virConnectListDefinedStoragePools,
> - cancellable,
> - &ninactive,
> - &lerr);
> - if (lerr) {
> - g_propagate_error(err, lerr);
> - lerr = NULL;
> - goto cleanup;
> - }
> -
> pools = g_hash_table_new_full(g_str_hash,
> g_str_equal,
> NULL,
> g_object_unref);
>
> - for (i = 0 ; i < nactive ; i++) {
> + for (i = 0 ; i < npools; i++) {
> if (g_cancellable_set_error_if_cancelled(cancellable, err))
> goto cleanup;
>
> - virStoragePoolPtr vpool;
> GVirStoragePool *pool;
While touching this code, you could move 'pool' declaration to the
beginning of the 'for' block.
Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150707/859640e6/attachment-0001.sig>
More information about the libvir-list
mailing list