From nobody Mon Feb 9 01:42:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1602159183; cv=none; d=zohomail.com; s=zohoarc; b=dqXTVzlgi+1zspOMSxxkLxokiJaHu944RimxTAh5yHg+3+H9qzzXY1CKxFm07WVEc8bAL1Fe0vGi43mJh4RkiRgSVyCqea7L23mjn0ZJt/9XiHR7S66LuGwILgUhSQhrR93M3RBBKnVgYmF3NHek/PYrzu6WnbQkFxGGlXZsny0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602159183; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0IBu0dz4ZTS4KUomAiXscSjeIvcpjsvzB3iV6yRRGGc=; b=IjJK6/GwcPCy/7uE3m/4sBpVUZw7rekrYwq8ASU7R7hVDFxydvFlEA9uukdLWWotUmTctMaIGTkVUnGnd1lrc/lPzQR7xX08uAYAZPPCYzFrCwUHHEsB5xbFC7aPvWlVJ2YzoIxaR/y4eXQMNDyMZR+oEEjZJXtuR//1nb5aXLQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1602159183932538.0586829952279; Thu, 8 Oct 2020 05:13:03 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-517-6e8x4XOZNbyZmAOkc2XMBg-1; Thu, 08 Oct 2020 08:12:59 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 926F8ADC4E; Thu, 8 Oct 2020 12:12:40 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6D04D61176; Thu, 8 Oct 2020 12:12:40 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 318798C7BC; Thu, 8 Oct 2020 12:12:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 098CCLnS001283 for ; Thu, 8 Oct 2020 08:12:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 61BA55577D; Thu, 8 Oct 2020 12:12:21 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F04C8246F for ; Thu, 8 Oct 2020 12:12:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602159182; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=0IBu0dz4ZTS4KUomAiXscSjeIvcpjsvzB3iV6yRRGGc=; b=QulVBdzlCf1Txe/qyiZ8q0BA9bknPC3KoX1PdHZOFWWvJOeyE6CTIIh/7omzi8xNL1Xjef ATgFx8vBHGSg9pmUTcN1CX4qVf+91B0I+57UTHAz8jyHmRioE9/OSswMvBPBEwL7kCRQlj ndAVPsBCc2M16dRQL7NDNlVixujFhhI= X-MC-Unique: 6e8x4XOZNbyZmAOkc2XMBg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 3/8] remote: use g_new0 instead of VIR_ALLOC Date: Thu, 8 Oct 2020 14:12:09 +0200 Message-Id: <575abee8056db1a3c28927d3c23962ae777943b0.1602158901.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: J=C3=A1n Tomko --- src/remote/remote_daemon_config.c | 3 +- src/remote/remote_daemon_dispatch.c | 225 ++++++++++------------------ src/remote/remote_daemon_stream.c | 6 +- src/remote/remote_driver.c | 102 ++++--------- 4 files changed, 108 insertions(+), 228 deletions(-) diff --git a/src/remote/remote_daemon_config.c b/src/remote/remote_daemon_c= onfig.c index a09f287656..f0cca42925 100644 --- a/src/remote/remote_daemon_config.c +++ b/src/remote/remote_daemon_config.c @@ -94,8 +94,7 @@ daemonConfigNew(bool privileged G_GNUC_UNUSED) { struct daemonConfig *data; =20 - if (VIR_ALLOC(data) < 0) - return NULL; + data =3D g_new0(struct daemonConfig, 1); =20 #ifdef WITH_IP # ifdef LIBVIRTD diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index a659737bc7..90115167fb 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -1597,8 +1597,7 @@ remoteRelayDomainQemuMonitorEvent(virConnectPtr conn, data.seconds =3D seconds; data.micros =3D micros; if (details) { - if (VIR_ALLOC(data.details) < 0) - goto error; + data.details =3D g_new0(char *, 1); *(data.details) =3D g_strdup(details); } make_nonnull_domain(&data.dom, dom); @@ -1608,11 +1607,6 @@ remoteRelayDomainQemuMonitorEvent(virConnectPtr conn, (xdrproc_t)xdr_qemu_domain_monitor_event= _msg, &data); return; - - error: - xdr_free((xdrproc_t)xdr_qemu_domain_monitor_event_msg, - (char *) &data); - return; } =20 static @@ -1907,8 +1901,7 @@ void *remoteClientNew(virNetServerClientPtr client, { struct daemonClientPrivate *priv; =20 - if (VIR_ALLOC(priv) < 0) - return NULL; + priv =3D g_new0(struct daemonClientPrivate, 1); =20 if (virMutexInit(&priv->lock) < 0) { VIR_FREE(priv); @@ -2309,8 +2302,8 @@ remoteDispatchDomainGetSchedulerParameters(virNetServ= erPtr server G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"= )); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params =3D g_new0(virTypedParameter, args->nparams); nparams =3D args->nparams; =20 if (!(dom =3D get_nonnull_domain(conn, args->dom))) @@ -2357,8 +2350,8 @@ remoteDispatchDomainGetSchedulerParametersFlags(virNe= tServerPtr server G_GNUC_UN virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"= )); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params =3D g_new0(virTypedParameter, args->nparams); nparams =3D args->nparams; =20 if (!(dom =3D get_nonnull_domain(conn, args->dom))) @@ -2413,16 +2406,14 @@ remoteDispatchDomainMemoryStats(virNetServerPtr ser= ver G_GNUC_UNUSED, goto cleanup; =20 /* Allocate stats array for making dispatch call */ - if (VIR_ALLOC_N(stats, args->maxStats) < 0) - goto cleanup; + stats =3D g_new0(struct _virDomainMemoryStat, args->maxStats); =20 nr_stats =3D virDomainMemoryStats(dom, stats, args->maxStats, args->fl= ags); if (nr_stats < 0) goto cleanup; =20 /* Allocate return buffer */ - if (VIR_ALLOC_N(ret->stats.stats_val, args->maxStats) < 0) - goto cleanup; + ret->stats.stats_val =3D g_new0(remote_domain_memory_stat, args->maxSt= ats); =20 /* Copy the stats into the xdr return structure */ for (i =3D 0; i < nr_stats; i++) { @@ -2473,8 +2464,7 @@ remoteDispatchDomainBlockPeek(virNetServerPtr server = G_GNUC_UNUSED, } =20 ret->buffer.buffer_len =3D size; - if (VIR_ALLOC_N(ret->buffer.buffer_val, size) < 0) - goto cleanup; + ret->buffer.buffer_val =3D g_new0(char, size); =20 if (virDomainBlockPeek(dom, path, offset, size, ret->buffer.buffer_val, flags) < 0) @@ -2518,8 +2508,8 @@ remoteDispatchDomainBlockStatsFlags(virNetServerPtr s= erver G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"= )); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params =3D g_new0(virTypedParameter, args->nparams); nparams =3D args->nparams; =20 if (virDomainBlockStatsFlags(dom, path, params, &nparams, flags) < 0) @@ -2583,8 +2573,7 @@ remoteDispatchDomainMemoryPeek(virNetServerPtr server= G_GNUC_UNUSED, } =20 ret->buffer.buffer_len =3D size; - if (VIR_ALLOC_N(ret->buffer.buffer_val, size) < 0) - goto cleanup; + ret->buffer.buffer_val =3D g_new0(char, size); =20 if (virDomainMemoryPeek(dom, offset, size, ret->buffer.buffer_val, flags) < 0) @@ -2620,15 +2609,13 @@ remoteDispatchDomainGetSecurityLabel(virNetServerPt= r server G_GNUC_UNUSED, if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 - if (VIR_ALLOC(seclabel) < 0) - goto cleanup; + seclabel =3D g_new0(virSecurityLabel, 1); =20 if (virDomainGetSecurityLabel(dom, seclabel) < 0) goto cleanup; =20 ret->label.label_len =3D strlen(seclabel->label) + 1; - if (VIR_ALLOC_N(ret->label.label_val, ret->label.label_len) < 0) - goto cleanup; + ret->label.label_val =3D g_new0(char, ret->label.label_len); strcpy(ret->label.label_val, seclabel->label); ret->enforcing =3D seclabel->enforcing; =20 @@ -2669,8 +2656,7 @@ remoteDispatchDomainGetSecurityLabelList(virNetServer= Ptr server G_GNUC_UNUSED, goto done; } =20 - if (VIR_ALLOC_N(ret->labels.labels_val, len) < 0) - goto cleanup; + ret->labels.labels_val =3D g_new0(remote_domain_get_security_label_ret= , len); =20 for (i =3D 0; i < len; i++) { size_t label_len =3D strlen(seclabels[i].label) + 1; @@ -2711,13 +2697,11 @@ remoteDispatchNodeGetSecurityModel(virNetServerPtr = server G_GNUC_UNUSED, goto cleanup; =20 ret->model.model_len =3D strlen(secmodel.model) + 1; - if (VIR_ALLOC_N(ret->model.model_val, ret->model.model_len) < 0) - goto cleanup; + ret->model.model_val =3D g_new0(char, ret->model.model_len); strcpy(ret->model.model_val, secmodel.model); =20 ret->doi.doi_len =3D strlen(secmodel.doi) + 1; - if (VIR_ALLOC_N(ret->doi.doi_val, ret->doi.doi_len) < 0) - goto cleanup; + ret->doi.doi_val =3D g_new0(char, ret->doi.doi_len); strcpy(ret->doi.doi_val, secmodel.doi); =20 rv =3D 0; @@ -2760,9 +2744,8 @@ remoteDispatchDomainGetVcpuPinInfo(virNetServerPtr se= rver G_GNUC_UNUSED, } =20 /* Allocate buffers to take the results. */ - if (args->maplen > 0 && - VIR_ALLOC_N(cpumaps, args->ncpumaps * args->maplen) < 0) - goto cleanup; + if (args->maplen > 0) + cpumaps =3D g_new0(unsigned char, args->ncpumaps * args->maplen); =20 if ((num =3D virDomainGetVcpuPinInfo(dom, args->ncpumaps, @@ -2844,9 +2827,8 @@ remoteDispatchDomainGetEmulatorPinInfo(virNetServerPt= r server G_GNUC_UNUSED, goto cleanup; =20 /* Allocate buffers to take the results */ - if (args->maplen > 0 && - VIR_ALLOC_N(cpumaps, args->maplen) < 0) - goto cleanup; + if (args->maplen > 0) + cpumaps =3D g_new0(unsigned char, args->maplen); =20 if ((r =3D virDomainGetEmulatorPinInfo(dom, cpumaps, @@ -2903,11 +2885,9 @@ remoteDispatchDomainGetVcpus(virNetServerPtr server = G_GNUC_UNUSED, } =20 /* Allocate buffers to take the results. */ - if (VIR_ALLOC_N(info, args->maxinfo) < 0) - goto cleanup; - if (args->maplen > 0 && - VIR_ALLOC_N(cpumaps, args->maxinfo * args->maplen) < 0) - goto cleanup; + info =3D g_new0(virVcpuInfo, args->maxinfo); + if (args->maplen > 0) + cpumaps =3D g_new0(unsigned char, args->maxinfo * args->maplen); =20 if ((info_len =3D virDomainGetVcpus(dom, info, args->maxinfo, @@ -2916,8 +2896,7 @@ remoteDispatchDomainGetVcpus(virNetServerPtr server G= _GNUC_UNUSED, =20 /* Allocate the return buffer for info. */ ret->info.info_len =3D info_len; - if (VIR_ALLOC_N(ret->info.info_val, info_len) < 0) - goto cleanup; + ret->info.info_val =3D g_new0(remote_vcpu_info, info_len); =20 for (i =3D 0; i < info_len; ++i) { ret->info.info_val[i].number =3D info[i].number; @@ -2980,9 +2959,7 @@ remoteDispatchDomainGetIOThreadInfo(virNetServerPtr s= erver G_GNUC_UNUSED, } =20 if (ninfo) { - if (VIR_ALLOC_N(ret->info.info_val, ninfo) < 0) - goto cleanup; - + ret->info.info_val =3D g_new0(remote_domain_iothread_info, ninfo); ret->info.info_len =3D ninfo; =20 for (i =3D 0; i < ninfo; i++) { @@ -3040,8 +3017,7 @@ remoteDispatchDomainMigratePrepare(virNetServerPtr se= rver G_GNUC_UNUSED, dname =3D args->dname =3D=3D NULL ? NULL : *args->dname; =20 /* Wacky world of XDR ... */ - if (VIR_ALLOC(uri_out) < 0) - goto cleanup; + uri_out =3D g_new0(char *, 1); =20 if (virDomainMigratePrepare(conn, &cookie, &cookielen, uri_in, uri_out, @@ -3092,8 +3068,7 @@ remoteDispatchDomainMigratePrepare2(virNetServerPtr s= erver G_GNUC_UNUSED, dname =3D args->dname =3D=3D NULL ? NULL : *args->dname; =20 /* Wacky world of XDR ... */ - if (VIR_ALLOC(uri_out) < 0) - goto cleanup; + uri_out =3D g_new0(char *, 1); =20 if (virDomainMigratePrepare2(conn, &cookie, &cookielen, uri_in, uri_out, @@ -3142,8 +3117,8 @@ remoteDispatchDomainGetMemoryParameters(virNetServerP= tr server G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"= )); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params =3D g_new0(virTypedParameter, args->nparams); nparams =3D args->nparams; =20 if (!(dom =3D get_nonnull_domain(conn, args->dom))) @@ -3202,8 +3177,8 @@ remoteDispatchDomainGetNumaParameters(virNetServerPtr= server G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"= )); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params =3D g_new0(virTypedParameter, args->nparams); nparams =3D args->nparams; =20 if (!(dom =3D get_nonnull_domain(conn, args->dom))) @@ -3262,8 +3237,8 @@ remoteDispatchDomainGetBlkioParameters(virNetServerPt= r server G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"= )); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params =3D g_new0(virTypedParameter, args->nparams); nparams =3D args->nparams; =20 if (!(dom =3D get_nonnull_domain(conn, args->dom))) @@ -3323,8 +3298,8 @@ remoteDispatchNodeGetCPUStats(virNetServerPtr server = G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"= )); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params =3D g_new0(virNodeCPUStats, args->nparams); nparams =3D args->nparams; =20 if (virNodeGetCPUStats(conn, cpuNum, params, &nparams, flags) < 0) @@ -3340,8 +3315,7 @@ remoteDispatchNodeGetCPUStats(virNetServerPtr server = G_GNUC_UNUSED, =20 /* Serialise the memory parameters. */ ret->params.params_len =3D nparams; - if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0) - goto cleanup; + ret->params.params_val =3D g_new0(remote_node_get_cpu_stats, nparams); =20 for (i =3D 0; i < nparams; ++i) { /* remoteDispatchClientRequest will free this: */ @@ -3391,8 +3365,8 @@ remoteDispatchNodeGetMemoryStats(virNetServerPtr serv= er G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"= )); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params =3D g_new0(virNodeMemoryStats, args->nparams); nparams =3D args->nparams; =20 if (virNodeGetMemoryStats(conn, cellNum, params, &nparams, flags) < 0) @@ -3408,8 +3382,7 @@ remoteDispatchNodeGetMemoryStats(virNetServerPtr serv= er G_GNUC_UNUSED, =20 /* Serialise the memory parameters. */ ret->params.params_len =3D nparams; - if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0) - goto cleanup; + ret->params.params_val =3D g_new0(remote_node_get_memory_stats, nparam= s); =20 for (i =3D 0; i < nparams; ++i) { /* remoteDispatchClientRequest will free this: */ @@ -3573,8 +3546,8 @@ remoteDispatchDomainGetBlockIoTune(virNetServerPtr se= rver G_GNUC_UNUSED, goto cleanup; } =20 - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params =3D g_new0(virTypedParameter, args->nparams); nparams =3D args->nparams; =20 if (!(dom =3D get_nonnull_domain(conn, args->dom))) @@ -3649,8 +3622,7 @@ remoteDispatchAuthList(virNetServerPtr server, } =20 ret->types.types_len =3D 1; - if (VIR_ALLOC_N(ret->types.types_val, ret->types.types_len) < 0) - goto cleanup; + ret->types.types_val =3D g_new0(remote_auth_type, ret->types.types_len= ); =20 switch ((virNetServerServiceAuthMethods) auth) { case VIR_NET_SERVER_SERVICE_AUTH_NONE: @@ -3666,7 +3638,6 @@ remoteDispatchAuthList(virNetServerPtr server, =20 rv =3D 0; =20 - cleanup: if (rv < 0) virNetMessageSaveError(rerr); return rv; @@ -3846,8 +3817,7 @@ remoteDispatchAuthSaslStart(virNetServerPtr server, =20 /* NB, distinction of NULL vs "" is *critical* in SASL */ if (serverout) { - if (VIR_ALLOC_N(ret->data.data_val, serveroutlen) < 0) - goto authfail; + ret->data.data_val =3D g_new0(char, serveroutlen); memcpy(ret->data.data_val, serverout, serveroutlen); } else { ret->data.data_val =3D NULL; @@ -3942,8 +3912,7 @@ remoteDispatchAuthSaslStep(virNetServerPtr server, =20 /* NB, distinction of NULL vs "" is *critical* in SASL */ if (serverout) { - if (VIR_ALLOC_N(ret->data.data_val, serveroutlen) < 0) - goto authfail; + ret->data.data_val =3D g_new0(char, serveroutlen); memcpy(ret->data.data_val, serverout, serveroutlen); } else { ret->data.data_val =3D NULL; @@ -4147,8 +4116,7 @@ remoteDispatchNodeDeviceGetParent(virNetServerPtr ser= ver G_GNUC_UNUSED, ret->parentName =3D NULL; } else { /* remoteDispatchClientRequest will free this. */ - if (VIR_ALLOC(ret->parentName) < 0) - goto cleanup; + ret->parentName =3D g_new0(char *, 1); *(ret->parentName) =3D g_strdup(parent); } =20 @@ -4250,8 +4218,7 @@ remoteDispatchConnectDomainEventRegister(virNetServer= Ptr server G_GNUC_UNUSED, * clearing 'callback' and having to juggle the pointer * between 'ref' and 'callback'. */ - if (VIR_ALLOC(callback) < 0) - goto cleanup; + callback =3D g_new0(daemonClientEventCallback, 1); callback->client =3D virObjectRef(client); callback->program =3D virObjectRef(remoteProgram); callback->eventID =3D VIR_DOMAIN_EVENT_ID_LIFECYCLE; @@ -4479,8 +4446,7 @@ remoteDispatchConnectDomainEventRegisterAny(virNetSer= verPtr server G_GNUC_UNUSED * incomplete callback to our array, then register, then fix up * our callback; but since VIR_APPEND_ELEMENT clears 'callback' on * success, we use 'ref' to save a copy of the pointer. */ - if (VIR_ALLOC(callback) < 0) - goto cleanup; + callback =3D g_new0(daemonClientEventCallback, 1); callback->client =3D virObjectRef(client); callback->program =3D virObjectRef(remoteProgram); callback->eventID =3D args->eventID; @@ -4555,8 +4521,7 @@ remoteDispatchConnectDomainEventCallbackRegisterAny(v= irNetServerPtr server G_GNU * incomplete callback to our array, then register, then fix up * our callback; but since VIR_APPEND_ELEMENT clears 'callback' on * success, we use 'ref' to save a copy of the pointer. */ - if (VIR_ALLOC(callback) < 0) - goto cleanup; + callback =3D g_new0(daemonClientEventCallback, 1); callback->client =3D virObjectRef(client); callback->program =3D virObjectRef(remoteProgram); callback->eventID =3D args->eventID; @@ -4799,8 +4764,7 @@ remoteDispatchDomainMigratePrepare3(virNetServerPtr s= erver G_GNUC_UNUSED, dname =3D args->dname =3D=3D NULL ? NULL : *args->dname; =20 /* Wacky world of XDR ... */ - if (VIR_ALLOC(uri_out) < 0) - goto cleanup; + uri_out =3D g_new0(char *, 1); =20 if (virDomainMigratePrepare3(conn, args->cookie_in.cookie_in_val, @@ -5130,8 +5094,8 @@ remoteDispatchDomainGetInterfaceParameters(virNetServ= erPtr server G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"= )); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params =3D g_new0(virTypedParameter, args->nparams); nparams =3D args->nparams; =20 if (!(dom =3D get_nonnull_domain(conn, args->dom))) @@ -5192,9 +5156,8 @@ remoteDispatchDomainGetCPUStats(virNetServerPtr serve= r G_GNUC_UNUSED, goto cleanup; } =20 - if (args->nparams > 0 && - VIR_ALLOC_N(params, args->ncpus * args->nparams) < 0) - goto cleanup; + if (args->nparams > 0) + params =3D g_new0(virTypedParameter, args->ncpus * args->nparams); =20 if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; @@ -5261,9 +5224,8 @@ remoteDispatchDomainGetDiskErrors(virNetServerPtr ser= ver G_GNUC_UNUSED, goto cleanup; } =20 - if (args->maxerrors && - VIR_ALLOC_N(errors, args->maxerrors) < 0) - goto cleanup; + if (args->maxerrors) + errors =3D g_new0(virDomainDiskError, args->maxerrors); =20 if ((len =3D virDomainGetDiskErrors(dom, errors, args->maxerrors, @@ -5352,8 +5314,8 @@ remoteDispatchNodeGetMemoryParameters(virNetServerPtr= server G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"= )); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params =3D g_new0(virTypedParameter, args->nparams); nparams =3D args->nparams; =20 if (virNodeGetMemoryParameters(conn, params, &nparams, flags) < 0) @@ -5602,8 +5564,7 @@ remoteDispatchDomainMigratePrepare3Params(virNetServe= rPtr server G_GNUC_UNUSED, goto cleanup; =20 /* Wacky world of XDR ... */ - if (VIR_ALLOC(uri_out) < 0) - goto cleanup; + uri_out =3D g_new0(char *, 1); =20 if (virDomainMigratePrepare3Params(conn, params, nparams, args->cookie_in.cookie_in_val, @@ -5924,8 +5885,7 @@ remoteDispatchDomainCreateXMLWithFiles(virNetServerPt= r server G_GNUC_UNUSED, if (!conn) goto cleanup; =20 - if (VIR_ALLOC_N(files, msg->nfds) < 0) - goto cleanup; + files =3D g_new0(int, msg->nfds); for (i =3D 0; i < msg->nfds; i++) { if ((files[i] =3D virNetMessageDupFD(msg, i)) < 0) goto cleanup; @@ -5969,8 +5929,7 @@ static int remoteDispatchDomainCreateWithFiles(virNet= ServerPtr server G_GNUC_UNU if (!conn) goto cleanup; =20 - if (VIR_ALLOC_N(files, msg->nfds) < 0) - goto cleanup; + files =3D g_new0(int, msg->nfds); for (i =3D 0; i < msg->nfds; i++) { if ((files[i] =3D virNetMessageDupFD(msg, i)) < 0) goto cleanup; @@ -6038,8 +5997,7 @@ remoteDispatchConnectNetworkEventRegisterAny(virNetSe= rverPtr server G_GNUC_UNUSE * incomplete callback to our array, then register, then fix up * our callback; but since VIR_APPEND_ELEMENT clears 'callback' on * success, we use 'ref' to save a copy of the pointer. */ - if (VIR_ALLOC(callback) < 0) - goto cleanup; + callback =3D g_new0(daemonClientEventCallback, 1); callback->client =3D virObjectRef(client); callback->program =3D virObjectRef(remoteProgram); callback->eventID =3D args->eventID; @@ -6159,8 +6117,7 @@ remoteDispatchConnectStoragePoolEventRegisterAny(virN= etServerPtr server G_GNUC_U * incomplete callback to our array, then register, then fix up * our callback; but since VIR_APPEND_ELEMENT clears 'callback' on * success, we use 'ref' to save a copy of the pointer. */ - if (VIR_ALLOC(callback) < 0) - goto cleanup; + callback =3D g_new0(daemonClientEventCallback, 1); callback->client =3D virObjectRef(client); callback->program =3D virObjectRef(remoteProgram); callback->eventID =3D args->eventID; @@ -6279,8 +6236,7 @@ remoteDispatchConnectNodeDeviceEventRegisterAny(virNe= tServerPtr server G_GNUC_UN * incomplete callback to our array, then register, then fix up * our callback; but since VIR_APPEND_ELEMENT clears 'callback' on * success, we use 'ref' to save a copy of the pointer. */ - if (VIR_ALLOC(callback) < 0) - goto cleanup; + callback =3D g_new0(daemonClientEventCallback, 1); callback->client =3D virObjectRef(client); callback->program =3D virObjectRef(remoteProgram); callback->eventID =3D args->eventID; @@ -6399,8 +6355,7 @@ remoteDispatchConnectSecretEventRegisterAny(virNetSer= verPtr server G_GNUC_UNUSED * incomplete callback to our array, then register, then fix up * our callback; but since VIR_APPEND_ELEMENT clears 'callback' on * success, we use 'ref' to save a copy of the pointer. */ - if (VIR_ALLOC(callback) < 0) - goto cleanup; + callback =3D g_new0(daemonClientEventCallback, 1); callback->client =3D virObjectRef(client); callback->program =3D virObjectRef(remoteProgram); callback->eventID =3D args->eventID; @@ -6514,8 +6469,7 @@ qemuDispatchConnectDomainMonitorEventRegister(virNetS= erverPtr server G_GNUC_UNUS * incomplete callback to our array, then register, then fix up * our callback; but since VIR_APPEND_ELEMENT clears 'callback' on * success, we use 'ref' to save a copy of the pointer. */ - if (VIR_ALLOC(callback) < 0) - goto cleanup; + callback =3D g_new0(daemonClientEventCallback, 1); callback->client =3D virObjectRef(client); callback->program =3D virObjectRef(qemuProgram); callback->eventID =3D -1; @@ -6656,9 +6610,8 @@ remoteDispatchNodeGetFreePages(virNetServerPtr server= G_GNUC_UNUSED, } =20 /* Allocate return buffer. */ - if (VIR_ALLOC_N(ret->counts.counts_val, - args->pages.pages_len * args->cellCount) < 0) - goto cleanup; + ret->counts.counts_val =3D g_new0(uint64_t, + args->pages.pages_len * args->cellCoun= t); =20 if ((len =3D virNodeGetFreePages(conn, args->pages.pages_len, @@ -6747,9 +6700,7 @@ remoteDispatchNetworkGetDHCPLeases(virNetServerPtr se= rver G_GNUC_UNUSED, } =20 if (leases && nleases) { - if (VIR_ALLOC_N(ret->leases.leases_val, nleases) < 0) - goto cleanup; - + ret->leases.leases_val =3D g_new0(remote_network_dhcp_lease, nleas= es); ret->leases.leases_len =3D nleases; =20 for (i =3D 0; i < nleases; i++) { @@ -6797,8 +6748,7 @@ remoteDispatchConnectGetAllDomainStats(virNetServerPt= r server G_GNUC_UNUSED, goto cleanup; =20 if (args->doms.doms_len) { - if (VIR_ALLOC_N(doms, args->doms.doms_len + 1) < 0) - goto cleanup; + doms =3D g_new0(virDomainPtr, args->doms.doms_len + 1); =20 for (i =3D 0; i < args->doms.doms_len; i++) { if (!(doms[i] =3D get_nonnull_domain(conn, args->doms.doms_val= [i]))) @@ -6827,9 +6777,7 @@ remoteDispatchConnectGetAllDomainStats(virNetServerPt= r server G_GNUC_UNUSED, goto cleanup; } =20 - if (VIR_ALLOC_N(ret->retStats.retStats_val, nrecords) < 0) - goto cleanup; - + ret->retStats.retStats_val =3D g_new0(remote_domain_stats_record, = nrecords); ret->retStats.retStats_len =3D nrecords; =20 for (i =3D 0; i < nrecords; i++) { @@ -6934,9 +6882,7 @@ remoteDispatchDomainGetFSInfo(virNetServerPtr server = G_GNUC_UNUSED, } =20 if (ninfo) { - if (VIR_ALLOC_N(ret->info.info_val, ninfo) < 0) - goto cleanup; - + ret->info.info_val =3D g_new0(remote_domain_fsinfo, ninfo); ret->info.info_len =3D ninfo; =20 for (i =3D 0; i < ninfo; i++) { @@ -6956,8 +6902,7 @@ remoteDispatchDomainGetFSInfo(virNetServerPtr server = G_GNUC_UNUSED, } =20 if (ndisk > 0) { - if (VIR_ALLOC_N(dst->dev_aliases.dev_aliases_val, ndisk) <= 0) - goto cleanup; + dst->dev_aliases.dev_aliases_val =3D g_new0(char *, ndisk); =20 for (j =3D 0; j < ndisk; j++) dst->dev_aliases.dev_aliases_val[j] =3D g_strdup(info[= i]->devAlias[j]); @@ -7019,9 +6964,7 @@ remoteSerializeDomainInterface(virDomainInterfacePtr = *ifaces, return -1; } =20 - if (VIR_ALLOC_N(ret->ifaces.ifaces_val, ifaces_count) < 0) - return -1; - + ret->ifaces.ifaces_val =3D g_new0(remote_domain_interface, ifaces_coun= t); ret->ifaces.ifaces_len =3D ifaces_count; =20 for (i =3D 0; i < ifaces_count; i++) { @@ -7031,8 +6974,7 @@ remoteSerializeDomainInterface(virDomainInterfacePtr = *ifaces, iface_ret->name =3D g_strdup(iface->name); =20 if (iface->hwaddr) { - if (VIR_ALLOC(iface_ret->hwaddr) < 0) - goto cleanup; + iface_ret->hwaddr =3D g_new0(char *, 1); *iface_ret->hwaddr =3D g_strdup(iface->hwaddr); } =20 @@ -7043,10 +6985,7 @@ remoteSerializeDomainInterface(virDomainInterfacePtr= *ifaces, goto cleanup; } =20 - if (VIR_ALLOC_N(iface_ret->addrs.addrs_val, - iface->naddrs) < 0) - goto cleanup; - + iface_ret->addrs.addrs_val =3D g_new0(remote_domain_ip_addr, iface= ->naddrs); iface_ret->addrs.addrs_len =3D iface->naddrs; =20 for (j =3D 0; j < iface->naddrs; j++) { @@ -7362,8 +7301,7 @@ remoteSerializeDomainDiskErrors(virDomainDiskErrorPtr= errors, remote_domain_disk_error *val =3D NULL; size_t i =3D 0; =20 - if (VIR_ALLOC_N(val, nerrors) < 0) - goto error; + val =3D g_new0(remote_domain_disk_error, nerrors); =20 for (i =3D 0; i < nerrors; i++) { val[i].disk =3D g_strdup(errors[i].disk); @@ -7374,15 +7312,6 @@ remoteSerializeDomainDiskErrors(virDomainDiskErrorPt= r errors, *ret_errors_val =3D val; =20 return 0; - - error: - if (val) { - size_t j; - for (j =3D 0; j < i; j++) - VIR_FREE(val[j].disk); - VIR_FREE(val); - } - return -1; } =20 static int diff --git a/src/remote/remote_daemon_stream.c b/src/remote/remote_daemon_s= tream.c index 9a62189cd6..b4a3cb6741 100644 --- a/src/remote/remote_daemon_stream.c +++ b/src/remote/remote_daemon_stream.c @@ -362,8 +362,7 @@ daemonCreateClientStream(virNetServerClientPtr client, VIR_DEBUG("client=3D%p, proc=3D%d, serial=3D%u, st=3D%p", client, header->proc, header->serial, st); =20 - if (VIR_ALLOC(stream) < 0) - return NULL; + stream =3D g_new0(daemonClientStream, 1); =20 stream->refs =3D 1; stream->priv =3D priv; @@ -853,8 +852,7 @@ daemonStreamHandleRead(virNetServerClientPtr client, =20 memset(&rerr, 0, sizeof(rerr)); =20 - if (VIR_ALLOC_N(buffer, bufferLen) < 0) - return -1; + buffer =3D g_new0(char, bufferLen); =20 if (!(msg =3D virNetMessageNew(false))) goto cleanup; diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 6e0c04f168..49769ac04d 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -1207,8 +1207,7 @@ static struct private_data * remoteAllocPrivateData(void) { struct private_data *priv; - if (VIR_ALLOC(priv) < 0) - return NULL; + priv =3D g_new0(struct private_data, 1); =20 if (virMutexInit(&priv->lock) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -2271,18 +2270,15 @@ remoteDomainGetIOThreadInfo(virDomainPtr dom, goto cleanup; } =20 - if (VIR_ALLOC_N(info_ret, ret.info.info_len) < 0) - goto cleanup; + info_ret =3D g_new0(virDomainIOThreadInfoPtr, ret.info.info_len); =20 for (i =3D 0; i < ret.info.info_len; i++) { src =3D &ret.info.info_val[i]; =20 - if (VIR_ALLOC(info_ret[i]) < 0) - goto cleanup; + info_ret[i] =3D g_new0(virDomainIOThreadInfo, 1); =20 info_ret[i]->iothread_id =3D src->iothread_id; - if (VIR_ALLOC_N(info_ret[i]->cpumap, src->cpumap.cpumap_len) <= 0) - goto cleanup; + info_ret[i]->cpumap =3D g_new0(unsigned char, src->cpumap.cpum= ap_len); memcpy(info_ret[i]->cpumap, src->cpumap.cpumap_val, src->cpumap.cpumap_len); info_ret[i]->cpumaplen =3D src->cpumap.cpumap_len; @@ -2367,8 +2363,7 @@ remoteDomainGetSecurityLabelList(virDomainPtr domain,= virSecurityLabelPtr* secla goto done; } =20 - if (VIR_ALLOC_N(*seclabels, ret.labels.labels_len) < 0) - goto cleanup; + *seclabels =3D g_new0(virSecurityLabel, ret.labels.labels_len); =20 for (i =3D 0; i < ret.labels.labels_len; i++) { remote_domain_get_security_label_ret *cur =3D &ret.labels.labels_v= al[i]; @@ -3766,8 +3761,7 @@ static sasl_callback_t *remoteAuthMakeCallbacks(int *= credtype, int ncredtype) sasl_callback_t *cbs; size_t i; int n; - if (VIR_ALLOC_N(cbs, ncredtype+1) < 0) - return NULL; + cbs =3D g_new0(sasl_callback_t, ncredtype + 1); =20 for (i =3D 0, n =3D 0; i < ncredtype; i++) { int id =3D remoteAuthCredVir2SASL(credtype[i]); @@ -3804,8 +3798,7 @@ static int remoteAuthMakeCredentials(sasl_interact_t = *interact, (*ncred)++; } =20 - if (VIR_ALLOC_N(*cred, *ncred) < 0) - return -1; + *cred =3D g_new0(virConnectCredential, *ncred); =20 for (ninteract =3D 0, *ncred =3D 0; interact[ninteract].id !=3D 0; nin= teract++) { if (interact[ninteract].result) @@ -4665,22 +4658,18 @@ remoteDomainBuildEventGraphicsHelper(virConnectPtr = conn, if (!dom) return; =20 - if (VIR_ALLOC(localAddr) < 0) - goto error; + localAddr =3D g_new0(virDomainEventGraphicsAddress, 1); localAddr->family =3D msg->local.family; localAddr->service =3D g_strdup(msg->local.service); localAddr->node =3D g_strdup(msg->local.node); =20 - if (VIR_ALLOC(remoteAddr) < 0) - goto error; + remoteAddr =3D g_new0(virDomainEventGraphicsAddress, 1); remoteAddr->family =3D msg->remote.family; remoteAddr->service =3D g_strdup(msg->remote.service); remoteAddr->node =3D g_strdup(msg->remote.node); =20 - if (VIR_ALLOC(subject) < 0) - goto error; - if (VIR_ALLOC_N(subject->identities, msg->subject.subject_len) < 0) - goto error; + subject =3D g_new0(virDomainEventGraphicsSubject, 1); + subject->identities =3D g_new0(virDomainEventGraphicsSubjectIdentity, = msg->subject.subject_len); subject->nidentity =3D msg->subject.subject_len; for (i =3D 0; i < subject->nidentity; i++) { subject->identities[i].type =3D g_strdup(msg->subject.subject_val[= i].type); @@ -4698,28 +4687,6 @@ remoteDomainBuildEventGraphicsHelper(virConnectPtr c= onn, =20 virObjectEventStateQueueRemote(priv->eventState, event, callbackID); return; - - error: - if (localAddr) { - VIR_FREE(localAddr->service); - VIR_FREE(localAddr->node); - VIR_FREE(localAddr); - } - if (remoteAddr) { - VIR_FREE(remoteAddr->service); - VIR_FREE(remoteAddr->node); - VIR_FREE(remoteAddr); - } - if (subject) { - for (i =3D 0; i < subject->nidentity; i++) { - VIR_FREE(subject->identities[i].type); - VIR_FREE(subject->identities[i].name); - } - VIR_FREE(subject->identities); - VIR_FREE(subject); - } - virObjectUnref(dom); - return; } static void remoteDomainBuildEventGraphics(virNetClientProgramPtr prog G_GNUC_UNUSED, @@ -5640,8 +5607,7 @@ remoteStreamEventAddCallback(virStreamPtr st, int ret =3D -1; struct remoteStreamCallbackData *cbdata; =20 - if (VIR_ALLOC(cbdata) < 0) - return -1; + cbdata =3D g_new0(struct remoteStreamCallbackData, 1); cbdata->cb =3D cb; cbdata->opaque =3D opaque; cbdata->ff =3D ff; @@ -6304,8 +6270,7 @@ remoteConnectGetCPUModelNames(virConnectPtr conn, } =20 if (models) { - if (VIR_ALLOC_N(retmodels, ret.models.models_len + 1) < 0) - goto cleanup; + retmodels =3D g_new0(char *, ret.models.models_len + 1); =20 for (i =3D 0; i < ret.models.models_len; i++) { retmodels[i] =3D ret.models.models_val[i]; @@ -6738,8 +6703,7 @@ remoteNodeGetCPUMap(virConnectPtr conn, goto cleanup; =20 if (cpumap) { - if (VIR_ALLOC_N(*cpumap, ret.cpumap.cpumap_len) < 0) - goto cleanup; + *cpumap =3D g_new0(unsigned char, ret.cpumap.cpumap_len); memcpy(*cpumap, ret.cpumap.cpumap_val, ret.cpumap.cpumap_len); } =20 @@ -7467,13 +7431,11 @@ remoteNetworkGetDHCPLeases(virNetworkPtr net, } =20 if (leases) { - if (ret.leases.leases_len && - VIR_ALLOC_N(leases_ret, ret.leases.leases_len + 1) < 0) - goto cleanup; + if (ret.leases.leases_len) + leases_ret =3D g_new0(virNetworkDHCPLeasePtr, ret.leases.lease= s_len + 1); =20 for (i =3D 0; i < ret.leases.leases_len; i++) { - if (VIR_ALLOC(leases_ret[i]) < 0) - goto cleanup; + leases_ret[i] =3D g_new0(virNetworkDHCPLease, 1); =20 if (remoteSerializeDHCPLease(leases_ret[i], &ret.leases.leases= _val[i]) < 0) goto cleanup; @@ -7519,8 +7481,7 @@ remoteConnectGetAllDomainStats(virConnectPtr conn, memset(&args, 0, sizeof(args)); =20 if (ndoms) { - if (VIR_ALLOC_N(args.doms.doms_val, ndoms) < 0) - goto cleanup; + args.doms.doms_val =3D g_new0(remote_nonnull_domain, ndoms); =20 for (i =3D 0; i < ndoms; i++) make_nonnull_domain(args.doms.doms_val + i, doms[i]); @@ -7550,14 +7511,12 @@ remoteConnectGetAllDomainStats(virConnectPtr conn, =20 *retStats =3D NULL; =20 - if (VIR_ALLOC_N(tmpret, ret.retStats.retStats_len + 1) < 0) - goto cleanup; + tmpret =3D g_new0(virDomainStatsRecordPtr, ret.retStats.retStats_len += 1); =20 for (i =3D 0; i < ret.retStats.retStats_len; i++) { remote_domain_stats_record *rec =3D ret.retStats.retStats_val + i; =20 - if (VIR_ALLOC(elem) < 0) - goto cleanup; + elem =3D g_new0(virDomainStatsRecord, 1); =20 if (!(elem->dom =3D get_nonnull_domain(conn, rec->dom))) goto cleanup; @@ -7676,14 +7635,13 @@ remoteDomainGetFSInfo(virDomainPtr dom, goto cleanup; } =20 - if (VIR_ALLOC_N(info_ret, ret.info.info_len) < 0) + info_ret =3D g_new0(virDomainFSInfoPtr, ret.info.info_len); goto cleanup; =20 for (i =3D 0; i < ret.info.info_len; i++) { src =3D &ret.info.info_val[i]; =20 - if (VIR_ALLOC(info_ret[i]) < 0) - goto cleanup; + info_ret[i] =3D g_new0(virDomainFSInfo, 1); =20 info_ret[i]->mountpoint =3D g_strdup(src->mountpoint); =20 @@ -7693,9 +7651,8 @@ remoteDomainGetFSInfo(virDomainPtr dom, =20 len =3D src->dev_aliases.dev_aliases_len; info_ret[i]->ndevAlias =3D len; - if (len && - VIR_ALLOC_N(info_ret[i]->devAlias, len) < 0) - goto cleanup; + if (len) + info_ret[i]->devAlias =3D g_new0(char *, len); =20 for (j =3D 0; j < len; j++) info_ret[i]->devAlias[j] =3D g_strdup(src->dev_aliases.dev= _aliases_val[j]); @@ -7760,16 +7717,14 @@ remoteDomainInterfaceAddresses(virDomainPtr dom, goto cleanup; } =20 - if (ret.ifaces.ifaces_len && - VIR_ALLOC_N(ifaces_ret, ret.ifaces.ifaces_len) < 0) - goto cleanup; + if (ret.ifaces.ifaces_len) + ifaces_ret =3D g_new0(virDomainInterfacePtr, ret.ifaces.ifaces_len= ); =20 for (i =3D 0; i < ret.ifaces.ifaces_len; i++) { virDomainInterfacePtr iface; remote_domain_interface *iface_ret =3D &(ret.ifaces.ifaces_val[i]); =20 - if (VIR_ALLOC(ifaces_ret[i]) < 0) - goto cleanup; + ifaces_ret[i] =3D g_new0(virDomainInterface, 1); =20 iface =3D ifaces_ret[i]; =20 @@ -7788,8 +7743,7 @@ remoteDomainInterfaceAddresses(virDomainPtr dom, iface->naddrs =3D iface_ret->addrs.addrs_len; =20 if (iface->naddrs) { - if (VIR_ALLOC_N(iface->addrs, iface->naddrs) < 0) - goto cleanup; + iface->addrs =3D g_new0(virDomainIPAddress, iface->naddrs); =20 for (j =3D 0; j < iface->naddrs; j++) { virDomainIPAddressPtr ip_addr =3D &(iface->addrs[j]); --=20 2.26.2