[libvirt] [PATCH 1/6] virObject: use virReportSystemError if applicable

Michal Privoznik mprivozn at redhat.com
Mon Feb 12 10:52:48 UTC 2018


When initializing a mutex (either regular or RW) the virMutexInit() and
virRWLockInit() functions set errno and return -1. It's a pity we don't
use virReportSystemError() in that case rather plain virReportError().

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/util/virobject.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/util/virobject.c b/src/util/virobject.c
index 1723df6b2..b2fc63aec 100644
--- a/src/util/virobject.c
+++ b/src/util/virobject.c
@@ -273,8 +273,8 @@ virObjectLockableNew(virClassPtr klass)
         return NULL;
 
     if (virMutexInit(&obj->lock) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Unable to initialize mutex"));
+        virReportSystemError(errno, "%s",
+                             _("Unable to initialize mutex"));
         virObjectUnref(obj);
         return NULL;
     }
@@ -299,8 +299,8 @@ virObjectRWLockableNew(virClassPtr klass)
         return NULL;
 
     if (virRWLockInit(&obj->lock) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("Unable to initialize RW lock"));
+        virReportSystemError(errno, "%s",
+                             _("Unable to initialize RW lock"));
         virObjectUnref(obj);
         return NULL;
     }
-- 
2.13.6




More information about the libvir-list mailing list