logging: use g_new0 instead of VIR_ALLOC

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Ján Tomko 2020-09-30 14:58:44 +02:00
parent 4c6f98cea6
commit d59b6070d7
4 changed files with 8 additions and 16 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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)

View File

@ -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;