Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx> --- src/util/virlog.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/util/virlog.c b/src/util/virlog.c index b3460d85fe..47e77e63b7 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -28,7 +28,6 @@ #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> -#include <regex.h> #include <sys/uio.h> #if HAVE_SYSLOG_H # include <syslog.h> @@ -61,7 +60,7 @@ VIR_LOG_INIT("util.log"); -static regex_t *virLogRegex; +static GRegex *virLogRegex; static char virLogHostname[HOST_NAME_MAX+1]; @@ -268,10 +267,7 @@ virLogOnceInit(void) virLogLock(); virLogDefaultPriority = VIR_LOG_DEFAULT; - if (VIR_ALLOC_QUIET(virLogRegex) >= 0) { - if (regcomp(virLogRegex, VIR_LOG_REGEX, REG_EXTENDED) != 0) - VIR_FREE(virLogRegex); - } + virLogRegex = g_regex_new(VIR_LOG_REGEX, G_REGEX_OPTIMIZE, 0, NULL); /* We get and remember the hostname early, because at later time * it might not be possible to load NSS modules via getaddrinfo() @@ -1262,12 +1258,11 @@ virLogSetFromEnv(void) */ bool virLogProbablyLogMessage(const char *str) { - bool ret = false; if (!virLogRegex) return false; - if (regexec(virLogRegex, str, 0, NULL, 0) == 0) - ret = true; - return ret; + if (g_regex_match(virLogRegex, str, 0, NULL)) + return true; + return false; } -- 2.21.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list