From b8630854930266a504d955de3c7ab661f0619345 Mon Sep 17 00:00:00 2001 From: Martin Kletzander Date: Wed, 15 Dec 2021 16:36:51 +0100 Subject: [PATCH] util: Initialize virLogMutex statically The only difference is that we are not going to be guaranteed that the mutex is normal (as opposed to recursive, although there is no system known to me that would default to recursive mutexes), but that was done only to find occasional errors (during runtime, back in 2010, commit 336fd879c00b). Functions using this mutex are mostly stable and unchanging, and it makes the virLogOnceInit() function only return 0 (or possibly abort in glib calls). On top of that we can assume that the virLogMutex is always initialized which enables us to be more consistent in some early error reporting. Signed-off-by: Martin Kletzander Reviewed-by: Erik Skultety --- src/util/virlog.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/util/virlog.c b/src/util/virlog.c index e368cada60..5848940c6c 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -125,7 +125,7 @@ static void virLogOutputToFd(virLogSource *src, /* * Logs accesses must be serialized though a mutex */ -virMutex virLogMutex; +static virMutex virLogMutex = VIR_MUTEX_INITIALIZER; void virLogLock(void) @@ -250,9 +250,6 @@ virLogPriorityString(virLogPriority lvl) static int virLogOnceInit(void) { - if (virMutexInit(&virLogMutex) < 0) - return -1; - virLogLock(); virLogDefaultPriority = VIR_LOG_DEFAULT; -- 2.47.2