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

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

 



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;
+    }

    virMutexLock(&con->lock);

--
2.13.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux