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

Re: [libvirt] [[libvirt-glib PATCHv2] 4/4] Replace g_error with g_warning in constructors



On Tue, Jan 31, 2012 at 12:00:23PM +0100, Christophe Fergeau wrote:
> g_error generates a fatal error message, meaning it will abort
> the currently running process. It's nicer to use g_warning here.
> ---
>  libvirt-gobject/libvirt-gobject-domain.c         |    4 +++-
>  libvirt-gobject/libvirt-gobject-network-filter.c |    4 +++-
>  libvirt-gobject/libvirt-gobject-network.c        |    4 +++-
>  libvirt-gobject/libvirt-gobject-secret.c         |    4 +++-
>  libvirt-gobject/libvirt-gobject-storage-pool.c   |    4 +++-
>  5 files changed, 15 insertions(+), 5 deletions(-)
> 
> diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c
> index 0f64833..e4d480a 100644
> --- a/libvirt-gobject/libvirt-gobject-domain.c
> +++ b/libvirt-gobject/libvirt-gobject-domain.c
> @@ -134,7 +134,9 @@ static void gvir_domain_constructed(GObject *object)
>  
>      /* xxx we may want to turn this into an initable */
>      if (virDomainGetUUIDString(priv->handle, priv->uuid) < 0) {
> -        g_error("Failed to get domain UUID on %p", priv->handle);
> +        virErrorPtr verr = virGetLastError();
> +        g_warning("Failed to get domain UUID on %p: %s",
> +                  priv->handle, verr->message);
>      }
>  }

This is what I think we should be doing for  GetName() too, since
it has the same error scenarios as GetUUID*().

NB, for extra paranoia you shouldn't assume verr is non-NULL.

eg,    verr ? verr->message : NULL

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|


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