By using the gvir_set_error family of functions, we get handling of NULL GError ** for free, which wasn't consistently handled throughout the code base. --- libvirt-gobject/libvirt-gobject-connection.c | 84 ++++++++---------- libvirt-gobject/libvirt-gobject-domain-disk.c | 6 +- libvirt-gobject/libvirt-gobject-domain-interface.c | 7 +- libvirt-gobject/libvirt-gobject-domain-snapshot.c | 6 +- libvirt-gobject/libvirt-gobject-domain.c | 93 ++++++++----------- libvirt-gobject/libvirt-gobject-interface.c | 7 +- libvirt-gobject/libvirt-gobject-network-filter.c | 7 +- libvirt-gobject/libvirt-gobject-network.c | 7 +- libvirt-gobject/libvirt-gobject-node-device.c | 7 +- libvirt-gobject/libvirt-gobject-secret.c | 7 +- libvirt-gobject/libvirt-gobject-storage-pool.c | 54 +++++------ libvirt-gobject/libvirt-gobject-storage-vol.c | 14 ++-- libvirt-gobject/libvirt-gobject-stream.c | 14 ++-- 13 files changed, 134 insertions(+), 179 deletions(-) diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c index 9d3ab10..0f9540a 100644 --- a/libvirt-gobject/libvirt-gobject-connection.c +++ b/libvirt-gobject/libvirt-gobject-connection.c @@ -401,21 +401,19 @@ gboolean gvir_connection_open(GVirConnection *conn, g_mutex_lock(priv->lock); if (priv->conn) { - if (err) - *err = g_error_new(GVIR_CONNECTION_ERROR, - 0, - "Connection %s is already open", - priv->uri); + g_set_error(err, GVIR_CONNECTION_ERROR, + 0, + "Connection %s is already open", + priv->uri); g_mutex_unlock(priv->lock); return FALSE; } if (!(priv->conn = virConnectOpen(priv->uri))) { - if (err) - *err = gvir_error_new(GVIR_CONNECTION_ERROR, - 0, - "Unable to open %s", - priv->uri); + gvir_set_error(err, GVIR_CONNECTION_ERROR, + 0, + "Unable to open %s", + priv->uri); g_mutex_unlock(priv->lock); return FALSE; } @@ -423,8 +421,7 @@ gboolean gvir_connection_open(GVirConnection *conn, if (!priv->uri) { char *uri = virConnectGetURI(priv->conn); if (!uri) { - if (err) - *err = gvir_error_new(GVIR_CONNECTION_ERROR, + gvir_set_error(err, GVIR_CONNECTION_ERROR, 0, "%s", "Unable to get connection URI"); virConnectClose(priv->conn); @@ -570,10 +567,9 @@ static gchar ** fetch_list(virConnectPtr vconn, gint i; if ((n = count_func(vconn)) < 0) { - if (err) - *err = gvir_error_new(GVIR_CONNECTION_ERROR, - 0, - "Unable to count %s", name); + gvir_set_error(err, GVIR_CONNECTION_ERROR, + 0, + "Unable to count %s", name); goto error; } @@ -583,10 +579,9 @@ static gchar ** fetch_list(virConnectPtr vconn, lst = g_new(gchar *, n); if ((n = list_func(vconn, lst, n)) < 0) { - if (err) - *err = gvir_error_new(GVIR_CONNECTION_ERROR, - 0, - "Unable to list %s %d", name, n); + gvir_set_error(err, GVIR_CONNECTION_ERROR, + 0, + "Unable to list %s %d", name, n); goto error; } } @@ -623,10 +618,9 @@ gboolean gvir_connection_fetch_domains(GVirConnection *conn, g_mutex_lock(priv->lock); if (!priv->conn) { - if (err) - *err = g_error_new(GVIR_CONNECTION_ERROR, - 0, - "Connection is not open"); + g_set_error(err, GVIR_CONNECTION_ERROR, + 0, + "Connection is not open"); g_mutex_unlock(priv->lock); goto cleanup; } @@ -639,10 +633,9 @@ gboolean gvir_connection_fetch_domains(GVirConnection *conn, goto cleanup; if ((nactive = virConnectNumOfDomains(vconn)) < 0) { - if (err) - *err = gvir_error_new(GVIR_CONNECTION_ERROR, - 0, - "Unable to count domains"); + gvir_set_error(err, GVIR_CONNECTION_ERROR, + 0, + "Unable to count domains"); goto cleanup; } if (nactive) { @@ -651,10 +644,9 @@ gboolean gvir_connection_fetch_domains(GVirConnection *conn, active = g_new(gint, nactive); if ((nactive = virConnectListDomains(vconn, active, nactive)) < 0) { - if (err) - *err = gvir_error_new(GVIR_CONNECTION_ERROR, - 0, - "Unable to list domains"); + gvir_set_error(err, GVIR_CONNECTION_ERROR, + 0, + "Unable to list domains"); goto cleanup; } } @@ -755,10 +747,9 @@ gboolean gvir_connection_fetch_storage_pools(GVirConnection *conn, g_mutex_lock(priv->lock); if (!priv->conn) { - if (err) - *err = g_error_new(GVIR_CONNECTION_ERROR, - 0, - "Connection is not open"); + g_set_error(err, GVIR_CONNECTION_ERROR, + 0, + "Connection is not open"); g_mutex_unlock(priv->lock); goto cleanup; } @@ -1238,10 +1229,9 @@ GVirDomain *gvir_connection_create_domain(GVirConnection *conn, handle = virDomainDefineXML(priv->conn, xml); g_free(xml); if (!handle) { - if (err) - *err = gvir_error_new_literal(GVIR_CONNECTION_ERROR, - 0, - "Failed to create domain"); + gvir_set_error_literal(err, GVIR_CONNECTION_ERROR, + 0, + "Failed to create domain"); return NULL; } @@ -1286,10 +1276,9 @@ GVirDomain *gvir_connection_start_domain(GVirConnection *conn, handle = virDomainCreateXML(priv->conn, xml, flags); g_free(xml); if (!handle) { - if (err) - *err = gvir_error_new_literal(GVIR_CONNECTION_ERROR, - 0, - "Failed to create domain"); + gvir_set_error_literal(err, GVIR_CONNECTION_ERROR, + 0, + "Failed to create domain"); return NULL; } @@ -1331,10 +1320,9 @@ GVirStoragePool *gvir_connection_create_storage_pool g_return_val_if_fail(xml != NULL, NULL); if (!(handle = virStoragePoolDefineXML(priv->conn, xml, flags))) { - if (err) - *err = gvir_error_new_literal(GVIR_CONNECTION_ERROR, - flags, - "Failed to create storage pool"); + gvir_set_error_literal(err, GVIR_CONNECTION_ERROR, + flags, + "Failed to create storage pool"); return NULL; } diff --git a/libvirt-gobject/libvirt-gobject-domain-disk.c b/libvirt-gobject/libvirt-gobject-domain-disk.c index ab9b29f..919b27e 100644 --- a/libvirt-gobject/libvirt-gobject-domain-disk.c +++ b/libvirt-gobject/libvirt-gobject-domain-disk.c @@ -175,10 +175,8 @@ GVirDomainDiskStats *gvir_domain_disk_get_stats(GVirDomainDisk *self, GError **e handle = gvir_domain_device_get_domain_handle(GVIR_DOMAIN_DEVICE(self)); if (virDomainBlockStats(handle, priv->path, &stats, sizeof (stats)) < 0) { - if (err) - *err = gvir_error_new_literal(GVIR_DOMAIN_DISK_ERROR, - 0, - "Unable to get domain disk stats"); + gvir_set_error_literal(err, GVIR_DOMAIN_DISK_ERROR, 0, + "Unable to get domain disk stats"); goto end; } diff --git a/libvirt-gobject/libvirt-gobject-domain-interface.c b/libvirt-gobject/libvirt-gobject-domain-interface.c index 223a663..0917e03 100644 --- a/libvirt-gobject/libvirt-gobject-domain-interface.c +++ b/libvirt-gobject/libvirt-gobject-domain-interface.c @@ -175,10 +175,9 @@ GVirDomainInterfaceStats *gvir_domain_interface_get_stats(GVirDomainInterface *s handle = gvir_domain_device_get_domain_handle(GVIR_DOMAIN_DEVICE(self)); if (virDomainInterfaceStats(handle, priv->path, &stats, sizeof (stats)) < 0) { - if (err) - *err = gvir_error_new_literal(GVIR_DOMAIN_INTERFACE_ERROR, - 0, - "Unable to get domain interface stats"); + gvir_set_error_literal(err, GVIR_DOMAIN_INTERFACE_ERROR, + 0, + "Unable to get domain interface stats"); goto end; } diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.c b/libvirt-gobject/libvirt-gobject-domain-snapshot.c index 36dd15b..e68321d 100644 --- a/libvirt-gobject/libvirt-gobject-domain-snapshot.c +++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.c @@ -196,9 +196,9 @@ GVirConfigDomainSnapshot *gvir_domain_snapshot_get_config gchar *xml; if (!(xml = virDomainSnapshotGetXMLDesc(priv->handle, flags))) { - *err = gvir_error_new_literal(GVIR_DOMAIN_SNAPSHOT_ERROR, - 0, - "Unable to get domain_snapshot XML config"); + gvir_set_error_literal(err, GVIR_DOMAIN_SNAPSHOT_ERROR, + 0, + "Unable to get domain_snapshot XML config"); return NULL; } diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c index 56694a8..b4e8ef4 100644 --- a/libvirt-gobject/libvirt-gobject-domain.c +++ b/libvirt-gobject/libvirt-gobject-domain.c @@ -279,10 +279,9 @@ gint gvir_domain_get_id(GVirDomain *dom, gint ret; if ((ret = virDomainGetID(priv->handle)) < 0) { - if (err) - *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR, - 0, - "Unable to get ID for domain"); + gvir_set_error_literal(err, GVIR_DOMAIN_ERROR, + 0, + "Unable to get ID for domain"); } return ret; } @@ -305,10 +304,9 @@ gboolean gvir_domain_start(GVirDomain *dom, else ret = virDomainCreate(priv->handle); if (ret < 0) { - if (err) - *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR, - 0, - "Unable to start domain"); + gvir_set_error_literal(err, GVIR_DOMAIN_ERROR, + 0, + "Unable to start domain"); return FALSE; } @@ -327,10 +325,9 @@ gboolean gvir_domain_resume(GVirDomain *dom, GVirDomainPrivate *priv = dom->priv; if (virDomainResume(priv->handle) < 0) { - if (err) - *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR, - 0, - "Unable to resume domain"); + gvir_set_error_literal(err, GVIR_DOMAIN_ERROR, + 0, + "Unable to resume domain"); return FALSE; } @@ -354,10 +351,9 @@ gboolean gvir_domain_stop(GVirDomain *dom, else ret = virDomainDestroy(priv->handle); if (ret < 0) { - if (err) - *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR, - 0, - "Unable to stop domain"); + gvir_set_error_literal(err, GVIR_DOMAIN_ERROR, + 0, + "Unable to stop domain"); return FALSE; } @@ -381,10 +377,9 @@ gboolean gvir_domain_delete(GVirDomain *dom, else ret = virDomainUndefine(priv->handle); if (ret < 0) { - if (err) - *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR, - 0, - "Unable to delete domain"); + gvir_set_error_literal(err, GVIR_DOMAIN_ERROR, + 0, + "Unable to delete domain"); return FALSE; } @@ -403,10 +398,9 @@ gboolean gvir_domain_shutdown(GVirDomain *dom, GVirDomainPrivate *priv = dom->priv; if (virDomainShutdown(priv->handle) < 0) { - if (err) - *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR, - 0, - "Unable to shutdown domain"); + gvir_set_error_literal(err, GVIR_DOMAIN_ERROR, + 0, + "Unable to shutdown domain"); return FALSE; } @@ -425,10 +419,9 @@ gboolean gvir_domain_reboot(GVirDomain *dom, GVirDomainPrivate *priv = dom->priv; if (virDomainReboot(priv->handle, flags) < 0) { - if (err) - *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR, - 0, - "Unable to reboot domain"); + gvir_set_error_literal(err, GVIR_DOMAIN_ERROR, + 0, + "Unable to reboot domain"); return FALSE; } @@ -449,10 +442,9 @@ GVirConfigDomain *gvir_domain_get_config(GVirDomain *dom, gchar *xml; if (!(xml = virDomainGetXMLDesc(priv->handle, flags))) { - if (err) - *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR, - 0, - "Unable to get domain XML config"); + gvir_set_error_literal(err, GVIR_DOMAIN_ERROR, + 0, + "Unable to get domain XML config"); return NULL; } @@ -496,10 +488,9 @@ gboolean gvir_domain_set_config(GVirDomain *domain, g_return_val_if_fail(xml != NULL, FALSE); if ((conn = virDomainGetConnect(priv->handle)) == NULL) { - if (err != NULL) - *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR, - 0, - "Failed to get domain connection"); + gvir_set_error_literal(err, GVIR_DOMAIN_ERROR, + 0, + "Failed to get domain connection"); g_free (xml); return FALSE; @@ -509,11 +500,9 @@ gboolean gvir_domain_set_config(GVirDomain *domain, g_free (xml); if (handle == NULL) { - if (err != NULL) - *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR, - 0, - "Failed to set " - "domain configuration"); + gvir_set_error_literal(err, GVIR_DOMAIN_ERROR, + 0, + "Failed to set domain configuration"); return FALSE; } @@ -521,11 +510,9 @@ gboolean gvir_domain_set_config(GVirDomain *domain, virDomainFree(handle); if (g_strcmp0 (uuid, priv->uuid) != 0) { - if (err != NULL) - *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR, - 0, - "Failed to set " - "domain configuration"); + gvir_set_error_literal(err, GVIR_DOMAIN_ERROR, + 0, + "Failed to set domain configuration"); return FALSE; } @@ -546,10 +533,9 @@ GVirDomainInfo *gvir_domain_get_info(GVirDomain *dom, GVirDomainInfo *ret; if (virDomainGetInfo(priv->handle, &info) < 0) { - if (err) - *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR, - 0, - "Unable to get domain info"); + gvir_set_error_literal(err, GVIR_DOMAIN_ERROR, + 0, + "Unable to get domain info"); return NULL; } @@ -591,10 +577,9 @@ gchar *gvir_domain_screenshot(GVirDomain *dom, st, monitor_id, flags))) { - if (err) - *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR, - 0, - "Unable to take a screenshot"); + gvir_set_error_literal(err, GVIR_DOMAIN_ERROR, + 0, + "Unable to take a screenshot"); goto end; } end: diff --git a/libvirt-gobject/libvirt-gobject-interface.c b/libvirt-gobject/libvirt-gobject-interface.c index 1413abf..7e6e9b0 100644 --- a/libvirt-gobject/libvirt-gobject-interface.c +++ b/libvirt-gobject/libvirt-gobject-interface.c @@ -185,10 +185,9 @@ GVirConfigInterface *gvir_interface_get_config(GVirInterface *iface, gchar *xml; if (!(xml = virInterfaceGetXMLDesc(priv->handle, flags))) { - if (err) - *err = gvir_error_new_literal(GVIR_INTERFACE_ERROR, - 0, - "Unable to get interface XML config"); + gvir_set_error_literal(err, GVIR_INTERFACE_ERROR, + 0, + "Unable to get interface XML config"); return NULL; } diff --git a/libvirt-gobject/libvirt-gobject-network-filter.c b/libvirt-gobject/libvirt-gobject-network-filter.c index 2ac8236..f0fd024 100644 --- a/libvirt-gobject/libvirt-gobject-network-filter.c +++ b/libvirt-gobject/libvirt-gobject-network-filter.c @@ -211,10 +211,9 @@ GVirConfigNetworkFilter *gvir_network_filter_get_config gchar *xml; if (!(xml = virNWFilterGetXMLDesc(priv->handle, flags))) { - if (err) - *err = gvir_error_new_literal(GVIR_NETWORK_FILTER_ERROR, - 0, - "Unable to get network_filter XML config"); + gvir_set_error_literal(err, GVIR_NETWORK_FILTER_ERROR, + 0, + "Unable to get network_filter XML config"); return NULL; } diff --git a/libvirt-gobject/libvirt-gobject-network.c b/libvirt-gobject/libvirt-gobject-network.c index 5f40a77..847c236 100644 --- a/libvirt-gobject/libvirt-gobject-network.c +++ b/libvirt-gobject/libvirt-gobject-network.c @@ -207,10 +207,9 @@ GVirConfigNetwork *gvir_network_get_config(GVirNetwork *network, gchar *xml; if (!(xml = virNetworkGetXMLDesc(priv->handle, flags))) { - if (err) - *err = gvir_error_new_literal(GVIR_NETWORK_ERROR, - 0, - "Unable to get network XML config"); + gvir_set_error_literal(err, GVIR_NETWORK_ERROR, + 0, + "Unable to get network XML config"); return NULL; } diff --git a/libvirt-gobject/libvirt-gobject-node-device.c b/libvirt-gobject/libvirt-gobject-node-device.c index e21d1db..59fe84b 100644 --- a/libvirt-gobject/libvirt-gobject-node-device.c +++ b/libvirt-gobject/libvirt-gobject-node-device.c @@ -186,10 +186,9 @@ GVirConfigNodeDevice *gvir_node_device_get_config(GVirNodeDevice *device, gchar *xml; if (!(xml = virNodeDeviceGetXMLDesc(priv->handle, flags))) { - if (err) - *err = gvir_error_new_literal(GVIR_NODE_DEVICE_ERROR, - 0, - "Unable to get node_device XML config"); + gvir_set_error_literal(err, GVIR_NODE_DEVICE_ERROR, + 0, + "Unable to get node_device XML config"); return NULL; } diff --git a/libvirt-gobject/libvirt-gobject-secret.c b/libvirt-gobject/libvirt-gobject-secret.c index 7521b73..0c81921 100644 --- a/libvirt-gobject/libvirt-gobject-secret.c +++ b/libvirt-gobject/libvirt-gobject-secret.c @@ -197,10 +197,9 @@ GVirConfigSecret *gvir_secret_get_config(GVirSecret *secret, gchar *xml; if (!(xml = virSecretGetXMLDesc(priv->handle, flags))) { - if (err) - *err = gvir_error_new_literal(GVIR_SECRET_ERROR, - 0, - "Unable to get secret XML config"); + gvir_set_error_literal(err, GVIR_SECRET_ERROR, + 0, + "Unable to get secret XML config"); return NULL; } diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c index e267dff..8d7963f 100644 --- a/libvirt-gobject/libvirt-gobject-storage-pool.c +++ b/libvirt-gobject/libvirt-gobject-storage-pool.c @@ -239,10 +239,9 @@ GVirConfigStoragePool *gvir_storage_pool_get_config(GVirStoragePool *pool, gchar *xml; if (!(xml = virStoragePoolGetXMLDesc(priv->handle, flags))) { - if (err) - *err = gvir_error_new_literal(GVIR_STORAGE_POOL_ERROR, - 0, - "Unable to get storage_pool XML config"); + gvir_set_error_literal(err, GVIR_STORAGE_POOL_ERROR, + 0, + "Unable to get storage_pool XML config"); return NULL; } @@ -265,10 +264,9 @@ GVirStoragePoolInfo *gvir_storage_pool_get_info(GVirStoragePool *pool, GVirStoragePoolInfo *ret; if (virStoragePoolGetInfo(priv->handle, &info) < 0) { - if (err) - *err = gvir_error_new_literal(GVIR_STORAGE_POOL_ERROR, - 0, - "Unable to get storage pool info"); + gvir_set_error_literal(err, GVIR_STORAGE_POOL_ERROR, + 0, + "Unable to get storage pool info"); return NULL; } @@ -297,9 +295,9 @@ static gchar ** fetch_list(virStoragePoolPtr vpool, gint i; if ((n = count_func(vpool)) < 0) { - *err = gvir_error_new(GVIR_STORAGE_POOL_ERROR, - 0, - "Unable to count %s", name); + gvir_set_error(err, GVIR_STORAGE_POOL_ERROR, + 0, + "Unable to count %s", name); goto error; } @@ -309,9 +307,9 @@ static gchar ** fetch_list(virStoragePoolPtr vpool, lst = g_new(gchar *, n); if ((n = list_func(vpool, lst, n)) < 0) { - *err = gvir_error_new(GVIR_STORAGE_POOL_ERROR, - 0, - "Unable to list %s %d", name, n); + gvir_set_error(err, GVIR_STORAGE_POOL_ERROR, + 0, + "Unable to list %s %d", name, n); goto error; } } @@ -347,10 +345,9 @@ gboolean gvir_storage_pool_refresh(GVirStoragePool *pool, vpool = priv->handle; if (virStoragePoolRefresh(vpool, 0) < 0) { - if (err) - *err = gvir_error_new_literal(GVIR_STORAGE_POOL_ERROR, - 0, - "Unable to refresh storage pool"); + gvir_set_error_literal(err, GVIR_STORAGE_POOL_ERROR, + 0, + "Unable to refresh storage pool"); goto cleanup; } @@ -539,10 +536,9 @@ GVirStorageVol *gvir_storage_pool_create_volume g_return_val_if_fail(xml != NULL, NULL); if (!(handle = virStorageVolCreateXML(priv->handle, xml, 0))) { - if (err) - *err = gvir_error_new_literal(GVIR_STORAGE_POOL_ERROR, - 0, - "Failed to create volume"); + gvir_set_error_literal(err, GVIR_STORAGE_POOL_ERROR, + 0, + "Failed to create volume"); return NULL; } @@ -574,10 +570,9 @@ gboolean gvir_storage_pool_build (GVirStoragePool *pool, GError **err) { if (virStoragePoolBuild(pool->priv->handle, flags)) { - if (err) - *err = gvir_error_new_literal(GVIR_STORAGE_POOL_ERROR, - 0, - "Failed to build storage pool"); + gvir_set_error_literal(err, GVIR_STORAGE_POOL_ERROR, + 0, + "Failed to build storage pool"); return FALSE; } @@ -679,10 +674,9 @@ gboolean gvir_storage_pool_start (GVirStoragePool *pool, GError **err) { if (virStoragePoolCreate(pool->priv->handle, flags)) { - if (err) - *err = gvir_error_new_literal(GVIR_STORAGE_POOL_ERROR, - 0, - "Failed to start storage pool"); + gvir_set_error_literal(err, GVIR_STORAGE_POOL_ERROR, + 0, + "Failed to start storage pool"); return FALSE; } diff --git a/libvirt-gobject/libvirt-gobject-storage-vol.c b/libvirt-gobject/libvirt-gobject-storage-vol.c index 15ae404..dc5fb13 100644 --- a/libvirt-gobject/libvirt-gobject-storage-vol.c +++ b/libvirt-gobject/libvirt-gobject-storage-vol.c @@ -212,10 +212,9 @@ GVirConfigStorageVol *gvir_storage_vol_get_config(GVirStorageVol *vol, gchar *xml; if (!(xml = virStorageVolGetXMLDesc(priv->handle, flags))) { - if (err) - *err = gvir_error_new_literal(GVIR_STORAGE_VOL_ERROR, - 0, - "Unable to get storage_vol XML config"); + gvir_set_error_literal(err, GVIR_STORAGE_VOL_ERROR, + 0, + "Unable to get storage_vol XML config"); return NULL; } @@ -238,10 +237,9 @@ GVirStorageVolInfo *gvir_storage_vol_get_info(GVirStorageVol *vol, GVirStorageVolInfo *ret; if (virStorageVolGetInfo(priv->handle, &info) < 0) { - if (err) - *err = gvir_error_new_literal(GVIR_STORAGE_VOL_ERROR, - 0, - "Unable to get storage vol info"); + gvir_set_error_literal(err, GVIR_STORAGE_VOL_ERROR, + 0, + "Unable to get storage vol info"); return NULL; } diff --git a/libvirt-gobject/libvirt-gobject-stream.c b/libvirt-gobject/libvirt-gobject-stream.c index 7baf515..c1ae765 100644 --- a/libvirt-gobject/libvirt-gobject-stream.c +++ b/libvirt-gobject/libvirt-gobject-stream.c @@ -372,10 +372,9 @@ gvir_stream_receive_all(GVirStream *self, r = virStreamRecvAll(self->priv->handle, stream_sink, &helper); if (r < 0) { - if (err != NULL) - *err = gvir_error_new_literal(GVIR_STREAM_ERROR, - 0, - "Unable to perform RecvAll"); + gvir_set_error_literal(err, GVIR_STREAM_ERROR, + 0, + "Unable to perform RecvAll"); } return r; @@ -476,10 +475,9 @@ gvir_stream_send_all(GVirStream *self, r = virStreamSendAll(self->priv->handle, stream_source, &helper); if (r < 0) { - if (err != NULL) - *err = gvir_error_new_literal(GVIR_STREAM_ERROR, - 0, - "Unable to perform SendAll"); + gvir_set_error_literal(err, GVIR_STREAM_ERROR, + 0, + "Unable to perform SendAll"); } return r; -- 1.7.7.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list