[libvirt] [[libvirt-glib PATCHv2] 2/4] Don't use g_error in xxx_get_name

Daniel P. Berrange berrange at redhat.com
Tue Jan 31 12:08:17 UTC 2012


On Tue, Jan 31, 2012 at 12:00:21PM +0100, Christophe Fergeau wrote:
> g_error will trigger an abort of the running process so it's not
> desirable to call it in a library. This commit adds a GError **
> parameter to all _get_name methods which were calling g_error.
> ---
>  libvirt-gobject/libvirt-gobject-connection.c      |   10 ++++++++--
>  libvirt-gobject/libvirt-gobject-domain-snapshot.c |    5 ++++-
>  libvirt-gobject/libvirt-gobject-domain.c          |    7 +++++--
>  libvirt-gobject/libvirt-gobject-domain.h          |    2 +-
>  libvirt-gobject/libvirt-gobject-interface.c       |    7 +++++--
>  libvirt-gobject/libvirt-gobject-interface.h       |    2 +-
>  libvirt-gobject/libvirt-gobject-network-filter.c  |    8 ++++++--
>  libvirt-gobject/libvirt-gobject-network-filter.h  |    2 +-
>  libvirt-gobject/libvirt-gobject-network.c         |    7 +++++--
>  libvirt-gobject/libvirt-gobject-network.h         |    2 +-
>  libvirt-gobject/libvirt-gobject-node-device.c     |    7 +++++--
>  libvirt-gobject/libvirt-gobject-node-device.h     |    2 +-
>  libvirt-gobject/libvirt-gobject-storage-pool.c    |    7 +++++--
>  libvirt-gobject/libvirt-gobject-storage-pool.h    |    2 +-
>  14 files changed, 49 insertions(+), 21 deletions(-)

I think that you can just replace g_error with g_warning. The
vir*GetName() methods will never fail unless passed an invalid
pointer, since they just return a const string from the struct,
avoiding any RPC

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 :|




More information about the libvir-list mailing list