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

[libvirt PATCH 1/3] logging: use g_new0 instead of VIR_ALLOC



Signed-off-by: Ján Tomko <jtomko redhat com>
---
 src/logging/log_daemon.c        | 9 +++------
 src/logging/log_daemon_config.c | 3 +--
 src/logging/log_handler.c       | 9 +++------
 src/logging/log_manager.c       | 3 +--
 4 files changed, 8 insertions(+), 16 deletions(-)

diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c
index 0649a70c9d..be93c63eb5 100644
--- a/src/logging/log_daemon.c
+++ b/src/logging/log_daemon.c
@@ -116,8 +116,7 @@ virLogDaemonNew(virLogDaemonConfigPtr config, bool privileged)
     virLogDaemonPtr logd;
     virNetServerPtr srv = NULL;
 
-    if (VIR_ALLOC(logd) < 0)
-        return NULL;
+    logd = g_new0(virLogDaemon, 1);
 
     g_mutex_init(&logd->lock);
 
@@ -214,8 +213,7 @@ virLogDaemonNewPostExecRestart(virJSONValuePtr object, bool privileged,
     virJSONValuePtr child;
     const char *serverNames[] = { "virtlogd" };
 
-    if (VIR_ALLOC(logd) < 0)
-        return NULL;
+    logd = g_new0(virLogDaemon, 1);
 
     g_mutex_init(&logd->lock);
 
@@ -330,8 +328,7 @@ virLogDaemonClientNew(virNetServerClientPtr client,
     unsigned long long timestamp;
     bool privileged = opaque != NULL;
 
-    if (VIR_ALLOC(priv) < 0)
-        return NULL;
+    priv = g_new0(virLogDaemonClient, 1);
 
     g_mutex_init(&priv->lock);
 
diff --git a/src/logging/log_daemon_config.c b/src/logging/log_daemon_config.c
index 97f2de90a6..5577991b13 100644
--- a/src/logging/log_daemon_config.c
+++ b/src/logging/log_daemon_config.c
@@ -58,8 +58,7 @@ virLogDaemonConfigNew(bool privileged G_GNUC_UNUSED)
 {
     virLogDaemonConfigPtr data;
 
-    if (VIR_ALLOC(data) < 0)
-        return NULL;
+    data = g_new0(virLogDaemonConfig, 1);
 
     data->max_clients = 1024;
     data->admin_max_clients = 5000;
diff --git a/src/logging/log_handler.c b/src/logging/log_handler.c
index 87748d96d1..d47009d686 100644
--- a/src/logging/log_handler.c
+++ b/src/logging/log_handler.c
@@ -221,8 +221,7 @@ virLogHandlerLogFilePostExecRestart(virLogHandlerPtr handler,
     const char *domuuid;
     const char *tmp;
 
-    if (VIR_ALLOC(file) < 0)
-        return NULL;
+    file = g_new0(virLogHandlerLogFile, 1);
 
     handler->inhibitor(true, handler->opaque);
 
@@ -389,8 +388,7 @@ virLogHandlerDomainOpenLogFile(virLogHandlerPtr handler,
     if (virPipe(pipefd) < 0)
         goto error;
 
-    if (VIR_ALLOC(file) < 0)
-        goto error;
+    file = g_new0(virLogHandlerLogFile, 1);
 
     file->watch = -1;
     file->pipefd = pipefd[0];
@@ -537,8 +535,7 @@ virLogHandlerDomainReadLogFile(virLogHandlerPtr handler,
     if (virRotatingFileReaderSeek(file, inode, offset) < 0)
         goto error;
 
-    if (VIR_ALLOC_N(data, maxlen + 1) < 0)
-        goto error;
+    data = g_new0(char, maxlen + 1);
 
     got = virRotatingFileReaderConsume(file, data, maxlen);
     if (got < 0)
diff --git a/src/logging/log_manager.c b/src/logging/log_manager.c
index fd7c2922b3..57be340a2d 100644
--- a/src/logging/log_manager.c
+++ b/src/logging/log_manager.c
@@ -113,8 +113,7 @@ virLogManagerNew(bool privileged)
 {
     virLogManagerPtr mgr;
 
-    if (VIR_ALLOC(mgr) < 0)
-        goto error;
+    mgr = g_new0(virLogManager, 1);
 
     if (!(mgr->client = virLogManagerConnect(privileged, &mgr->program)))
         goto error;
-- 
2.26.2


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