gvir_storage_vol_get_name currently call g_error when an error occurs.
Since g_error trigger a coredump, calling it in a library is harmful.
Replace this with proper GError error reporting.
---
libvirt-gobject/libvirt-gobject-storage-vol.c | 7 +++++--
libvirt-gobject/libvirt-gobject-storage-vol.h | 2 +-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-storage-vol.c
b/libvirt-gobject/libvirt-gobject-storage-vol.c
index 5b18877..5e83e1b 100644
--- a/libvirt-gobject/libvirt-gobject-storage-vol.c
+++ b/libvirt-gobject/libvirt-gobject-storage-vol.c
@@ -184,13 +184,16 @@ const gchar *gvir_storage_vol_get_name(GVirStorageVol *vol)
return name;
}
-const gchar *gvir_storage_vol_get_path(GVirStorageVol *vol)
+const gchar *gvir_storage_vol_get_path(GVirStorageVol *vol, GError **error)
{
GVirStorageVolPrivate *priv = vol->priv;
const char *path;
if (!(path = virStorageVolGetPath(priv->handle))) {
- g_error("Failed to get storage_vol path on %p", priv->handle);
+ gvir_set_error(error, GVIR_STORAGE_VOL_ERROR, 0,
+ "Failed to get storage_vol path on %p",
+ priv->handle);
+ return NULL;
}
return path;
diff --git a/libvirt-gobject/libvirt-gobject-storage-vol.h
b/libvirt-gobject/libvirt-gobject-storage-vol.h
index db63865..25f683a 100644
--- a/libvirt-gobject/libvirt-gobject-storage-vol.h
+++ b/libvirt-gobject/libvirt-gobject-storage-vol.h
@@ -78,7 +78,7 @@ GType gvir_storage_vol_info_get_type(void);
GType gvir_storage_vol_handle_get_type(void);
const gchar *gvir_storage_vol_get_name(GVirStorageVol *vol);
-const gchar *gvir_storage_vol_get_path(GVirStorageVol *vol);
+const gchar *gvir_storage_vol_get_path(GVirStorageVol *vol, GError **error);
gboolean gvir_storage_vol_delete(GVirStorageVol *vol,
guint flags,
--
1.7.7.6