mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-18 18:45:16 +00:00
9b3455cb78
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@redhat.com> (cherry picked from commit 69c6a58a1d3906fdb3ee7929a03ce9b59f33e1c3)