[libvirt] [libvirt-glib 3/3] Correct return type of gvir_storage_pool_create_volume()
Christophe Fergeau
cfergeau at redhat.com
Wed Jan 18 14:07:19 UTC 2012
On Wed, Jan 18, 2012 at 03:49:28PM +0200, Zeeshan Ali (Khattak) wrote:
> On Wed, Jan 18, 2012 at 12:11 PM, Christophe Fergeau
> <cfergeau at redhat.com> wrote:
> > On Wed, Jan 18, 2012 at 04:53:29AM +0200, Zeeshan Ali (Khattak) wrote:
> >> From: "Zeeshan Ali (Khattak)" <zeeshanak at gnome.org>
> >>
> >> ---
> >> libvirt-gobject/libvirt-gobject-storage-pool.c | 6 +++---
> >> libvirt-gobject/libvirt-gobject-storage-pool.h | 4 ++--
> >> 2 files changed, 5 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/libvirt-gobject/libvirt-gobject-storage-pool.c b/libvirt-gobject/libvirt-gobject-storage-pool.c
> >> index 5bd3f0a..bf25641 100644
> >> --- a/libvirt-gobject/libvirt-gobject-storage-pool.c
> >> +++ b/libvirt-gobject/libvirt-gobject-storage-pool.c
> >> @@ -499,11 +499,11 @@ GList *gvir_storage_pool_get_volumes(GVirStoragePool *pool)
> >> *
> >> * Return value: (transfer full): the #GVirStorageVol, or NULL
> >> */
> >> -GVirStoragePool *gvir_storage_pool_get_volume(GVirStoragePool *pool,
> >> - const gchar *name)
> >> +GVirStorageVol *gvir_storage_pool_get_volume(GVirStoragePool *pool,
> >> + const gchar *name)
> >> {
> >> GVirStoragePoolPrivate *priv = pool->priv;
> >> - GVirStoragePool *volume;
> >> + GVirStorageVol *volume;
> >>
> >> g_mutex_lock(priv->lock);
> >> volume = g_hash_table_lookup(priv->volumes, name);
> >
> > Might be worth adding a g_return_val_if_fail(GVIR_IS_STORAGE_VOL(volume))
> > here when volume is non NULL ?
>
> We don't put anything other than volumes to this hashtable so there
> is no need AFAICT.
Well, we were mistakenly casting its content to the wrong type, who knows
which other mistakes we will be doing in the future? I was just asking if
it's worth adding this check as a way to catch future bugs.
Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120118/0c9d3517/attachment-0001.sig>
More information about the libvir-list
mailing list