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

Re: [libvirt] [PATCH 2/7] Report error if virMutexInit fails

On Thu, Jul 27, 2017 at 01:47:22PM +0200, Michal Privoznik wrote:
The virMutexInit() function is not reporting any error on failure
rather than returning -1 and setting errno. It's up to the caller
to report the error.

I would rather see virMutexInit() report the error since it looks like
some code already counts on it (I haven't done any comparison) and
different error messages for each mutex does not really help anything
IMHO since mutex initialization is fatal anyway.

I think virthread.c does not report errors because we had multiple
implementations for it, but that's no longer true since 404174cad321
(late 2012).

diff --git a/tools/virsh-console.c b/tools/virsh-console.c
index c1927c28a..ab3339ec7 100644
--- a/tools/virsh-console.c
+++ b/tools/virsh-console.c
@@ -351,8 +351,10 @@ virshRunConsole(vshControl *ctl,
    if (virDomainOpenConsole(dom, dev_name, con->st, flags) < 0)
        goto cleanup;

-    if (virCondInit(&con->cond) < 0 || virMutexInit(&con->lock) < 0)
+    if (virCondInit(&con->cond) < 0 || virMutexInit(&con->lock) < 0) {
+        VIR_ERROR(_("unable to init console lock or condition"));

I don't see a reason for VIR_ERROR here.  Also virCondInit() and other
could report error, although that's not the aim of this patch.

        goto cleanup;
+    }



libvir-list mailing list
libvir-list redhat com

Attachment: signature.asc
Description: Digital signature

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