[libvirt] [PATCH 4/4] util: print errno in virObjectLockableNew

Martin Kletzander mkletzan at redhat.com
Tue Jul 15 09:22:28 UTC 2014


On Tue, Jul 15, 2014 at 04:32:03PM +0800, Jincheng Miao wrote:
>In virObjectLockableNew, when virMutexInit fails,
>virReportSystemError should use errno to get the right
>error number, instead of VIR_ERR_INTERNAL_ERROR.
>
>Signed-off-by: Jincheng Miao <jmiao at redhat.com>
>---
> src/util/virobject.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/src/util/virobject.c b/src/util/virobject.c
>index 6cb84b4..b5d2c02 100644
>--- a/src/util/virobject.c
>+++ b/src/util/virobject.c
>@@ -220,7 +220,7 @@ void *virObjectLockableNew(virClassPtr klass)
>         return NULL;
>
>     if (virMutexInit(&obj->lock) < 0) {
>-        virReportSystemError(VIR_ERR_INTERNAL_ERROR, "%s",
>+        virReportSystemError(errno, "%s",
>                              _("Unable to initialize mutex"));

I'm not sure errno is set when using our virMutexInit().  Most of the
code uses virReportError instead, I suggest using that.  This should
be changed everywhere in the code.  Rough idea of the places could be
gotten by the following command:

git grep -nA5 virMutexInit | grep SystemError

but as I said, only rough idea :)

Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140715/f41a27d8/attachment-0001.sig>


More information about the libvir-list mailing list