[libvirt] [PATCH 1/3] Add a virGetLastErrorMessage() function
Eric Blake
eblake at redhat.com
Fri May 10 17:26:42 UTC 2013
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?
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130510/63f0e6eb/attachment-0001.sig>
More information about the libvir-list
mailing list