[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [[libvirt-glib PATCHv2] 3/4] Output runtime warning when *_get_name fails



*_get_name failures used to trigger a crash of the application
because of the use of g_error. Now that it's removed, such failures
may go unnoticed and unchecked. Add a runtime warning when a failure
occurs.
---
 libvirt-gobject/libvirt-gobject-domain-snapshot.c |    1 +
 libvirt-gobject/libvirt-gobject-domain.c          |    1 +
 libvirt-gobject/libvirt-gobject-interface.c       |    1 +
 libvirt-gobject/libvirt-gobject-network-filter.c  |    1 +
 libvirt-gobject/libvirt-gobject-network.c         |    1 +
 libvirt-gobject/libvirt-gobject-node-device.c     |    1 +
 libvirt-gobject/libvirt-gobject-storage-pool.c    |    1 +
 libvirt-gobject/libvirt-gobject-storage-vol.c     |    2 ++
 8 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/libvirt-gobject/libvirt-gobject-domain-snapshot.c b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
index 0560595..3784b60 100644
--- a/libvirt-gobject/libvirt-gobject-domain-snapshot.c
+++ b/libvirt-gobject/libvirt-gobject-domain-snapshot.c
@@ -169,6 +169,7 @@ const gchar *gvir_domain_snapshot_get_name(GVirDomainSnapshot *snapshot)
         gvir_set_error(err, GVIR_DOMAIN_SNAPSHOT_ERROR, 0,
                        "Failed to get domain_snapshot name on %p",
                        priv->handle);
+        g_warn_if_reached();
         return NULL;
     }
 
diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c
index bfbb80f..0f64833 100644
--- a/libvirt-gobject/libvirt-gobject-domain.c
+++ b/libvirt-gobject/libvirt-gobject-domain.c
@@ -273,6 +273,7 @@ const gchar *gvir_domain_get_name(GVirDomain *dom, GError **err)
         gvir_set_error(err, GVIR_DOMAIN_ERROR, 0,
                        "Failed to get domain name on %p",
                        priv->handle);
+        g_warn_if_reached();
         return NULL;
     }
 
diff --git a/libvirt-gobject/libvirt-gobject-interface.c b/libvirt-gobject/libvirt-gobject-interface.c
index 095e22a..83d4136 100644
--- a/libvirt-gobject/libvirt-gobject-interface.c
+++ b/libvirt-gobject/libvirt-gobject-interface.c
@@ -166,6 +166,7 @@ const gchar *gvir_interface_get_name(GVirInterface *iface, GError **err)
         gvir_set_error(err, GVIR_INTERFACE_ERROR, 0,
                        "Failed to get interface name on %p",
                        priv->handle);
+        g_warn_if_reached();
         return NULL;
     }
 
diff --git a/libvirt-gobject/libvirt-gobject-network-filter.c b/libvirt-gobject/libvirt-gobject-network-filter.c
index 473ef5d..efefdf4 100644
--- a/libvirt-gobject/libvirt-gobject-network-filter.c
+++ b/libvirt-gobject/libvirt-gobject-network-filter.c
@@ -183,6 +183,7 @@ const gchar *gvir_network_filter_get_name(GVirNetworkFilter *filter,
         gvir_set_error(err, GVIR_NETWORK_FILTER_ERROR, 0,
                        "Failed to get network_filter name on %p",
                        priv->handle);
+        g_warn_if_reached();
         return NULL;
     }
 
diff --git a/libvirt-gobject/libvirt-gobject-network.c b/libvirt-gobject/libvirt-gobject-network.c
index 143e80b..43c1a52 100644
--- a/libvirt-gobject/libvirt-gobject-network.c
+++ b/libvirt-gobject/libvirt-gobject-network.c
@@ -180,6 +180,7 @@ const gchar *gvir_network_get_name(GVirNetwork *network, GError **err)
         gvir_set_error(err, GVIR_NETWORK_ERROR, 0,
                        "Failed to get network name on %p",
                        priv->handle);
+        g_warn_if_reached();
         return NULL;
     }
 
diff --git a/libvirt-gobject/libvirt-gobject-node-device.c b/libvirt-gobject/libvirt-gobject-node-device.c
index 55f7098..e34d37b 100644
--- a/libvirt-gobject/libvirt-gobject-node-device.c
+++ b/libvirt-gobject/libvirt-gobject-node-device.c
@@ -166,6 +166,7 @@ const gchar *gvir_node_device_get_name(GVirNodeDevice *device, GError **err)
         gvir_set_error(err, GVIR_NODE_DEVICE_ERROR, 0,
                        "Failed to get node_device name on %p",
                        priv->handle);
+        g_warn_if_reached();
         return NULL;
     }
 
diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c
index d2ee6d6..ef8617f 100644
--- a/libvirt-gobject/libvirt-gobject-storage-pool.c
+++ b/libvirt-gobject/libvirt-gobject-storage-pool.c
@@ -212,6 +212,7 @@ const gchar *gvir_storage_pool_get_name(GVirStoragePool *pool, GError **err)
         gvir_set_error(err, GVIR_STORAGE_POOL_ERROR, 0,
                        "Failed to get storage_pool name on %p",
                        priv->handle);
+        g_warn_if_reached();
         return NULL;
     }
 
diff --git a/libvirt-gobject/libvirt-gobject-storage-vol.c b/libvirt-gobject/libvirt-gobject-storage-vol.c
index c427e42..c27cfb7 100644
--- a/libvirt-gobject/libvirt-gobject-storage-vol.c
+++ b/libvirt-gobject/libvirt-gobject-storage-vol.c
@@ -181,6 +181,7 @@ const gchar *gvir_storage_vol_get_name(GVirStorageVol *vol, GError **error)
         gvir_set_error(error, GVIR_STORAGE_VOL_ERROR, 0,
                        "Failed to get storage_vol name on %p",
                        priv->handle);
+        g_warn_if_reached();
         return NULL;
     }
 
@@ -196,6 +197,7 @@ const gchar *gvir_storage_vol_get_path(GVirStorageVol *vol, GError **error)
         gvir_set_error(error, GVIR_STORAGE_VOL_ERROR, 0,
                        "Failed to get storage_vol path on %p",
                        priv->handle);
+        g_warn_if_reached();
         return NULL;
     }
 
-- 
1.7.7.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]