[libvirt] [PATCH 1/3] Add a virGetLastErrorMessage() function
Daniel P. Berrange
berrange at redhat.com
Fri May 10 17:40:05 UTC 2013
On Fri, May 10, 2013 at 11:26:42AM -0600, Eric Blake wrote:
> On 05/10/2013 11:17 AM, Daniel P. Berrange wrote:
> > From: "Daniel P. Berrange" <berrange at redhat.com>
> >
> > Apps using libvirt will often have code like
> >
> > if (virXXXX() < 0) {
> > virErrorPtr err = virGetLastError();
> > fprintf(stderr, "Something failed: %s\n",
> > err && err->message ? err->message :
> > "unknown error");
> > return -1;
> > }
> >
> > Checking for a NULL error object or message leads to very
> > verbose code. A virGetLastErrorMessage() helper from libvirt
> > can simplify this to
> >
> > if (virXXXX() < 0) {
> > fprintf(stderr, "Something failed: %s\n",
> > virGetLastErrorMessage());
> > return -1;
> > }
> >
> > Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> > ---
> > include/libvirt/virterror.h | 2 ++
> > src/libvirt_public.syms | 5 +++++
> > src/util/virerror.c | 21 +++++++++++++++++++++
> > 3 files changed, 28 insertions(+)
>
> ACK. Client-side only, so it doesn't need RPC support.
>
> Should we update examples/hellolibvirt/hellolibvirt.c to use it?
Good idea, I'll send another patch for that.
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