From nobody Thu May 2 14:38:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1602098568; cv=none; d=zohomail.com; s=zohoarc; b=cnq4J8EvNiod888hYgQIg24YjrfQziyZERrp6iZSB9MAqvdptjFRr0Zgkw+GbRkafSjecg8EejvgzqMAxlwDXRJ6yyK7niaBk0xf2eeylQvxWhI8x9QrM3PAqmNDWAGYDPcHgfbk7kb79rKPOhS8qAg4b5XOGy62OywDGr6InB0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602098568; 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=DMDMua32ipuX/kgie+9lyeyL/PRF30RcB1gwHQZFbMY=; b=I0PfGU6aeWWI7B8pj/77dKezZVTNPgL5p/eI4EP4H1JdgtgyJSPhKTyj8BEVYQM+oodMH6AcArQQU4oBsUsPAlDy4HL3PVmRalC/g+2qMr7o/fESNGAdrwMWNCEPsYRHVkLJsiufeQge86mUkCH+aovlctbLCXXZnC+NHVAvOek= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1602098568029396.8028368207529; Wed, 7 Oct 2020 12:22:48 -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-370-sbyl2VpWOGaFAHr3GFn-HQ-1; Wed, 07 Oct 2020 15:22:44 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 11BFF1019625; Wed, 7 Oct 2020 19:22:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E5BE26EF43; Wed, 7 Oct 2020 19:22:37 +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 ADA1F1832FC4; Wed, 7 Oct 2020 19:22:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 097JMZ6x005876 for ; Wed, 7 Oct 2020 15:22:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0E7FF1001281; Wed, 7 Oct 2020 19:22:35 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D95E100238C for ; Wed, 7 Oct 2020 19:22:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602098566; 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=DMDMua32ipuX/kgie+9lyeyL/PRF30RcB1gwHQZFbMY=; b=RqigKtz/f8jbE4CJ+QHyngfTSIQSv2UQXLZDEBvHNkRvM7JfyJeLEUd9yRZc3V58skTlGU roFtp5+Pp00FRgTkMMGjpD+2uRrDfQsB5z3h5VaJxgaFS0qFMciz0Ob+o5B5yHC5eOXlJg 4EPJbZ8u2gd0aWjQYOAXY05wom5FBtM= X-MC-Unique: sbyl2VpWOGaFAHr3GFn-HQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 01/13] conf: domain: use g_new0 Date: Wed, 7 Oct 2020 21:22:17 +0200 Message-Id: <5446c683d936b97a8b418f7f77bed917ae4f005f.1602098503.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.13 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 Reviewed-by: Erik Skultety Reviewed-by: Neal Gompa --- src/conf/domain_conf.c | 347 ++++++++++++++++------------------------- 1 file changed, 132 insertions(+), 215 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c003b5c030..51efeb0e42 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1469,8 +1469,7 @@ virDomainKeyWrapDefParseXML(virDomainDefPtr def, xmlX= PathContextPtr ctxt) if ((n =3D virXPathNodeSet("./keywrap/cipher", ctxt, &nodes)) < 0) return n; =20 - if (VIR_ALLOC(keywrap) < 0) - return -1; + keywrap =3D g_new0(virDomainKeyWrapDef, 1); =20 for (i =3D 0; i < n; i++) { if (virDomainKeyWrapCipherDefParseXML(keywrap, nodes[i]) < 0) @@ -1559,8 +1558,7 @@ virDomainVirtioOptionsParseXML(xmlNodePtr driver, if (*virtio || !driver) return 0; =20 - if (VIR_ALLOC(*virtio) < 0) - return -1; + *virtio =3D g_new0(virDomainVirtioOptions, 1); =20 res =3D *virtio; =20 @@ -1912,8 +1910,7 @@ virDomainVcpuDefNew(virDomainXMLOptionPtr xmlopt) !(priv =3D xmlopt->privateData.vcpuNew())) return NULL; =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(virDomainVcpuDef, 1); =20 ret->privateData =3D g_steal_pointer(&priv); =20 @@ -2181,8 +2178,7 @@ virDomainDiskDefNew(virDomainXMLOptionPtr xmlopt) { virDomainDiskDefPtr ret; =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(virDomainDiskDef, 1); =20 ret->src =3D virStorageSourceNew(); =20 @@ -2303,8 +2299,7 @@ virDomainControllerDefNew(virDomainControllerType typ= e) { virDomainControllerDefPtr def; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virDomainControllerDef, 1); =20 def->type =3D type; =20 @@ -2393,8 +2388,7 @@ virDomainFSDefNew(virDomainXMLOptionPtr xmlopt) { virDomainFSDefPtr ret; =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(virDomainFSDef, 1); =20 ret->src =3D virStorageSourceNew(); =20 @@ -2460,8 +2454,7 @@ virDomainVsockDefNew(virDomainXMLOptionPtr xmlopt) virDomainVsockDefPtr ret =3D NULL; virDomainVsockDefPtr vsock; =20 - if (VIR_ALLOC(vsock) < 0) - return NULL; + vsock =3D g_new0(virDomainVsockDef, 1); =20 if (xmlopt && xmlopt->privateData.vsockNew && @@ -2938,8 +2931,7 @@ virDomainVideoDefNew(virDomainXMLOptionPtr xmlopt) { virDomainVideoDefPtr def; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virDomainVideoDef, 1); =20 if (xmlopt && xmlopt->privateData.videoNew && !(def->privateData =3D xmlopt->privateData.videoNew())) { @@ -2989,18 +2981,11 @@ virDomainHostdevDefNew(void) { virDomainHostdevDefPtr def; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virDomainHostdevDef, 1); =20 - if (VIR_ALLOC(def->info) < 0) - goto error; + def->info =3D g_new0(virDomainDeviceInfo, 1); =20 return def; - - error: - VIR_FREE(def->info); - VIR_FREE(def); - return NULL; } =20 =20 @@ -3329,8 +3314,7 @@ virDomainIOThreadIDDefArrayInit(virDomainDefPtr def, _("failed to populate iothreadids")); return -1; } - if (VIR_ALLOC(iothrid) < 0) - return -1; + iothrid =3D g_new0(virDomainIOThreadIDDef, 1); iothrid->iothread_id =3D nxt; iothrid->autofill =3D true; def->iothreadids[def->niothreadids++] =3D iothrid; @@ -3678,8 +3662,7 @@ virDomainDefNew(void) { virDomainDefPtr ret; =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(virDomainDef, 1); =20 if (!(ret->numa =3D virDomainNumaNew())) goto error; @@ -8761,8 +8744,7 @@ virDomainNetIPParseXML(xmlNodePtr node) else family =3D virSocketAddrNumericFamily(address); =20 - if (VIR_ALLOC(ip) < 0) - return NULL; + ip =3D g_new0(virNetDevIPAddr, 1); =20 if (virSocketAddrParse(&ip->address, address, family) < 0) { virReportError(VIR_ERR_XML_ERROR, @@ -8854,8 +8836,7 @@ virDomainNetDefCoalesceParseXML(xmlNodePtr node, if (!str) return NULL; =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(virNetDevCoalesce, 1); =20 if (virStrToLong_ullp(str, NULL, 10, &tmp) < 0) { virReportError(VIR_ERR_XML_DETAIL, @@ -9226,8 +9207,7 @@ virSecurityLabelDefsParseXML(virDomainDefPtr def, if (n =3D=3D 0) return 0; =20 - if (VIR_ALLOC_N(def->seclabels, n) < 0) - goto error; + def->seclabels =3D g_new0(virSecurityLabelDefPtr, n); =20 /* Parse each "seclabel" tag */ for (i =3D 0; i < n; i++) { @@ -9326,13 +9306,10 @@ virSecurityDeviceLabelDefParseXML(virSecurityDevice= LabelDefPtr **seclabels_rtn, if (n =3D=3D 0) return 0; =20 - if (VIR_ALLOC_N(seclabels, n) < 0) - goto error; + seclabels =3D g_new0(virSecurityDeviceLabelDefPtr, n); nseclabels =3D n; - for (i =3D 0; i < n; i++) { - if (VIR_ALLOC(seclabels[i]) < 0) - goto error; - } + for (i =3D 0; i < n; i++) + seclabels[i] =3D g_new0(virSecurityDeviceLabelDef, 1); =20 for (i =3D 0; i < n; i++) { /* get model associated to this override */ @@ -9409,8 +9386,7 @@ virDomainLeaseDefParseXML(xmlNodePtr node) g_autofree char *path =3D NULL; g_autofree char *offset =3D NULL; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virDomainLeaseDef, 1); =20 cur =3D node->children; while (cur !=3D NULL) { @@ -9470,8 +9446,7 @@ virDomainDiskSourcePoolDefParse(xmlNodePtr node, =20 *srcpool =3D NULL; =20 - if (VIR_ALLOC(source) < 0) - return -1; + source =3D g_new0(virStorageSourcePoolDef, 1); =20 source->pool =3D virXMLPropString(node, "pool"); source->volume =3D virXMLPropString(node, "volume"); @@ -11744,8 +11719,7 @@ virDomainActualNetDefParseXML(xmlNodePtr node, g_autofree char *trustGuestRxFilters =3D NULL; g_autofree char *macTableManager =3D NULL; =20 - if (VIR_ALLOC(actual) < 0) - return -1; + actual =3D g_new0(virDomainActualNetDef, 1); =20 ctxt->node =3D node; =20 @@ -11910,8 +11884,7 @@ virDomainNetAppendIPAddress(virDomainNetDefPtr def, unsigned int prefix) { virNetDevIPAddrPtr ipDef =3D NULL; - if (VIR_ALLOC(ipDef) < 0) - return -1; + ipDef =3D g_new0(virNetDevIPAddr, 1); =20 if (virSocketAddrParse(&ipDef->address, address, family) < 0) goto error; @@ -12955,8 +12928,7 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr de= f, addrStr =3D virXMLPropString(cur, "address"); portStr =3D virXMLPropString(cur, "port"); =20 - if (VIR_ALLOC(def->target.addr) < 0) - return -1; + def->target.addr =3D g_new0(virSocketAddr, 1); =20 if (addrStr =3D=3D NULL) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -13389,8 +13361,7 @@ virDomainChrDefNew(virDomainXMLOptionPtr xmlopt) { virDomainChrDefPtr def =3D NULL; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virDomainChrDef, 1); =20 def->target.port =3D -1; =20 @@ -13537,8 +13508,7 @@ virDomainSmartcardDefParseXML(virDomainXMLOptionPtr= xmlopt, g_autofree char *mode =3D NULL; g_autofree char *type =3D NULL; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virDomainSmartcardDef, 1); =20 mode =3D virXMLPropString(node, "mode"); if (mode =3D=3D NULL) { @@ -13689,8 +13659,7 @@ virDomainTPMDefParseXML(virDomainXMLOptionPtr xmlop= t, g_autofree char *secretuuid =3D NULL; g_autofree xmlNodePtr *backends =3D NULL; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virDomainTPMDef, 1); =20 model =3D virXMLPropString(node, "model"); if (model !=3D NULL && @@ -13783,8 +13752,7 @@ virDomainPanicDefParseXML(virDomainXMLOptionPtr xml= opt, virDomainPanicDefPtr panic; g_autofree char *model =3D NULL; =20 - if (VIR_ALLOC(panic) < 0) - return NULL; + panic =3D g_new0(virDomainPanicDef, 1); =20 if (virDomainDeviceInfoParseXML(xmlopt, node, &panic->info, flags) < 0) @@ -13820,8 +13788,7 @@ virDomainInputDefParseXML(virDomainXMLOptionPtr xml= opt, g_autofree char *bus =3D NULL; g_autofree char *model =3D NULL; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virDomainInputDef, 1); =20 ctxt->node =3D node; =20 @@ -13974,8 +13941,7 @@ virDomainHubDefParseXML(virDomainXMLOptionPtr xmlop= t, virDomainHubDefPtr def; g_autofree char *type =3D NULL; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virDomainHubDef, 1); =20 type =3D virXMLPropString(node, "type"); =20 @@ -14017,8 +13983,7 @@ virDomainTimerDefParseXML(xmlNodePtr node, g_autofree char *track =3D NULL; g_autofree char *mode =3D NULL; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virDomainTimerDef, 1); =20 ctxt->node =3D node; =20 @@ -14372,8 +14337,7 @@ virDomainGraphicsListensParseXML(virDomainGraphicsD= efPtr def, if (nListens > 0) { size_t i; =20 - if (VIR_ALLOC_N(def->listens, nListens) < 0) - goto cleanup; + def->listens =3D g_new0(virDomainGraphicsListenDef, nListens); =20 for (i =3D 0; i < nListens; i++) { if (virDomainGraphicsListenDefParseXML(&def->listens[i], def, @@ -14918,8 +14882,7 @@ virDomainGraphicsDefNew(virDomainXMLOptionPtr xmlop= t) { virDomainGraphicsDefPtr def =3D NULL; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virDomainGraphicsDef, 1); =20 if (xmlopt && xmlopt->privateData.graphicsNew && !(def->privateData =3D xmlopt->privateData.graphicsNew())) { @@ -14936,8 +14899,7 @@ virDomainNetDefNew(virDomainXMLOptionPtr xmlopt) { virDomainNetDefPtr def =3D NULL; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virDomainNetDef, 1); =20 if (xmlopt && xmlopt->privateData.networkNew && !(def->privateData =3D xmlopt->privateData.networkNew())) { @@ -15021,8 +14983,7 @@ virDomainSoundCodecDefParseXML(xmlNodePtr node) virDomainSoundCodecDefPtr def; g_autofree char *type =3D NULL; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virDomainSoundCodecDef, 1); =20 type =3D virXMLPropString(node, "type"); if ((def->type =3D virDomainSoundCodecTypeFromString(type)) < 0) { @@ -15050,8 +15011,7 @@ virDomainSoundDefParseXML(virDomainXMLOptionPtr xml= opt, g_autofree char *model =3D NULL; xmlNodePtr audioNode; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virDomainSoundDef, 1); ctxt->node =3D node; =20 model =3D virXMLPropString(node, "model"); @@ -15074,8 +15034,7 @@ virDomainSoundDefParseXML(virDomainXMLOptionPtr xml= opt, if (ncodecs > 0) { size_t i; =20 - if (VIR_ALLOC_N(def->codecs, ncodecs) < 0) - goto error; + def->codecs =3D g_new0(virDomainSoundCodecDefPtr, ncodecs); =20 for (i =3D 0; i < ncodecs; i++) { virDomainSoundCodecDefPtr codec =3D virDomainSoundCodecDef= ParseXML(codecNodes[i]); @@ -15161,8 +15120,7 @@ virDomainAudioDefParseXML(virDomainXMLOptionPtr xml= opt G_GNUC_UNUSED, g_autofree char *tmp =3D NULL; g_autofree char *type =3D NULL; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virDomainAudioDef, 1); ctxt->node =3D node; =20 type =3D virXMLPropString(node, "type"); @@ -15218,8 +15176,7 @@ virDomainWatchdogDefParseXML(virDomainXMLOptionPtr = xmlopt, g_autofree char *model =3D NULL; g_autofree char *action =3D NULL; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virDomainWatchdogDef, 1); =20 model =3D virXMLPropString(node, "model"); if (model =3D=3D NULL) { @@ -15271,8 +15228,7 @@ virDomainRNGDefParseXML(virDomainXMLOptionPtr xmlop= t, g_autofree char *backend =3D NULL; g_autofree char *type =3D NULL; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virDomainRNGDef, 1); =20 if (!(model =3D virXMLPropString(node, "model"))) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing RNG device mode= l")); @@ -15382,8 +15338,7 @@ virDomainMemballoonDefParseXML(virDomainXMLOptionPt= r xmlopt, g_autofree char *model =3D NULL; g_autofree char *deflate =3D NULL; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virDomainMemballoonDef, 1); =20 model =3D virXMLPropString(node, "model"); if (model =3D=3D NULL) { @@ -15440,8 +15395,7 @@ virDomainNVRAMDefParseXML(virDomainXMLOptionPtr xml= opt, { virDomainNVRAMDefPtr def; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virDomainNVRAMDef, 1); =20 if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0) goto error; @@ -15466,8 +15420,7 @@ virDomainShmemDefParseXML(virDomainXMLOptionPtr xml= opt, xmlNodePtr server =3D NULL; g_autofree char *tmp =3D NULL; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virDomainShmemDef, 1); =20 ctxt->node =3D node; =20 @@ -15577,8 +15530,7 @@ virSysinfoBIOSParseXML(xmlNodePtr node, return ret; } =20 - if (VIR_ALLOC(def) < 0) - goto cleanup; + def =3D g_new0(virSysinfoBIOSDef, 1); =20 def->vendor =3D virXPathString("string(entry[@name=3D'vendor'])", ctxt= ); def->version =3D virXPathString("string(entry[@name=3D'version'])", ct= xt); @@ -15641,8 +15593,7 @@ virSysinfoSystemParseXML(xmlNodePtr node, return ret; } =20 - if (VIR_ALLOC(def) < 0) - goto cleanup; + def =3D g_new0(virSysinfoSystemDef, 1); =20 def->manufacturer =3D virXPathString("string(entry[@name=3D'manufacturer'])", ctxt); @@ -15710,8 +15661,8 @@ virSysinfoBaseBoardParseXML(xmlXPathContextPtr ctxt, if ((n =3D virXPathNodeSet("./baseBoard", ctxt, &nodes)) < 0) return -1; =20 - if (n && VIR_ALLOC_N(boards, n) < 0) - return -1; + if (n) + boards =3D g_new0(virSysinfoBaseBoardDef, n); =20 for (i =3D 0; i < n; i++) { virSysinfoBaseBoardDefPtr def =3D boards + nboards; @@ -15766,11 +15717,9 @@ virSysinfoOEMStringsParseXML(xmlNodePtr node, if (nstrings =3D=3D 0) return 0; =20 - if (VIR_ALLOC(def) < 0) - goto cleanup; + def =3D g_new0(virSysinfoOEMStringsDef, 1); =20 - if (VIR_ALLOC_N(def->values, nstrings) < 0) - goto cleanup; + def->values =3D g_new0(char *, nstrings); =20 def->nvalues =3D nstrings; for (i =3D 0; i < nstrings; i++) { @@ -15803,8 +15752,7 @@ virSysinfoChassisParseXML(xmlNodePtr node, return ret; } =20 - if (VIR_ALLOC(def) < 0) - goto cleanup; + def =3D g_new0(virSysinfoChassisDef, 1); =20 def->manufacturer =3D virXPathString("string(entry[@name=3D'manufacturer'])", ctxt); @@ -15825,7 +15773,6 @@ virSysinfoChassisParseXML(xmlNodePtr node, =20 *chassisdef =3D g_steal_pointer(&def); ret =3D 0; - cleanup: virSysinfoChassisDefFree(def); return ret; } @@ -15951,8 +15898,7 @@ virSysinfoParseXML(xmlNodePtr node, return NULL; } =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virSysinfoDef, 1); =20 typeStr =3D virXMLPropString(node, "type"); if (typeStr =3D=3D NULL) { @@ -16130,8 +16076,7 @@ virDomainVideoDriverDefParseXML(xmlNodePtr node) if (!vgaconf) return NULL; =20 - if (VIR_ALLOC(def) < 0) - return def; + def =3D g_new0(virDomainVideoDriverDef, 1); =20 if ((val =3D virDomainVideoVGAConfTypeFromString(vgaconf)) <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -16385,8 +16330,7 @@ virDomainRedirdevDefParseXML(virDomainXMLOptionPtr = xmlopt, g_autofree char *bus =3D NULL; g_autofree char *type =3D NULL; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virDomainRedirdevDef, 1); =20 if (!(def->source =3D virDomainChrSourceDefNew(xmlopt))) goto error; @@ -16492,8 +16436,7 @@ virDomainRedirFilterUSBDevDefParseXML(xmlNodePtr no= de) g_autofree char *version =3D NULL; g_autofree char *allow =3D NULL; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virDomainRedirFilterUSBDevDef, 1); =20 class =3D virXMLPropString(node, "class"); if (class) { @@ -16574,15 +16517,14 @@ virDomainRedirFilterDefParseXML(xmlNodePtr node, virDomainRedirFilterDefPtr def =3D NULL; g_autofree xmlNodePtr *nodes =3D NULL; =20 - if (VIR_ALLOC(def) < 0) - goto error; + def =3D g_new0(virDomainRedirFilterDef, 1); =20 ctxt->node =3D node; if ((n =3D virXPathNodeSet("./usbdev", ctxt, &nodes)) < 0) goto error; =20 - if (n && VIR_ALLOC_N(def->usbdevs, n) < 0) - goto error; + if (n) + def->usbdevs =3D g_new0(virDomainRedirFilterUSBDevDefPtr, n); =20 for (i =3D 0; i < n; i++) { virDomainRedirFilterUSBDevDefPtr usbdev =3D @@ -16815,8 +16757,7 @@ virDomainSEVDefParseXML(xmlNodePtr sevNode, unsigned long policy; g_autofree char *type =3D NULL; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virDomainSEVDef, 1); =20 ctxt->node =3D sevNode; =20 @@ -16918,8 +16859,7 @@ virDomainMemoryDefParseXML(virDomainXMLOptionPtr xm= lopt, int val; g_autofree char *tmp =3D NULL; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virDomainMemoryDef, 1); =20 ctxt->node =3D memdevNode; =20 @@ -17015,8 +16955,7 @@ virDomainIOMMUDefParseXML(xmlNodePtr node, =20 ctxt->node =3D node; =20 - if (VIR_ALLOC(iommu) < 0) - return NULL; + iommu =3D g_new0(virDomainIOMMUDef, 1); =20 if (!(tmp =3D virXMLPropString(node, "model"))) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -17156,8 +17095,7 @@ virDomainDeviceDefParse(const char *xmlStr, =20 node =3D ctxt->node; =20 - if (VIR_ALLOC(dev) < 0) - return NULL; + dev =3D g_new0(virDomainDeviceDef, 1); =20 if ((dev->type =3D virDomainDeviceTypeFromString((const char *) node->= name)) < 0) { /* Some crazy mapping of serial, parallel, console and channel to @@ -18016,14 +17954,14 @@ virDomainNetDHCPInterfaces(virDomainDefPtr def, goto error; =20 if (n_leases) { - ifaces_ret =3D g_renew(typeof(*ifaces_ret), ifaces_ret, ifaces= _count + 1); - ifaces_ret[ifaces_count] =3D g_new0(typeof(**ifaces_ret), 1); + ifaces_ret =3D g_renew(virDomainInterfacePtr, ifaces_ret, ifac= es_count + 1); + ifaces_ret[ifaces_count] =3D g_new0(virDomainInterface, 1); iface =3D ifaces_ret[ifaces_count]; ifaces_count++; =20 /* Assuming each lease corresponds to a separate IP */ iface->naddrs =3D n_leases; - iface->addrs =3D g_new0(typeof(*iface->addrs), iface->naddrs); + iface->addrs =3D g_new0(virDomainIPAddress, iface->naddrs); iface->name =3D g_strdup(def->nets[i]->ifname); iface->hwaddr =3D g_strdup(macaddr); } @@ -18078,15 +18016,13 @@ virDomainNetARPInterfaces(virDomainDefPtr def, virArpTableEntry entry =3D table->t[j]; =20 if (STREQ(entry.mac, macaddr)) { - if (VIR_ALLOC(iface) < 0) - goto cleanup; + iface =3D g_new0(virDomainInterface, 1); =20 iface->name =3D g_strdup(def->nets[i]->ifname); =20 iface->hwaddr =3D g_strdup(macaddr); =20 - if (VIR_ALLOC(iface->addrs) < 0) - goto cleanup; + iface->addrs =3D g_new0(virDomainIPAddress, 1); iface->naddrs =3D 1; =20 iface->addrs->addr =3D g_strdup(entry.ipaddr); @@ -19037,8 +18973,7 @@ virDomainIdmapDefParseXML(xmlXPathContextPtr ctxt, virDomainIdMapEntryPtr idmap =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) =20 - if (VIR_ALLOC_N(idmap, num) < 0) - return idmap; + idmap =3D g_new0(virDomainIdMapEntry, num); =20 for (i =3D 0; i < num; i++) { ctxt->node =3D node[i]; @@ -19084,8 +19019,7 @@ virDomainIOThreadIDDefParseXML(xmlNodePtr node) virDomainIOThreadIDDefPtr iothrid; g_autofree char *tmp =3D NULL; =20 - if (VIR_ALLOC(iothrid) < 0) - return NULL; + iothrid =3D g_new0(virDomainIOThreadIDDef, 1); =20 if (!(tmp =3D virXMLPropString(node, "id"))) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -19132,8 +19066,8 @@ virDomainDefParseIOThreads(virDomainDefPtr def, if (n > iothreads) iothreads =3D n; =20 - if (n && VIR_ALLOC_N(def->iothreadids, n) < 0) - return -1; + if (n) + def->iothreadids =3D g_new0(virDomainIOThreadIDDefPtr, n); =20 for (i =3D 0; i < n; i++) { virDomainIOThreadIDDefPtr iothrid =3D NULL; @@ -19414,8 +19348,7 @@ virDomainDefMaybeAddInput(virDomainDefPtr def, return 0; } =20 - if (VIR_ALLOC(input) < 0) - return -1; + input =3D g_new0(virDomainInputDef, 1); =20 input->type =3D type; input->bus =3D bus; @@ -19474,8 +19407,7 @@ virDomainResourceDefParse(xmlNodePtr node, =20 ctxt->node =3D node; =20 - if (VIR_ALLOC(def) < 0) - goto error; + def =3D g_new0(virDomainResourceDef, 1); =20 /* Find out what type of virtualization to use */ if (!(def->partition =3D virXPathString("string(./partition)", ctxt)))= { @@ -20160,8 +20092,7 @@ virDomainEmulatorSchedParse(xmlNodePtr node, { g_autofree virDomainThreadSchedParamPtr sched =3D NULL; =20 - if (VIR_ALLOC(sched) < 0) - return -1; + sched =3D g_new0(virDomainThreadSchedParam, 1); =20 if (virDomainSchedulerParseCommonAttrs(node, &sched->policy, @@ -20464,8 +20395,7 @@ virDomainDefParseBootOptions(virDomainDefPtr def, if ((n =3D virXPathNodeSet("./os/initarg", ctxt, &nodes)) < 0) return -1; =20 - if (VIR_ALLOC_N(def->os.initargv, n+1) < 0) - return -1; + def->os.initargv =3D g_new0(char *, n+1); for (i =3D 0; i < n; i++) { if (!nodes[i]->children || !nodes[i]->children->content) { @@ -20481,8 +20411,7 @@ virDomainDefParseBootOptions(virDomainDefPtr def, if ((n =3D virXPathNodeSet("./os/initenv", ctxt, &nodes)) < 0) return -1; =20 - if (VIR_ALLOC_N(def->os.initenv, n+1) < 0) - return -1; + def->os.initenv =3D g_new0(virDomainOSEnvPtr, n+1); for (i =3D 0; i < n; i++) { if (!(name =3D virXMLPropString(nodes[i], "name"))) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -20498,9 +20427,7 @@ virDomainDefParseBootOptions(virDomainDefPtr def, return -1; } =20 - if (VIR_ALLOC(def->os.initenv[i]) < 0) - return -1; - + def->os.initenv[i] =3D g_new0(virDomainOSEnv, 1); def->os.initenv[i]->name =3D name; def->os.initenv[i]->value =3D g_strdup((const char *)nodes[i]-= >children->content); } @@ -20538,8 +20465,7 @@ virDomainDefParseBootOptions(virDomainDefPtr def, if ((loader_node =3D virXPathNode("./os/loader[1]", ctxt))) { const bool fwAutoSelect =3D def->os.firmware !=3D VIR_DOMAIN_O= S_DEF_FIRMWARE_NONE; =20 - if (VIR_ALLOC(def->os.loader) < 0) - return -1; + def->os.loader =3D g_new0(virDomainLoaderDef, 1); =20 if (virDomainLoaderDefParseXML(loader_node, def->os.loader, @@ -20814,8 +20740,7 @@ virDomainResctrlMonDefParse(virDomainDefPtr def, } =20 for (i =3D 0; i < n; i++) { - if (VIR_ALLOC(domresmon) < 0) - goto cleanup; + domresmon =3D g_new0(virDomainResctrlMonDef, 1); =20 domresmon->tag =3D tag; =20 @@ -21229,8 +21154,7 @@ virDomainDefParseMemory(virDomainDefPtr def, } =20 if (n) { - if (VIR_ALLOC_N(def->mem.hugepages, n) < 0) - goto error; + def->mem.hugepages =3D g_new0(virDomainHugePage, n); =20 for (i =3D 0; i < n; i++) { if (virDomainHugepagesParseXML(nodes[i], ctxt, @@ -21242,9 +21166,7 @@ virDomainDefParseMemory(virDomainDefPtr def, VIR_FREE(nodes); } else { /* no hugepage pages */ - if (VIR_ALLOC(def->mem.hugepages) < 0) - goto error; - + def->mem.hugepages =3D g_new0(virDomainHugePage, 1); def->mem.nhugepages =3D 1; } } @@ -21413,8 +21335,8 @@ virDomainDefTunablesParse(virDomainDefPtr def, "%s", _("cannot extract blkiotune nodes")); goto error; } - if (n && VIR_ALLOC_N(def->blkio.devices, n) < 0) - goto error; + if (n) + def->blkio.devices =3D g_new0(virBlkioDevice, n); =20 for (i =3D 0; i < n; i++) { if (virDomainBlkioDeviceParseXML(nodes[i], @@ -21768,8 +21690,8 @@ virDomainDefClockParse(virDomainDefPtr def, if ((n =3D virXPathNodeSet("./clock/timer", ctxt, &nodes)) < 0) goto error; =20 - if (n && VIR_ALLOC_N(def->clock.timers, n) < 0) - goto error; + if (n) + def->clock.timers =3D g_new0(virDomainTimerDefPtr, n); =20 for (i =3D 0; i < n; i++) { virDomainTimerDefPtr timer =3D virDomainTimerDefParseXML(nodes[i], @@ -21803,8 +21725,8 @@ virDomainDefControllersParse(virDomainDefPtr def, if ((n =3D virXPathNodeSet("./devices/controller", ctxt, &nodes)) < 0) goto error; =20 - if (n && VIR_ALLOC_N(def->controllers, n) < 0) - goto error; + if (n) + def->controllers =3D g_new0(virDomainControllerDefPtr, n); =20 for (i =3D 0; i < n; i++) { virDomainControllerDefPtr controller =3D virDomainControllerDefPar= seXML(xmlopt, @@ -21985,8 +21907,8 @@ virDomainDefParseXML(xmlDocPtr xml, if ((n =3D virXPathNodeSet("./devices/disk", ctxt, &nodes)) < 0) goto error; =20 - if (n && VIR_ALLOC_N(def->disks, n) < 0) - goto error; + if (n) + def->disks =3D g_new0(virDomainDiskDefPtr, n); =20 for (i =3D 0; i < n; i++) { virDomainDiskDefPtr disk =3D virDomainDiskDefParseXML(xmlopt, @@ -22009,8 +21931,8 @@ virDomainDefParseXML(xmlDocPtr xml, "%s", _("cannot extract device leases")); goto error; } - if (n && VIR_ALLOC_N(def->leases, n) < 0) - goto error; + if (n) + def->leases =3D g_new0(virDomainLeaseDefPtr, n); for (i =3D 0; i < n; i++) { virDomainLeaseDefPtr lease =3D virDomainLeaseDefParseXML(nodes[i]); if (!lease) @@ -22023,8 +21945,8 @@ virDomainDefParseXML(xmlDocPtr xml, /* analysis of the filesystems */ if ((n =3D virXPathNodeSet("./devices/filesystem", ctxt, &nodes)) < 0) goto error; - if (n && VIR_ALLOC_N(def->fss, n) < 0) - goto error; + if (n) + def->fss =3D g_new0(virDomainFSDefPtr, n); for (i =3D 0; i < n; i++) { virDomainFSDefPtr fs =3D virDomainFSDefParseXML(xmlopt, nodes[i], @@ -22040,8 +21962,8 @@ virDomainDefParseXML(xmlDocPtr xml, /* analysis of the network devices */ if ((n =3D virXPathNodeSet("./devices/interface", ctxt, &nodes)) < 0) goto error; - if (n && VIR_ALLOC_N(def->nets, n) < 0) - goto error; + if (n) + def->nets =3D g_new0(virDomainNetDefPtr, n); for (i =3D 0; i < n; i++) { virDomainNetDefPtr net =3D virDomainNetDefParseXML(xmlopt, nodes[i], @@ -22067,8 +21989,8 @@ virDomainDefParseXML(xmlDocPtr xml, /* analysis of the smartcard devices */ if ((n =3D virXPathNodeSet("./devices/smartcard", ctxt, &nodes)) < 0) goto error; - if (n && VIR_ALLOC_N(def->smartcards, n) < 0) - goto error; + if (n) + def->smartcards =3D g_new0(virDomainSmartcardDefPtr, n); =20 for (i =3D 0; i < n; i++) { virDomainSmartcardDefPtr card =3D virDomainSmartcardDefParseXML(xm= lopt, @@ -22086,8 +22008,8 @@ virDomainDefParseXML(xmlDocPtr xml, /* analysis of the character devices */ if ((n =3D virXPathNodeSet("./devices/parallel", ctxt, &nodes)) < 0) goto error; - if (n && VIR_ALLOC_N(def->parallels, n) < 0) - goto error; + if (n) + def->parallels =3D g_new0(virDomainChrDefPtr, n); =20 for (i =3D 0; i < n; i++) { virDomainChrDefPtr chr =3D virDomainChrDefParseXML(xmlopt, @@ -22112,8 +22034,8 @@ virDomainDefParseXML(xmlDocPtr xml, if ((n =3D virXPathNodeSet("./devices/serial", ctxt, &nodes)) < 0) goto error; =20 - if (n && VIR_ALLOC_N(def->serials, n) < 0) - goto error; + if (n) + def->serials =3D g_new0(virDomainChrDefPtr, n); =20 for (i =3D 0; i < n; i++) { virDomainChrDefPtr chr =3D virDomainChrDefParseXML(xmlopt, @@ -22140,8 +22062,8 @@ virDomainDefParseXML(xmlDocPtr xml, "%s", _("cannot extract console devices")); goto error; } - if (n && VIR_ALLOC_N(def->consoles, n) < 0) - goto error; + if (n) + def->consoles =3D g_new0(virDomainChrDefPtr, n); =20 for (i =3D 0; i < n; i++) { virDomainChrDefPtr chr =3D virDomainChrDefParseXML(xmlopt, @@ -22158,8 +22080,8 @@ virDomainDefParseXML(xmlDocPtr xml, =20 if ((n =3D virXPathNodeSet("./devices/channel", ctxt, &nodes)) < 0) goto error; - if (n && VIR_ALLOC_N(def->channels, n) < 0) - goto error; + if (n) + def->channels =3D g_new0(virDomainChrDefPtr, n); =20 for (i =3D 0; i < n; i++) { virDomainChrDefPtr chr =3D virDomainChrDefParseXML(xmlopt, @@ -22177,8 +22099,8 @@ virDomainDefParseXML(xmlDocPtr xml, /* analysis of the input devices */ if ((n =3D virXPathNodeSet("./devices/input", ctxt, &nodes)) < 0) goto error; - if (n && VIR_ALLOC_N(def->inputs, n) < 0) - goto error; + if (n) + def->inputs =3D g_new0(virDomainInputDefPtr, n); =20 for (i =3D 0; i < n; i++) { virDomainInputDefPtr input =3D virDomainInputDefParseXML(xmlopt, @@ -22205,8 +22127,8 @@ virDomainDefParseXML(xmlDocPtr xml, /* analysis of the graphics devices */ if ((n =3D virXPathNodeSet("./devices/graphics", ctxt, &nodes)) < 0) goto error; - if (n && VIR_ALLOC_N(def->graphics, n) < 0) - goto error; + if (n) + def->graphics =3D g_new0(virDomainGraphicsDefPtr, n); for (i =3D 0; i < n; i++) { virDomainGraphicsDefPtr graphics =3D virDomainGraphicsDefParseXML(= xmlopt, no= des[i], @@ -22222,8 +22144,8 @@ virDomainDefParseXML(xmlDocPtr xml, /* analysis of the sound devices */ if ((n =3D virXPathNodeSet("./devices/sound", ctxt, &nodes)) < 0) goto error; - if (n && VIR_ALLOC_N(def->sounds, n) < 0) - goto error; + if (n) + def->sounds =3D g_new0(virDomainSoundDefPtr, n); for (i =3D 0; i < n; i++) { virDomainSoundDefPtr sound =3D virDomainSoundDefParseXML(xmlopt, nodes[i], @@ -22239,8 +22161,8 @@ virDomainDefParseXML(xmlDocPtr xml, /* analysis of the audio devices */ if ((n =3D virXPathNodeSet("./devices/audio", ctxt, &nodes)) < 0) goto error; - if (n && VIR_ALLOC_N(def->audios, n) < 0) - goto error; + if (n) + def->audios =3D g_new0(virDomainAudioDefPtr, n); for (i =3D 0; i < n; i++) { virDomainAudioDefPtr audio =3D virDomainAudioDefParseXML(xmlopt, nodes[i], @@ -22255,8 +22177,8 @@ virDomainDefParseXML(xmlDocPtr xml, /* analysis of the video devices */ if ((n =3D virXPathNodeSet("./devices/video", ctxt, &nodes)) < 0) goto error; - if (n && VIR_ALLOC_N(def->videos, n) < 0) - goto error; + if (n) + def->videos =3D g_new0(virDomainVideoDefPtr, n); for (i =3D 0; i < n; i++) { virDomainVideoDefPtr video; ssize_t insertAt =3D -1; @@ -22364,8 +22286,8 @@ virDomainDefParseXML(xmlDocPtr xml, /* Parse the RNG devices */ if ((n =3D virXPathNodeSet("./devices/rng", ctxt, &nodes)) < 0) goto error; - if (n && VIR_ALLOC_N(def->rngs, n) < 0) - goto error; + if (n) + def->rngs =3D g_new0(virDomainRNGDefPtr, n); for (i =3D 0; i < n; i++) { virDomainRNGDefPtr rng =3D virDomainRNGDefParseXML(xmlopt, nodes[i= ], ctxt, flags); @@ -22387,8 +22309,8 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; } =20 - if (n && VIR_ALLOC_N(def->tpms, n) < 0) - goto error; + if (n) + def->tpms =3D g_new0(virDomainTPMDefPtr, n); =20 for (i =3D 0; i < n; i++) { virDomainTPMDefPtr tpm =3D virDomainTPMDefParseXML(xmlopt, nodes[i= ], @@ -22419,8 +22341,8 @@ virDomainDefParseXML(xmlDocPtr xml, /* analysis of the hub devices */ if ((n =3D virXPathNodeSet("./devices/hub", ctxt, &nodes)) < 0) goto error; - if (n && VIR_ALLOC_N(def->hubs, n) < 0) - goto error; + if (n) + def->hubs =3D g_new0(virDomainHubDefPtr, n); for (i =3D 0; i < n; i++) { virDomainHubDefPtr hub; =20 @@ -22443,8 +22365,8 @@ virDomainDefParseXML(xmlDocPtr xml, /* analysis of the redirected devices */ if ((n =3D virXPathNodeSet("./devices/redirdev", ctxt, &nodes)) < 0) goto error; - if (n && VIR_ALLOC_N(def->redirdevs, n) < 0) - goto error; + if (n) + def->redirdevs =3D g_new0(virDomainRedirdevDefPtr, n); for (i =3D 0; i < n; i++) { virDomainRedirdevDefPtr redirdev =3D virDomainRedirdevDefParseXML(xmlopt, nodes[i], ctxt, flags); @@ -22477,8 +22399,8 @@ virDomainDefParseXML(xmlDocPtr xml, /* analysis of the panic devices */ if ((n =3D virXPathNodeSet("./devices/panic", ctxt, &nodes)) < 0) goto error; - if (n && VIR_ALLOC_N(def->panics, n) < 0) - goto error; + if (n) + def->panics =3D g_new0(virDomainPanicDefPtr, n); for (i =3D 0; i < n; i++) { virDomainPanicDefPtr panic; =20 @@ -22493,8 +22415,8 @@ virDomainDefParseXML(xmlDocPtr xml, /* analysis of the shmem devices */ if ((n =3D virXPathNodeSet("./devices/shmem", ctxt, &nodes)) < 0) goto error; - if (n && VIR_ALLOC_N(def->shmems, n) < 0) - goto error; + if (n) + def->shmems =3D g_new0(virDomainShmemDefPtr, n); =20 node =3D ctxt->node; for (i =3D 0; i < n; i++) { @@ -22519,8 +22441,8 @@ virDomainDefParseXML(xmlDocPtr xml, /* analysis of memory devices */ if ((n =3D virXPathNodeSet("./devices/memory", ctxt, &nodes)) < 0) goto error; - if (n && VIR_ALLOC_N(def->mems, n) < 0) - goto error; + if (n) + def->mems =3D g_new0(virDomainMemoryDefPtr, n); =20 for (i =3D 0; i < n; i++) { virDomainMemoryDefPtr mem =3D virDomainMemoryDefParseXML(xmlopt, @@ -25105,8 +25027,7 @@ virDomainIOThreadIDAdd(virDomainDefPtr def, { virDomainIOThreadIDDefPtr iothrid =3D NULL; =20 - if (VIR_ALLOC(iothrid) < 0) - goto error; + iothrid =3D g_new0(virDomainIOThreadIDDef, 1); =20 iothrid->iothread_id =3D iothread_id; =20 @@ -31953,8 +31874,7 @@ virDomainDefGetShortName(const virDomainDef *def) return NULL; } =20 - if (VIR_ALLOC_N(shortname, len + 1) < 0) - return NULL; + shortname =3D g_new0(char, len + 1); =20 if (wcstombs(shortname, wshortname, len) =3D=3D (size_t) -1) { virReportSystemError(errno, "%s", @@ -32100,8 +32020,7 @@ virDomainNetDefToNetworkPort(virDomainDefPtr dom, return NULL; } =20 - if (VIR_ALLOC(port) < 0) - return NULL; + port =3D g_new0(virNetworkPortDef, 1); =20 if (virUUIDGenerate(port->uuid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -32144,8 +32063,7 @@ virDomainNetDefActualFromNetworkPort(virDomainNetDe= fPtr iface, return -1; } =20 - if (VIR_ALLOC(actual) < 0) - return -1; + actual =3D g_new0(virDomainActualNetDef, 1); =20 switch ((virNetworkPortPlugType)port->plugtype) { case VIR_NETWORK_PORT_PLUG_TYPE_NONE: @@ -32262,8 +32180,7 @@ virDomainNetDefActualToNetworkPort(virDomainDefPtr = dom, return NULL; } =20 - if (VIR_ALLOC(port) < 0) - return NULL; + port =3D g_new0(virNetworkPortDef, 1); =20 if (virUUIDIsValid(iface->data.network.portid)) { memcpy(port->uuid, iface->data.network.portid, VIR_UUID_BUFLEN); --=20 2.26.2 From nobody Thu May 2 14:38:28 2024 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=1602098567; cv=none; d=zohomail.com; s=zohoarc; b=TWsCsbZdk3O1E2dE2Dlsis/3tJUJhuQthvBTg/4MoW5NS16VboyBsYMAPipdK7XnxGlzGdbCBAhgV9iFReWqQ3gy6vLzm4pS8cmFNe8/PiswzGFZSKo0LM6KfZLJu4sSIeuMooDLAvj40idTNS2zciA3nyLDjtSKcrLkz8C2eXA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602098567; 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=qTu25wvykdCr4L0EruDOfshYd7xwl7/2XoC54Us4msg=; b=C1M43MwqeeySXHl4sNbyWbaTHKCvNmwudI09iCez7k3m3TtQ4A4WVd5w0SDCwp+mSBbXSQvsJGnh2PWVivBWmgzlaVqxikQFeeskQVot+QBspmkxj5GnZ6k145vHb9uJxqqqoRMQkuTIaC9nV0wZ+ATHzZ/HHDYwHYn9VPFhKMQ= 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 1602098567517583.9894624494431; Wed, 7 Oct 2020 12:22:47 -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-423-g2JnMMqCM9WSRklWxPAa7A-1; Wed, 07 Oct 2020 15:22:43 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 97435804013; Wed, 7 Oct 2020 19:22:37 +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 67A2975120; Wed, 7 Oct 2020 19:22:37 +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 22E758C7AA; Wed, 7 Oct 2020 19:22:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 097JMZMr005886 for ; Wed, 7 Oct 2020 15:22:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id D54D51002D42; Wed, 7 Oct 2020 19:22:35 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5CBFC1001281 for ; Wed, 7 Oct 2020 19:22:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602098566; 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=qTu25wvykdCr4L0EruDOfshYd7xwl7/2XoC54Us4msg=; b=bWhUcHjTeunbFPkTrrzGyeIE03QuYDo7YhyqLbI0C4ZYxWS13mL06kotgboxsy6wSmL7p0 kHPzWiuwMARSTKkTAxFZDmNeOttVgGvQ58aRpJC+RideaAyXNxNXiIk4OY+LzeaOtldExu g9jCeRPeODAR+MsLmj61LHpD2ZlWmrc= X-MC-Unique: g2JnMMqCM9WSRklWxPAa7A-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 02/13] conf: capabilities: use g_new0 Date: Wed, 7 Oct 2020 21:22:18 +0200 Message-Id: <6b9321774df9d4cb46346aa023c86010d41d7206.1602098503.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.15 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 Reviewed-by: Erik Skultety Reviewed-by: Neal Gompa --- src/conf/capabilities.c | 39 ++++++++++++--------------------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 0ba7323ee8..90ad4e0c13 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -382,14 +382,10 @@ virCapabilitiesAllocMachines(const char *const *names= , int nnames) virCapsGuestMachinePtr *machines; size_t i; =20 - if (VIR_ALLOC_N(machines, nnames) < 0) - return NULL; + machines =3D g_new0(virCapsGuestMachinePtr, nnames); =20 for (i =3D 0; i < nnames; i++) { - if (VIR_ALLOC(machines[i]) < 0) { - virCapabilitiesFreeMachines(machines, nnames); - return NULL; - } + machines[i] =3D g_new0(virCapsGuestMachine, 1); machines[i]->name =3D g_strdup(names[i]); } =20 @@ -442,8 +438,7 @@ virCapabilitiesAddGuest(virCapsPtr caps, { virCapsGuestPtr guest; =20 - if (VIR_ALLOC(guest) < 0) - goto error; + guest =3D g_new0(virCapsGuest, 1); =20 guest->ostype =3D ostype; guest->arch.id =3D arch; @@ -492,8 +487,7 @@ virCapabilitiesAddGuestDomain(virCapsGuestPtr guest, { virCapsGuestDomainPtr dom; =20 - if (VIR_ALLOC(dom) < 0) - goto error; + dom =3D g_new0(virCapsGuestDomain, 1); =20 dom->type =3D hvtype; dom->info.emulator =3D g_strdup(emulator); @@ -728,8 +722,7 @@ virCapabilitiesDomainDataLookupInternal(virCapsPtr caps, return ret; } =20 - if (VIR_ALLOC(ret) < 0) - return ret; + ret =3D g_new0(virCapsDomainData, 1); =20 ret->ostype =3D foundguest->ostype; ret->arch =3D foundguest->arch.id; @@ -806,8 +799,7 @@ virCapabilitiesAddStoragePool(virCapsPtr caps, { virCapsStoragePoolPtr pool; =20 - if (VIR_ALLOC(pool) < 0) - goto error; + pool =3D g_new0(virCapsStoragePool, 1); =20 pool->type =3D poolType; =20 @@ -1493,8 +1485,7 @@ virCapabilitiesGetNUMASiblingInfo(int node, return 0; } =20 - if (VIR_ALLOC_N(tmp, ndistances) < 0) - goto cleanup; + tmp =3D g_new0(virCapsHostNUMACellSiblingInfo, ndistances); =20 for (i =3D 0; i < ndistances; i++) { if (!distances[i]) @@ -1532,8 +1523,7 @@ virCapabilitiesGetNUMAPagesInfo(int node, if (virNumaGetPages(node, &pages_size, &pages_avail, NULL, &npages) < = 0) goto cleanup; =20 - if (VIR_ALLOC_N(*pageinfo, npages) < 0) - goto cleanup; + *pageinfo =3D g_new0(virCapsHostNUMACellPageInfo, npages); *npageinfo =3D npages; =20 for (i =3D 0; i < npages; i++) { @@ -1572,8 +1562,7 @@ virCapabilitiesHostNUMAInitFake(virCapsHostNUMAPtr ca= ps) int nodecpus =3D nodeinfo.sockets * nodeinfo.cores * nodeinfo.thre= ads; cid =3D 0; =20 - if (VIR_ALLOC_N(cpus, nodecpus) < 0) - return -1; + cpus =3D g_new0(virCapsHostNUMACellCPU, nodecpus); =20 for (s =3D 0; s < nodeinfo.sockets; s++) { for (c =3D 0; c < nodeinfo.cores; c++) { @@ -1644,8 +1633,7 @@ virCapabilitiesHostNUMAInitReal(virCapsHostNUMAPtr ca= ps) goto cleanup; } =20 - if (VIR_ALLOC_N(cpus, ncpus) < 0) - goto cleanup; + cpus =3D g_new0(virCapsHostNUMACellCPU, ncpus); cpu =3D 0; =20 for (i =3D 0; i < virBitmapSize(cpumap); i++) { @@ -1816,8 +1804,7 @@ virCapabilitiesInitResctrlMemory(virCapsPtr caps) =20 for (i =3D 0; i < caps->host.cache.nbanks; i++) { virCapsHostCacheBankPtr bank =3D caps->host.cache.banks[i]; - if (VIR_ALLOC(node) < 0) - goto cleanup; + node =3D g_new0(virCapsHostMemBWNode, 1); =20 if (virResctrlInfoGetMemoryBandwidth(caps->host.resctrl, bank->level, &node->control) = > 0) { @@ -1901,9 +1888,7 @@ virCapabilitiesInitCaches(virCapsPtr caps) if (level < cache_min_level) continue; =20 - if (VIR_ALLOC(bank) < 0) - goto cleanup; - + bank =3D g_new0(virCapsHostCacheBank, 1); bank->level =3D level; =20 if (virFileReadValueUint(&bank->id, --=20 2.26.2 From nobody Thu May 2 14:38:28 2024 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=1602098574; cv=none; d=zohomail.com; s=zohoarc; b=CKoQNDPCwfpAES28Jf/amvS/5VbLzE3XcldhlukP5Vk312cOx+gSnBjdCeUcDVRRwKqLSvvLumNPAiNP4c4bZwSHVhxhTsPnTizsJT1LneBUc1S8s+1HvPP3f2iujA1qNXvT9RvuXP3NMKEeQosKoXtyhEHcMaGIkk/F3zsxpsE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602098574; 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=FKhosaBe3CfUzTTRBAwI6uxSWlWkppo5DG/duj42Rb4=; b=a+a/DNDAQ1ndVmCOr52Bw+9LsZ74+QnoCPZlL1FckyWcZnmKdf06HlgDR0C7TXWvSt2KSHvyRI40TT/QEpGrv0UjhcXlG6NXFqmgrfGR96jA8ulHYqAGIjZSFqaiHCq6Lx52g+Ip2IP8nxwur4KU8vX7o3Sg03dtjCiLpf1QqQk= 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 1602098574365713.7821798329002; Wed, 7 Oct 2020 12:22:54 -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-443-UMUoBmizMna9taqpSPD-uA-1; Wed, 07 Oct 2020 15:22:50 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C5D1118A822F; Wed, 7 Oct 2020 19:22:41 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A570A6EF43; Wed, 7 Oct 2020 19:22:41 +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 72E6B1832FD3; Wed, 7 Oct 2020 19:22:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 097JManR005895 for ; Wed, 7 Oct 2020 15:22:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id A702E1001281; Wed, 7 Oct 2020 19:22:36 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2F9F9100164C for ; Wed, 7 Oct 2020 19:22:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602098573; 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=FKhosaBe3CfUzTTRBAwI6uxSWlWkppo5DG/duj42Rb4=; b=H1I3RFbubvxo8mlMKZHRqbDKHn8PUYygX14cLSc5jFrc6gPf21xtH9Kv/YgwE8ZM3Q+6UU KIChv9xVbisdsM/3o3JVgA+Xc/9TSXGqNBMi2+B14h7DUKGlC+wZsP386+3ql1SXd9MbJ1 m3MVccPtLCXQOShMhxn9bbfCpy9ncCY= X-MC-Unique: UMUoBmizMna9taqpSPD-uA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 03/13] conf: network: use g_new0 Date: Wed, 7 Oct 2020 21:22:19 +0200 Message-Id: <021a37f12d1b95f6594b2f714d11bb31020cc27f.1602098503.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.13 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 Reviewed-by: Erik Skultety Reviewed-by: Neal Gompa --- src/conf/network_conf.c | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 2fcd498107..4f1115e103 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -442,9 +442,7 @@ virNetworkDHCPLeaseTimeDefParseXML(virNetworkDHCPLeaseT= imeDefPtr *lease, } } =20 - if (VIR_ALLOC(new_lease) < 0) - return -1; - + new_lease =3D g_new0(virNetworkDHCPLeaseTimeDef, 1); new_lease->expiry =3D expiry; new_lease->unit =3D unit; =20 @@ -976,8 +974,7 @@ virNetworkDNSDefParseXML(const char *networkName, return -1; } if (nfwds > 0) { - if (VIR_ALLOC_N(def->forwarders, nfwds) < 0) - return -1; + def->forwarders =3D g_new0(virNetworkDNSForwarder, nfwds); =20 for (i =3D 0; i < nfwds; i++) { g_autofree char *addr =3D virXMLPropString(fwdNodes[i], "addr"= ); @@ -1009,8 +1006,7 @@ virNetworkDNSDefParseXML(const char *networkName, return -1; } if (nhosts > 0) { - if (VIR_ALLOC_N(def->hosts, nhosts) < 0) - return -1; + def->hosts =3D g_new0(virNetworkDNSHostDef, nhosts); =20 for (i =3D 0; i < nhosts; i++) { if (virNetworkDNSHostDefParseXML(networkName, hostNodes[i], @@ -1029,8 +1025,7 @@ virNetworkDNSDefParseXML(const char *networkName, return -1; } if (nsrvs > 0) { - if (VIR_ALLOC_N(def->srvs, nsrvs) < 0) - return -1; + def->srvs =3D g_new0(virNetworkDNSSrvDef, nsrvs); =20 for (i =3D 0; i < nsrvs; i++) { if (virNetworkDNSSrvDefParseXML(networkName, srvNodes[i], ctxt, @@ -1049,8 +1044,7 @@ virNetworkDNSDefParseXML(const char *networkName, return -1; } if (ntxts > 0) { - if (VIR_ALLOC_N(def->txts, ntxts) < 0) - return -1; + def->txts =3D g_new0(virNetworkDNSTxtDef, ntxts); =20 for (i =3D 0; i < ntxts; i++) { if (virNetworkDNSTxtDefParseXML(networkName, txtNodes[i], @@ -1551,8 +1545,7 @@ virNetworkForwardDefParseXML(const char *networkName, } =20 if (nForwardIfs > 0 || forwardDev) { - if (VIR_ALLOC_N(def->ifs, MAX(nForwardIfs, 1)) < 0) - return -1; + def->ifs =3D g_new0(virNetworkForwardIfDef, MAX(nForwardIfs, 1)); =20 if (forwardDev) { def->ifs[0].device.dev =3D g_steal_pointer(&forwardDev); @@ -1603,8 +1596,7 @@ virNetworkForwardDefParseXML(const char *networkName, } =20 } else if (nForwardAddrs > 0) { - if (VIR_ALLOC_N(def->ifs, nForwardAddrs) < 0) - return -1; + def->ifs =3D g_new0(virNetworkForwardIfDef, nForwardAddrs); =20 for (i =3D 0; i < nForwardAddrs; i++) { g_autofree char *addrType =3D NULL; @@ -1661,8 +1653,7 @@ virNetworkForwardDefParseXML(const char *networkName, networkName); return -1; } else if (nForwardPfs =3D=3D 1) { - if (VIR_ALLOC_N(def->pfs, nForwardPfs) < 0) - return -1; + def->pfs =3D g_new0(virNetworkForwardPfDef, nForwardPfs); =20 forwardDev =3D virXMLPropString(*forwardPfNodes, "dev"); if (!forwardDev) { @@ -1707,8 +1698,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt, xmlNodePtr vlanNode; xmlNodePtr metadataNode =3D NULL; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virNetworkDef, 1); =20 /* Extract network name */ def->name =3D virXPathString("string(./name[1])", ctxt); @@ -1863,8 +1853,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt, size_t i; =20 /* allocate array to hold all the portgroups */ - if (VIR_ALLOC_N(def->portGroups, nPortGroups) < 0) - return NULL; + def->portGroups =3D g_new0(virPortGroupDef, nPortGroups); /* parse each portgroup */ for (i =3D 0; i < nPortGroups; i++) { if (virNetworkPortGroupParseXML(&def->portGroups[i], @@ -1883,8 +1872,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt, size_t i; =20 /* allocate array to hold all the addrs */ - if (VIR_ALLOC_N(def->ips, nips) < 0) - return NULL; + def->ips =3D g_new0(virNetworkIPDef, nips); /* parse each addr */ for (i =3D 0; i < nips; i++) { if (virNetworkIPDefParseXML(def->name, @@ -1904,8 +1892,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt, size_t i; =20 /* allocate array to hold all the route definitions */ - if (VIR_ALLOC_N(def->routes, nRoutes) < 0) - return NULL; + def->routes =3D g_new0(virNetDevIPRoutePtr, nRoutes); /* parse each definition */ for (i =3D 0; i < nRoutes; i++) { virNetDevIPRoutePtr route =3D NULL; --=20 2.26.2 From nobody Thu May 2 14:38:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1602098594; cv=none; d=zohomail.com; s=zohoarc; b=adH2YnAvbFCCI3pR+/ZtKCyOYQJwQut0q1zalEQi53JHbbGpf+AWXeLROgOWuI1m4cx550upUxnX+1DAlwOEpsPie4/zSo6yCU9Z2eUADyQa155jhjrRli778oDhZIYoZeDonuhMnyoBvwmQUKr2ye7MKjhnNzA68o7c1Tr9KdQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602098594; 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=d/cFOuBmXMkZwSTH1TpnzIw1C0AFHWlmBPvc3iMEEV8=; b=U9qHpLVbitjo4gC3loKneAjCPO2Qn1T0xPta39yqPC66+j7Hx46yS2ClqCfmcsqrUFoJ22G8pVaI5bl1g6uKgyv3b8ZwjGexmwXX0y0iova/yfa7PJ2y7nZtiKqwZR51ItrN+LUmsXjgD1B/LAlkP4MG1brBBGpzzYJssTNoM+A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1602098594579559.5247640915973; Wed, 7 Oct 2020 12:23:14 -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-445-KMS6d2i8Oc2hwgxFUM7qLA-1; Wed, 07 Oct 2020 15:22:50 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F367018A8231; Wed, 7 Oct 2020 19:22:41 +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 D0F425C1C2; Wed, 7 Oct 2020 19:22:41 +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 9FAAC8C7AD; Wed, 7 Oct 2020 19:22:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 097JMbZk005906 for ; Wed, 7 Oct 2020 15:22:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 79784100164C; Wed, 7 Oct 2020 19:22:37 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 017DF1001281 for ; Wed, 7 Oct 2020 19:22:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602098593; 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=d/cFOuBmXMkZwSTH1TpnzIw1C0AFHWlmBPvc3iMEEV8=; b=hLnr239nMW19sqt9R3lyrAnJrTZXavtG1AL6H5XsDLng3k1Fuu51L1/2pWvO+rCFd0XUIH zHlebFV6eiFE0pIg8HfriJmCcoZy/kAY5H9OsW/r5A9cg9OhUYTVH6X8qs3FW0Y7Q74odx pT8iXfcbICJPJJYnjOwQ8SkL9odMMuk= X-MC-Unique: KMS6d2i8Oc2hwgxFUM7qLA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 04/13] conf: node_device: use g_new0 Date: Wed, 7 Oct 2020 21:22:20 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.16 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 Reviewed-by: Erik Skultety Reviewed-by: Neal Gompa --- src/conf/node_device_conf.c | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index e478238675..4adfdef572 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -1337,8 +1337,7 @@ virNodeDevCapPCIDevIommuGroupParseXML(xmlXPathContext= Ptr ctxt, virPCIDeviceAddress addr =3D {0}; if (virPCIDeviceAddressParseXML(addrNodes[i], &addr) < 0) goto cleanup; - if (VIR_ALLOC(pciAddr) < 0) - goto cleanup; + pciAddr =3D g_new0(virPCIDeviceAddress, 1); pciAddr->domain =3D addr.domain; pciAddr->bus =3D addr.bus; pciAddr->slot =3D addr.slot; @@ -1416,8 +1415,7 @@ virPCIEDeviceInfoParseXML(xmlXPathContextPtr ctxt, ctxt->node =3D pciExpressNode; =20 if ((lnk =3D virXPathNode("./link[@validity=3D'cap']", ctxt))) { - if (VIR_ALLOC(pci_express->link_cap) < 0) - goto cleanup; + pci_express->link_cap =3D g_new0(virPCIELink, 1); =20 if (virPCIEDeviceInfoLinkParseXML(ctxt, lnk, pci_express->link_cap) < 0) @@ -1425,8 +1423,7 @@ virPCIEDeviceInfoParseXML(xmlXPathContextPtr ctxt, } =20 if ((lnk =3D virXPathNode("./link[@validity=3D'sta']", ctxt))) { - if (VIR_ALLOC(pci_express->link_sta) < 0) - goto cleanup; + pci_express->link_sta =3D g_new0(virPCIELink, 1); =20 if (virPCIEDeviceInfoLinkParseXML(ctxt, lnk, pci_express->link_sta) < 0) @@ -1445,8 +1442,7 @@ virNodeDevPCICapSRIOVPhysicalParseXML(xmlXPathContext= Ptr ctxt, { xmlNodePtr address =3D virXPathNode("./address[1]", ctxt); =20 - if (VIR_ALLOC(pci_dev->physical_function) < 0) - return -1; + pci_dev->physical_function =3D g_new0(virPCIDeviceAddress, 1); =20 if (!address) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -1485,14 +1481,12 @@ virNodeDevPCICapSRIOVVirtualParseXML(xmlXPathContex= tPtr ctxt, goto cleanup; } =20 - if (VIR_ALLOC_N(pci_dev->virtual_functions, naddresses) < 0) - goto cleanup; + pci_dev->virtual_functions =3D g_new0(virPCIDeviceAddressPtr, naddress= es); =20 for (i =3D 0; i < naddresses; i++) { g_autoptr(virPCIDeviceAddress) addr =3D NULL; =20 - if (VIR_ALLOC(addr) < 0) - goto cleanup; + addr =3D g_new0(virPCIDeviceAddress, 1); =20 if (virPCIDeviceAddressParseXML(addresses[i], addr) < 0) goto cleanup; @@ -1530,8 +1524,7 @@ virNodeDevPCICapMdevTypesParseXML(xmlXPathContextPtr = ctxt, for (i =3D 0; i < nmdev_types; i++) { ctxt->node =3D nodes[i]; =20 - if (VIR_ALLOC(type) < 0) - goto cleanup; + type =3D g_new0(virMediatedDeviceType, 1); =20 if (!(type->id =3D virXPathString("string(./@id[1])", ctxt))) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -1705,8 +1698,7 @@ virNodeDevCapPCIDevParseXML(xmlXPathContextPtr ctxt, goto out; =20 if ((pciExpress =3D virXPathNode("./pci-express[1]", ctxt))) { - if (VIR_ALLOC(pci_express) < 0) - goto out; + pci_express =3D g_new0(virPCIEDeviceInfo, 1); =20 if (virPCIEDeviceInfoParseXML(ctxt, pciExpress, pci_express) < 0) goto out; @@ -1844,8 +1836,7 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt, char *tmp; int val, ret =3D -1; =20 - if (VIR_ALLOC(caps) < 0) - return NULL; + caps =3D g_new0(virNodeDevCapsDef, 1); =20 tmp =3D virXMLPropString(node, "type"); if (!tmp) { @@ -1940,8 +1931,7 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, int n, m; size_t i; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virNodeDeviceDef, 1); =20 /* Extract device name */ if (create =3D=3D EXISTING_DEVICE) { @@ -1961,8 +1951,7 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, if ((n =3D virXPathNodeSet("./devnode", ctxt, &nodes)) < 0) goto error; =20 - if (VIR_ALLOC_N(def->devlinks, n + 1) < 0) - goto error; + def->devlinks =3D g_new0(char *, n + 1); =20 for (i =3D 0, m =3D 0; i < n; i++) { xmlNodePtr node =3D nodes[i]; @@ -2325,8 +2314,8 @@ virNodeDeviceCapsListExport(virNodeDeviceDefPtr def, if (virNodeDeviceUpdateCaps(def) < 0) goto cleanup; =20 - if (want_list && VIR_ALLOC_N(tmp, VIR_NODE_DEV_CAP_LAST - 1) < 0) - goto cleanup; + if (want_list) + tmp =3D g_new0(virNodeDevCapType, VIR_NODE_DEV_CAP_LAST - 1); =20 for (caps =3D def->caps; caps; caps =3D caps->next) { unsigned int flags; --=20 2.26.2 From nobody Thu May 2 14:38:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1602098577; cv=none; d=zohomail.com; s=zohoarc; b=QIzI06IK/RegzgJ4429lFNStVsFlbbCMHxhEPRg94CeTBGBbPeD5tVmDHcr0X2i1JRKgMa/NEhRxrymqMYsFiSAPgJNw/KcqOg8S6OapjJOkbjgHVNXc/6ETHIGnw3kwyHh4AQWnrWAmYUK+sW9HlwB7TGs3y3dSnOdGw9ZQ6rQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602098577; 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=TyE7a0vFU8VuIc2EYDV5fOhDu1bBx3UyDwlsPZPMNYQ=; b=JYnyw5SBauNlWxL4KQdK0e6um0rtjMK7cLRqWEAH3wSoO0jLALC7ZE3NdI/BcuIgbO/dmkIZWDmZWJmhfKIAMiGjjKeIB31/QB7t8F+97wu9ofGwxfh8p6AMLN6z/E7JKAOD9dU23FWAK0EuOzrqG8LBhUOSc6GflE8X+HFqygI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1602098577065826.7084463155354; Wed, 7 Oct 2020 12:22:57 -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-310-eOnXBRN4PWO4-B8_MwfjWA-1; Wed, 07 Oct 2020 15:22:52 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A1B268070F3; Wed, 7 Oct 2020 19:22:44 +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 84EA076649; Wed, 7 Oct 2020 19:22:44 +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 4FBC58C7AF; Wed, 7 Oct 2020 19:22:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 097JMceh005920 for ; Wed, 7 Oct 2020 15:22:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4D28E100164C; Wed, 7 Oct 2020 19:22:38 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id C8EAD1001281 for ; Wed, 7 Oct 2020 19:22:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602098574; 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=TyE7a0vFU8VuIc2EYDV5fOhDu1bBx3UyDwlsPZPMNYQ=; b=h15rofkfxpWB0n2abUUmX49fd0rCImfrfYFEE86grUxDuGpj8GJnXyP27aBzct1q65HrT4 fF6nIQnkNrwXF/VraoroLUXuha/PMI+ppDhUjc52JnSwYvWRfqhMT5MZjkdIOqvhTqbjAI kqVyMkVlR7Vako23uQU0Ns+cYvV19IY= X-MC-Unique: eOnXBRN4PWO4-B8_MwfjWA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 05/13] conf: domain_addr: use g_new0 Date: Wed, 7 Oct 2020 21:22:21 +0200 Message-Id: <2a74fa19580c88034ccbcb33a1367b6e590ce418.1602098503.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.11 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 Reviewed-by: Erik Skultety Reviewed-by: Neal Gompa --- src/conf/domain_addr.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index 9114f2d8d0..ab508b0c8f 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -1026,8 +1026,7 @@ virDomainPCIAddressSetExtensionAlloc(virDomainPCIAddr= essSetPtr addrs, if (addrs->zpciIds) return 0; =20 - if (VIR_ALLOC(addrs->zpciIds) < 0) - return -1; + addrs->zpciIds =3D g_new0(virDomainZPCIAddressIds, 1); =20 addrs->zpciIds->uids =3D virHashCreateFull(10, NULL, virZPCIAddrKeyCode, @@ -1054,12 +1053,8 @@ virDomainPCIAddressSetAlloc(unsigned int nbuses, { virDomainPCIAddressSetPtr addrs; =20 - if (VIR_ALLOC(addrs) < 0) - goto error; - - if (VIR_ALLOC_N(addrs->buses, nbuses) < 0) - goto error; - + addrs =3D g_new0(virDomainPCIAddressSet, 1); + addrs->buses =3D g_new0(virDomainPCIAddressBus, nbuses); addrs->nbuses =3D nbuses; =20 if (virDomainPCIAddressSetExtensionAlloc(addrs, extFlags) < 0) @@ -1465,8 +1460,7 @@ virDomainCCWAddressSetCreate(void) { virDomainCCWAddressSetPtr addrs =3D NULL; =20 - if (VIR_ALLOC(addrs) < 0) - goto error; + addrs =3D g_new0(virDomainCCWAddressSet, 1); =20 if (!(addrs->defined =3D virHashCreate(10, virHashValueFree))) goto error; @@ -1520,8 +1514,7 @@ virDomainVirtioSerialAddrSetCreate(void) { virDomainVirtioSerialAddrSetPtr ret =3D NULL; =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(virDomainVirtioSerialAddrSet, 1); =20 return ret; } @@ -1592,8 +1585,8 @@ virDomainVirtioSerialAddrSetAddController(virDomainVi= rtioSerialAddrSetPtr addrs, VIR_DEBUG("Adding virtio serial controller index %u with %d" " ports to the address set", cont->idx, ports); =20 - if (VIR_ALLOC(cnt) < 0) - goto cleanup; + cnt =3D g_new0(virDomainVirtioSerialController, + 1); =20 cnt->ports =3D virBitmapNew(ports); cnt->idx =3D cont->idx; @@ -1951,8 +1944,7 @@ virDomainUSBAddressSetCreate(void) { virDomainUSBAddressSetPtr addrs; =20 - if (VIR_ALLOC(addrs) < 0) - return NULL; + addrs =3D g_new0(virDomainUSBAddressSet, 1); =20 return addrs; } @@ -2039,17 +2031,14 @@ virDomainUSBAddressHubNew(size_t nports) { virDomainUSBAddressHubPtr hub =3D NULL, ret =3D NULL; =20 - if (VIR_ALLOC(hub) < 0) - goto cleanup; + hub =3D g_new0(virDomainUSBAddressHub, 1); =20 hub->portmap =3D virBitmapNew(nports); =20 - if (VIR_ALLOC_N(hub->ports, nports) < 0) - goto cleanup; + hub->ports =3D g_new0(virDomainUSBAddressHubPtr, nports); hub->nports =3D nports; =20 ret =3D g_steal_pointer(&hub); - cleanup: virDomainUSBAddressHubFree(hub); return ret; } --=20 2.26.2 From nobody Thu May 2 14:38:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1602098600; cv=none; d=zohomail.com; s=zohoarc; b=T6qRk3hTa6hRlpjScL5v1xbIJl0gFFDlUQmFD/NAXHatIYD8ke5EJHTWAbk7nXb9PM0baLBDr/aMaq1CBqZ21IJi8sPTtp7zGXg2A7Lz4gpKnhJBcvdXgTFyEhErYPPj6F8IboZ5kqIxY1Z8yUyz20kZBNyuRrX2sPaqoz5IZ70= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602098600; 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=Qxfq2wJGO2yFLI47iOauBgvthQua7Zyasjvw2u8PXG4=; b=ZlVK+8aIj/avfpHFY70wGgjpZbsPjGhRfzeXtw6JVA1d401mUEek5LXbiKe0nv6d1kuTwk8CWU5YVsEAF4xVRZ0UdgKt32tIFPA/+q51V8SxTb7fypWOslUujewUXppHeDWb2s/TzO9STMRkKO2jlUt1ZICYsKGDqtaXDcBEamI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1602098600518483.64258015786675; Wed, 7 Oct 2020 12:23:20 -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-46-S4SlIbaWOZSujgsX-E15hg-1; Wed, 07 Oct 2020 15:22:54 -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 6DC72425E3; Wed, 7 Oct 2020 19:22:47 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4DA9260E1C; Wed, 7 Oct 2020 19:22:47 +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 1CA131832FC6; Wed, 7 Oct 2020 19:22:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 097JMdjJ005932 for ; Wed, 7 Oct 2020 15:22:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1F0F61001281; Wed, 7 Oct 2020 19:22:39 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B803100164C for ; Wed, 7 Oct 2020 19:22:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602098599; 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=Qxfq2wJGO2yFLI47iOauBgvthQua7Zyasjvw2u8PXG4=; b=Sgtf5yXdb7hhPdMx1mL55GTA9aSi0JuEpGqQLeoeL0wCbI9W3qJsdJFhnEjTIBAVvRJkFj 3vqz5uDgPVFurIPOeiTeTpC0l7xZExz8AIo5RVkCbHWGle3f520OxuknMJHWjl1jkZxzYS 3NCyh/3YaMjJfy5GOXhAv/f2JfVDMp0= X-MC-Unique: S4SlIbaWOZSujgsX-E15hg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 06/13] conf: interface: use g_new0 Date: Wed, 7 Oct 2020 21:22:22 +0200 Message-Id: <0eac8edeb538199116f35484871410e30253a150.1602098503.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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 Reviewed-by: Erik Skultety Reviewed-by: Neal Gompa --- src/conf/interface_conf.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index 1e478ac075..7bb5ec4deb 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -337,16 +337,14 @@ virInterfaceDefParseProtoIPv4(virInterfaceProtocolDef= Ptr def, if (ipNodes =3D=3D NULL) return 0; =20 - if (VIR_ALLOC_N(def->ips, nipNodes) < 0) - goto error; + def->ips =3D g_new0(virInterfaceIPDefPtr, nipNodes); =20 def->nips =3D 0; for (i =3D 0; i < nipNodes; i++) { =20 virInterfaceIPDefPtr ip; =20 - if (VIR_ALLOC(ip) < 0) - goto error; + ip =3D g_new0(virInterfaceIPDef, 1); =20 ctxt->node =3D ipNodes[i]; if (virInterfaceDefParseIP(ip, ctxt) < 0) { @@ -393,16 +391,14 @@ virInterfaceDefParseProtoIPv6(virInterfaceProtocolDef= Ptr def, if (ipNodes =3D=3D NULL) return 0; =20 - if (VIR_ALLOC_N(def->ips, nipNodes) < 0) - goto error; + def->ips =3D g_new0(virInterfaceIPDefPtr, nipNodes); =20 def->nips =3D 0; for (i =3D 0; i < nipNodes; i++) { =20 virInterfaceIPDefPtr ip; =20 - if (VIR_ALLOC(ip) < 0) - goto error; + ip =3D g_new0(virInterfaceIPDef, 1); =20 ctxt->node =3D ipNodes[i]; if (virInterfaceDefParseIP(ip, ctxt) < 0) { @@ -438,16 +434,14 @@ virInterfaceDefParseIfAdressing(virInterfaceDefPtr de= f, return 0; } =20 - if (VIR_ALLOC_N(def->protos, nProtoNodes) < 0) - goto error; + def->protos =3D g_new0(virInterfaceProtocolDefPtr, nProtoNodes); =20 def->nprotos =3D 0; for (pp =3D 0; pp < nProtoNodes; pp++) { =20 virInterfaceProtocolDefPtr proto; =20 - if (VIR_ALLOC(proto) < 0) - goto error; + proto =3D g_new0(virInterfaceProtocolDef, 1); =20 ctxt->node =3D protoNodes[pp]; tmp =3D virXPathString("string(./@family)", ctxt); @@ -522,10 +516,7 @@ virInterfaceDefParseBridge(virInterfaceDefPtr def, goto error; } if (nbItf > 0) { - if (VIR_ALLOC_N(def->data.bridge.itf, nbItf) < 0) { - ret =3D -1; - goto error; - } + def->data.bridge.itf =3D g_new0(struct _virInterfaceDef *, nbItf); def->data.bridge.nbItf =3D nbItf; =20 for (i =3D 0; i < nbItf; i++) { @@ -568,8 +559,7 @@ virInterfaceDefParseBondItfs(virInterfaceDefPtr def, goto cleanup; } =20 - if (VIR_ALLOC_N(def->data.bond.itf, nbItf) < 0) - goto cleanup; + def->data.bond.itf =3D g_new0(struct _virInterfaceDef *, nbItf); =20 def->data.bond.nbItf =3D nbItf; =20 @@ -712,8 +702,7 @@ virInterfaceDefParseXML(xmlXPathContextPtr ctxt, } VIR_FREE(tmp); =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virInterfaceDef, 1); =20 if (((parentIfType =3D=3D VIR_INTERFACE_TYPE_BOND) && (type !=3D VIR_INTERFACE_TYPE_ETHERNET)) --=20 2.26.2 From nobody Thu May 2 14:38:28 2024 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=1602098662; cv=none; d=zohomail.com; s=zohoarc; b=POd3wqqTWNK0dTxN+PCmp7WbmuJ7ykjYIcszZZ6cNWHBowGY1W0pmAI6hMLKt/z9XgTnae9l/aTMBclOHCZpgynqHSDqrLOaZO5PjBFZFiJE7JCQp54aqf5DoymywskZHhqB/ywXmOFaI9USJceFvaWhxOBO5fTmuG1Gevf0uDc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602098662; 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=CN4Er536MipBASO1jSZT+xj6dZLoDfWNtUJb6Ne+YTs=; b=bubdRoxyaUOsRYqk00NS9f4wt53vnOLOXXyBGzhyU1/YVDZ5eg/d+EneYbr+ES75ykKsZBDkhqoS0XMYkg7Oh9zVSZyNnUSWIam1Ww+LLkkLxLx0QvBPbqnbd0Hp2lOChbGOf5L4z48npeuOsCKwnTnTgBdWSls4xSze+cwwgqE= 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 1602098662032448.96769452115086; Wed, 7 Oct 2020 12:24:22 -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-302-TFf-weDSPXGIsd4aqBhV9Q-1; Wed, 07 Oct 2020 15:22:55 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3A6BD1084C9B; Wed, 7 Oct 2020 19:22:50 +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 14D115C1C2; Wed, 7 Oct 2020 19:22:50 +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 D1ADD8C7B8; Wed, 7 Oct 2020 19:22:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 097JMdvh005941 for ; Wed, 7 Oct 2020 15:22:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id E4E841001281; Wed, 7 Oct 2020 19:22:39 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D8BD100164C for ; Wed, 7 Oct 2020 19:22:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602098660; 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=CN4Er536MipBASO1jSZT+xj6dZLoDfWNtUJb6Ne+YTs=; b=YH7lmPJmL6lJcbHpMErZWSWWnsifIz4k60Vnu4ED+pObbUFa9vIqCUljwHg9WeQlD6GGRi E2No9V4PeBTazfTtmX70cX6d1FiyT/NlkLUJe8Jh5gxFiVnnfbNNpdHFmxcg0qwKh8dVcr wkMn78d500/sdpH9L78CTQEsdpX+u60= X-MC-Unique: TFf-weDSPXGIsd4aqBhV9Q-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 07/13] conf: numa: use g_new0 Date: Wed, 7 Oct 2020 21:22:23 +0200 Message-Id: <181dfb1d09550c7b80a83c1c6ffe427cb7262fce.1602098503.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.16 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 Reviewed-by: Erik Skultety Reviewed-by: Neal Gompa --- src/conf/numa_conf.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/conf/numa_conf.c b/src/conf/numa_conf.c index 6653ba05a6..f8a7a01ac9 100644 --- a/src/conf/numa_conf.c +++ b/src/conf/numa_conf.c @@ -851,9 +851,7 @@ virDomainNumaDefNodeDistanceParseXML(virDomainNumaPtr d= ef, /* Apply the local / remote distance */ ldist =3D def->mem_nodes[cur_cell].distances; if (!ldist) { - if (VIR_ALLOC_N(ldist, ndistances) < 0) - goto cleanup; - + ldist =3D g_new0(virDomainNumaDistance, ndistances); ldist[cur_cell].value =3D LOCAL_DISTANCE; ldist[cur_cell].cellid =3D cur_cell; def->mem_nodes[cur_cell].ndistances =3D ndistances; @@ -866,9 +864,7 @@ virDomainNumaDefNodeDistanceParseXML(virDomainNumaPtr d= ef, /* Apply symmetry if none given */ rdist =3D def->mem_nodes[sibling_id].distances; if (!rdist) { - if (VIR_ALLOC_N(rdist, ndistances) < 0) - goto cleanup; - + rdist =3D g_new0(virDomainNumaDistance, ndistances); rdist[sibling_id].value =3D LOCAL_DISTANCE; rdist[sibling_id].cellid =3D sibling_id; def->mem_nodes[sibling_id].ndistances =3D ndistances; @@ -1005,8 +1001,7 @@ virDomainNumaDefParseXML(virDomainNumaPtr def, goto cleanup; } =20 - if (VIR_ALLOC_N(def->mem_nodes, n) < 0) - goto cleanup; + def->mem_nodes =3D g_new0(struct _virDomainNumaNode, n); def->nmem_nodes =3D n; =20 for (i =3D 0; i < n; i++) { @@ -1502,11 +1497,7 @@ virDomainNumaGetMaxCPUID(virDomainNumaPtr numa) virDomainNumaPtr virDomainNumaNew(void) { - virDomainNumaPtr ret =3D NULL; - - ignore_value(VIR_ALLOC(ret)); - - return ret; + return g_new0(virDomainNuma, 1); } =20 =20 @@ -1586,8 +1577,7 @@ virDomainNumaSetNodeCount(virDomainNumaPtr numa, size= _t nmem_nodes) return 0; } =20 - if (VIR_ALLOC_N(numa->mem_nodes, nmem_nodes) < 0) - return 0; + numa->mem_nodes =3D g_new0(struct _virDomainNumaNode, nmem_nodes); =20 numa->nmem_nodes =3D nmem_nodes; =20 @@ -1727,8 +1717,7 @@ virDomainNumaSetNodeDistanceCount(virDomainNumaPtr nu= ma, return 0; } =20 - if (VIR_ALLOC_N(distances, ndistances) < 0) - return 0; + distances =3D g_new0(struct _virDomainNumaDistance, ndistances); =20 numa->mem_nodes[node].distances =3D distances; numa->mem_nodes[node].ndistances =3D ndistances; --=20 2.26.2 From nobody Thu May 2 14:38:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1602098577; cv=none; d=zohomail.com; s=zohoarc; b=ATwN9S2xZbngVAkbnBuXpTWkvBEcQT+p4oDmev+Uh1t9YDtYnAzyez40BSkj8XOKdHP2aN4BA5NKa+H0vxujBhYZsI005iHY2D6FuVpQ5foZJE792nigeMazLhiaAgwe0MkpjYyw9exh55VZJPRY9wY14nUvvP8gm7+R0n39CoU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602098577; 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=tLfN0A6VLSVjwoEfOlQwshyfEkPcmFIpbljMB2jbDHA=; b=Whhu353Rlpwx59383cqqZ/TqqtZAg5oQ23irp8jpj6vEiccQdK11FmwCKXh0lz0q0Q6pyXz++Emml/Kcue2BhPRTMjgBpJLJeic1W8lrAEhG/HyAFpNZAsGfhQQGdg0TGMdaUk/XXC4Rai3M+3SdPV0qH4IklJl2esGMLlQ2eFQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1602098577316139.67870375920245; Wed, 7 Oct 2020 12:22:57 -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-378-Arstv4xaN6WduiXQsNiLbA-1; Wed, 07 Oct 2020 15:22:53 -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 586E31019633; Wed, 7 Oct 2020 19:22:45 +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 36F9A60E1C; Wed, 7 Oct 2020 19:22:45 +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 04A4D8C7B2; Wed, 7 Oct 2020 19:22:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 097JMeaO005951 for ; Wed, 7 Oct 2020 15:22:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id B7C041001281; Wed, 7 Oct 2020 19:22:40 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3FA9F100164C for ; Wed, 7 Oct 2020 19:22:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602098575; 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=tLfN0A6VLSVjwoEfOlQwshyfEkPcmFIpbljMB2jbDHA=; b=a3+yp8ncmWMfsEA1puWUFTK2U2C0zGXRhSoDgCw6/CyXylZH+lNBQ8CvAtvDXI3eFYvLLV WY28+B9Uoq16CH1td7IUXHTLB2dpcXmsf6db3WNKFKWFzslfxj1PPXbpo9LZlBSou4IT1X XeVY8k3/cG8jVt6a05wSRF6zxqPUgQc= X-MC-Unique: Arstv4xaN6WduiXQsNiLbA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 08/13] conf: storage: use g_new0 Date: Wed, 7 Oct 2020 21:22:24 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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 Reviewed-by: Erik Skultety Reviewed-by: Neal Gompa --- src/conf/storage_conf.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index ae63cc725e..09769e6c79 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -572,8 +572,7 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, goto cleanup; =20 if (n) { - if (VIR_ALLOC_N(source->hosts, n) < 0) - goto cleanup; + source->hosts =3D g_new0(virStoragePoolSourceHost, n); source->nhost =3D n; =20 for (i =3D 0; i < source->nhost; i++) { @@ -703,8 +702,7 @@ virStoragePoolDefParseSourceString(const char *srcSpec, &xpath_ctxt))) return NULL; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virStoragePoolSource, 1); =20 if (!(node =3D virXPathNode("/source", xpath_ctxt))) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -814,8 +812,7 @@ virStoragePoolDefRefreshParse(xmlXPathContextPtr ctxt, return -1; } =20 - if (VIR_ALLOC(refresh) < 0) - return -1; + refresh =3D g_new0(virStoragePoolDefRefresh, 1); =20 refresh->volume.allocation =3D tmp; def->refresh =3D g_steal_pointer(&refresh); @@ -876,8 +873,7 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) g_autofree char *uuid =3D NULL; g_autofree char *target_path =3D NULL; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virStoragePoolDef, 1); =20 type =3D virXPathString("string(./@type)", ctxt); if (type =3D=3D NULL) { @@ -1324,8 +1320,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool, if (options =3D=3D NULL) return NULL; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virStorageVolDef, 1); =20 def->target.type =3D VIR_STORAGE_TYPE_FILE; =20 @@ -1370,8 +1365,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool, } } =20 - if (VIR_ALLOC(def->target.backingStore->perms) < 0) - return NULL; + def->target.backingStore->perms =3D g_new0(virStoragePerms, 1); if (virStorageDefParsePerms(ctxt, def->target.backingStore->perms, "./backingStore/permissions") < 0) return NULL; @@ -1417,8 +1411,7 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool, } } =20 - if (VIR_ALLOC(def->target.perms) < 0) - return NULL; + def->target.perms =3D g_new0(virStoragePerms, 1); if (virStorageDefParsePerms(ctxt, def->target.perms, "./target/permissions") < 0) return NULL; --=20 2.26.2 From nobody Thu May 2 14:38:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1602098582; cv=none; d=zohomail.com; s=zohoarc; b=DSaS8Ar5mF0E1RxYL6+WucTCI3mX3Tqu3wqesT2mikoyUfAjFieSBzvoBSEiFT3kBcM1jJDTLzwgdbecPLx18meDoPRohzBFYuVo1fYkxcgFUL3QtO12P18tYRKJPrVsHsKhpt96UqnttHobfQcbdcRinmDAonJeY7ReaGdg77g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602098582; 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=36zjFcXE8eks8U7Wf026CYlL8948klPizUbPPRYsSCY=; b=cYLecccYCeobLslIV7gwzd/2X1pRzh3f3NoLj/tX4z+WX9MNb6EGCpAosM47H5MzByQCUj2+yvAdcFQAkbsXAUjH69yOxwR4pTJeHs7iWuLD3rgPbHVG0yW6Bf7ORBw7IdrbYH1BAfGPIvycMFyDX00kdRiwPnoUMahkr7rwozk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1602098582410273.46766370008515; Wed, 7 Oct 2020 12:23:02 -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-212-14X3lapwNcWr5DNiSpIGkg-1; Wed, 07 Oct 2020 15:22:58 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CD416425DB; Wed, 7 Oct 2020 19:22:52 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A61B51001281; Wed, 7 Oct 2020 19:22:52 +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 7084F1832FD8; Wed, 7 Oct 2020 19:22:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 097JMfZg005965 for ; Wed, 7 Oct 2020 15:22:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8AA7A100164C; Wed, 7 Oct 2020 19:22:41 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 130EB1001281 for ; Wed, 7 Oct 2020 19:22:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602098581; 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=36zjFcXE8eks8U7Wf026CYlL8948klPizUbPPRYsSCY=; b=Rh6aqzYyYX/esY676hTDDO05It7kxtizFl7jEm/8HQaWD1amLLtyxWD30kRByzXoZbNQ4N uZVnf1ZJBe5Z4/D7D7J+MIkxjaG8c5OTicJoGq34HIkaI+HEYyj47FImjO3TUWNoGHZ1EJ 1mlZe/a/S28Hb4Di4Jei/tgU6Zu46Ak= X-MC-Unique: 14X3lapwNcWr5DNiSpIGkg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 09/13] conf: virsecretobj: use g_new0 Date: Wed, 7 Oct 2020 21:22:25 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.84 on 10.5.11.22 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 Reviewed-by: Erik Skultety Reviewed-by: Neal Gompa --- src/conf/virsecretobj.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c index 81c9f2c346..c98d52f1e4 100644 --- a/src/conf/virsecretobj.c +++ b/src/conf/virsecretobj.c @@ -465,10 +465,7 @@ virSecretObjListGetUUIDsCallback(void *payload, if (data->uuids) { char *uuidstr; =20 - if (VIR_ALLOC_N(uuidstr, VIR_UUID_STRING_BUFLEN) < 0) { - data->error =3D true; - goto cleanup; - } + uuidstr =3D g_new0(char, VIR_UUID_STRING_BUFLEN); =20 virUUIDFormat(def->uuid, uuidstr); data->uuids[data->nuuids++] =3D uuidstr; @@ -590,11 +587,8 @@ virSecretObjListExport(virConnectPtr conn, .nsecrets =3D 0, .error =3D false }; =20 virObjectRWLockRead(secretobjs); - if (secrets && - VIR_ALLOC_N(data.secrets, virHashSize(secretobjs->objs) + 1) < 0) { - virObjectRWUnlock(secretobjs); - return -1; - } + if (secrets) + data.secrets =3D g_new0(virSecretPtr, virHashSize(secretobjs->objs= )); =20 virHashForEach(secretobjs->objs, virSecretObjListExportCallback, &data= ); virObjectRWUnlock(secretobjs); @@ -735,8 +729,7 @@ virSecretObjGetValue(virSecretObjPtr obj) return NULL; } =20 - if (VIR_ALLOC_N(ret, obj->value_size) < 0) - return NULL; + ret =3D g_new0(unsigned char, obj->value_size); memcpy(ret, obj->value, obj->value_size); =20 return ret; @@ -753,8 +746,7 @@ virSecretObjSetValue(virSecretObjPtr obj, g_autofree unsigned char *new_value =3D NULL; size_t old_value_size; =20 - if (VIR_ALLOC_N(new_value, value_size) < 0) - return -1; + new_value =3D g_new0(unsigned char, value_size); =20 old_value =3D obj->value; old_value_size =3D obj->value_size; @@ -846,8 +838,7 @@ virSecretLoadValue(virSecretObjPtr obj) goto cleanup; } =20 - if (VIR_ALLOC_N(contents, st.st_size + 1) < 0) - goto cleanup; + contents =3D g_new0(char, st.st_size + 1); =20 if (saferead(fd, contents, st.st_size) !=3D st.st_size) { virReportSystemError(errno, _("cannot read '%s'"), --=20 2.26.2 From nobody Thu May 2 14:38:28 2024 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=1602098579; cv=none; d=zohomail.com; s=zohoarc; b=C4ib59suiBKSpUkuFqSmpYWV6WO38wqe2wth/FEAq+wlJF6hYWfTW4Rbi51VvRAaoHbtr+Sv6xdz/rRMiCn1AKPMMWGw03fURbETvIaB70vreYfQNZn4UOViQ/0eIc2yEs8KWwkNuhmz9vHdIIc1vwEn83u0X7//lZd+aDTGqMc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602098579; 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=XVe5ORxLk5g+nZ9gMKFAfDfjiJvMyR2g1j7WhWeKri8=; b=hwI4FaLsJEXh8MqFFQezCzmpQV51cTflu/xEvElZfC3E64B9tWbnP7cJ4V0hfEyj+fJ4HUHskGB4zyPugEpTgCWt14GQwQpcHuIIdoCz2/I6i6gBZVWIbnmtaS9OybNnoyVbTvQh7Jyw6pKiLST2pq/QZcg6P1VvK3iaxWx2F6U= 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 1602098579515719.812683766519; Wed, 7 Oct 2020 12:22:59 -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-439-ztROXXvVPkmTKcXBeb58sg-1; Wed, 07 Oct 2020 15:22:54 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B35CA1019627; Wed, 7 Oct 2020 19:22:48 +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 8FE4B100164C; Wed, 7 Oct 2020 19:22:48 +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 5AEA08C7B5; Wed, 7 Oct 2020 19:22:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 097JMgvF005975 for ; Wed, 7 Oct 2020 15:22:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5CB581001281; Wed, 7 Oct 2020 19:22:42 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id D9401100239A for ; Wed, 7 Oct 2020 19:22:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602098578; 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=XVe5ORxLk5g+nZ9gMKFAfDfjiJvMyR2g1j7WhWeKri8=; b=KRf4yRuNSBTDDk7a58mx+hvDMuOGkTABJ3Z1+hu7ZqtWX0+8QtqAyGCPf4aPy1v4BNeYMt uBtW17SOZwdoDpiztV4H5fwtXZE7IQlbc+0nu5T89hdcnZqbyV9WHsvZK7h/3f0WOxjUpb ckwLa7smw0y1jSRk+xKhjnUmqlgbMz8= X-MC-Unique: ztROXXvVPkmTKcXBeb58sg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 10/13] conf: nwfilter_params: use g_new0 Date: Wed, 7 Oct 2020 21:22:26 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.84 on 10.5.11.22 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 Reviewed-by: Erik Skultety Reviewed-by: Neal Gompa --- src/conf/nwfilter_params.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/src/conf/nwfilter_params.c b/src/conf/nwfilter_params.c index f2ec08012a..1210079954 100644 --- a/src/conf/nwfilter_params.c +++ b/src/conf/nwfilter_params.c @@ -70,8 +70,7 @@ virNWFilterVarValueCopy(const virNWFilterVarValue *val) size_t i; char *str; =20 - if (VIR_ALLOC(res) < 0) - return NULL; + res =3D g_new0(virNWFilterVarValue, 1); res->valType =3D val->valType; =20 switch (res->valType) { @@ -79,8 +78,7 @@ virNWFilterVarValueCopy(const virNWFilterVarValue *val) res->u.simple.value =3D g_strdup(val->u.simple.value); break; case NWFILTER_VALUE_TYPE_ARRAY: - if (VIR_ALLOC_N(res->u.array.values, val->u.array.nValues) < 0) - goto err_exit; + res->u.array.values =3D g_new0(char *, val->u.array.nValues); res->u.array.nValues =3D val->u.array.nValues; for (i =3D 0; i < val->u.array.nValues; i++) { str =3D g_strdup(val->u.array.values[i]); @@ -92,10 +90,6 @@ virNWFilterVarValueCopy(const virNWFilterVarValue *val) } =20 return res; - - err_exit: - virNWFilterVarValueFree(res); - return NULL; } =20 virNWFilterVarValuePtr @@ -109,8 +103,7 @@ virNWFilterVarValueCreateSimple(char *value) return NULL; } =20 - if (VIR_ALLOC(val) < 0) - return NULL; + val =3D g_new0(virNWFilterVarValue, 1); =20 val->valType =3D NWFILTER_VALUE_TYPE_SIMPLE; val->u.simple.value =3D value; @@ -219,10 +212,7 @@ virNWFilterVarValueAddValue(virNWFilterVarValuePtr val= , char *value) case NWFILTER_VALUE_TYPE_SIMPLE: /* switch to array */ tmp =3D val->u.simple.value; - if (VIR_ALLOC_N(val->u.array.values, 2) < 0) { - val->u.simple.value =3D tmp; - return -1; - } + val->u.array.values =3D g_new0(char *, 2); val->valType =3D NWFILTER_VALUE_TYPE_ARRAY; val->u.array.nValues =3D 2; val->u.array.values[0] =3D tmp; @@ -870,8 +860,7 @@ virNWFilterVarAccessParse(const char *varAccess) virNWFilterVarAccessPtr dest; const char *input =3D varAccess; =20 - if (VIR_ALLOC(dest) < 0) - return NULL; + dest =3D g_new0(virNWFilterVarAccess, 1); =20 idx =3D strspn(input, VALID_VARNAME); =20 --=20 2.26.2 From nobody Thu May 2 14:38:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1602098665; cv=none; d=zohomail.com; s=zohoarc; b=MGLJC/OMkpF9vL3htKDOOQe/hF0hGgVesBitt08RXZ9sECPa/D3iddMRdEHJIfPan7pEBOR7p1GeaCfFJpp47IfqxQGk+U8/J4JNmA45CUFX23Xs5xQfdpPTWU2WUYHb657lQKtPDHW3sM0UbCtqKg1hc4erfNvivA0YWNUijyw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602098665; 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=5D4SNFsfqbGkwj5vuVhhwdq3lhAoaBq/vh0/091O6sI=; b=jNcOp0NkEXIhdJAmmxslAgWJWF2kxbYxeSh146jFnp+jpWDZvqhmNdqoaO//vpm26lFh9vJbRed5c1ZHYK2iurcrHT8bPDfPKNT7EuKixt/TsbJXL+oD4gnPs4NFreL2dDim4gMh/1OcBpAFJkM7PDA8TEzwDy1QUCjDL3xIEIA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1602098665334542.0385792640648; Wed, 7 Oct 2020 12:24:25 -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-298-6UxTmbUTOW2DAS2G4P9oUg-1; Wed, 07 Oct 2020 15:23:01 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 70CCA804030; Wed, 7 Oct 2020 19:22:55 +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 52307702E7; Wed, 7 Oct 2020 19:22:55 +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 1D59A8C7BB; Wed, 7 Oct 2020 19:22:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 097JMh7D005993 for ; Wed, 7 Oct 2020 15:22:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2ED111001281; Wed, 7 Oct 2020 19:22:43 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB68D1000239 for ; Wed, 7 Oct 2020 19:22:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602098664; 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=5D4SNFsfqbGkwj5vuVhhwdq3lhAoaBq/vh0/091O6sI=; b=b6gEL+JEUa+pbDDYQYqMuqIe2S8soMtRYT/wCn8lkNrUufTpEabpYJ3M5s5k4xus68A4/U VcCTMA29gLmYkH4tSzfxUVoBPAmV+6iq36fFpX6mjSIeii/5wl/7QtdfPwedC2SxhX1BCS GVrHtKmUUQKQVWxBd6LmgOf0+xq6qhU= X-MC-Unique: 6UxTmbUTOW2DAS2G4P9oUg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 11/13] conf: cpu: use g_new0 Date: Wed, 7 Oct 2020 21:22:27 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.11 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 Reviewed-by: Erik Skultety Reviewed-by: Neal Gompa --- src/conf/cpu_conf.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 1910470836..7778e01131 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -153,9 +153,7 @@ virCPUDefCopyModelFilter(virCPUDefPtr dst, size_t i; size_t n; =20 - if (VIR_ALLOC_N(dst->features, src->nfeatures) < 0) - return -1; - + dst->features =3D g_new0(virCPUFeatureDef, src->nfeatures); dst->model =3D g_strdup(src->model); dst->vendor =3D g_strdup(src->vendor); dst->vendor_id =3D g_strdup(src->vendor_id); @@ -248,16 +246,12 @@ virCPUDefCopyWithoutModel(const virCPUDef *cpu) copy->migratable =3D cpu->migratable; =20 if (cpu->cache) { - if (VIR_ALLOC(copy->cache) < 0) - return NULL; - + copy->cache =3D g_new0(virCPUCacheDef, 1); *copy->cache =3D *cpu->cache; } =20 if (cpu->tsc) { - if (VIR_ALLOC(copy->tsc) < 0) - return NULL; - + copy->tsc =3D g_new0(virHostCPUTscInfo, 1); *copy->tsc =3D *cpu->tsc; } =20 @@ -1156,8 +1150,7 @@ virCPUDefListParse(const char **xmlCPUs, goto error; } =20 - if (VIR_ALLOC_N(cpus, ncpus + 1)) - goto error; + cpus =3D g_new0(virCPUDefPtr, ncpus + 1); =20 for (i =3D 0; i < ncpus; i++) { if (!(doc =3D virXMLParseStringCtxt(xmlCPUs[i], _("(CPU_definition= )"), &ctxt))) --=20 2.26.2 From nobody Thu May 2 14:38:28 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1602098596; cv=none; d=zohomail.com; s=zohoarc; b=mtvlgr/uR7VgklzdgRzmTzPOmDefwVdnZc248fUAcfiaoGTbjS7enK/C6O2gX288OgQdpIhxTlq5Ib6qhwVMX4r4GnRMfHtQdXaG2Q2pMUwWkZ+1sQIJBBEE9r7Nesrh0EDLBguXX8oaWy0L/VHqhkjUaXUPlkablY+4Y1wsW3Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602098596; 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=X7sNdf/WgDs8UB1X+oo/HG84Gr6lmjmSpdMxM+UXi3M=; b=NgOTNgYUcxs3JiD9xghiApFrSeOjrTQE82vR4M+t3lcn2yZntLUafhBg1rrPxestUEFP9VUpl/igbCmkkwmlTyPWQ4Z/KK7rQOm45AQs62BWEwHv2fv16+RL5Jvr8KGixrz2UHWkNVTNq8ZImQKJOXj5Y2i8YlmFT/ja+p+1Dsg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1602098596228616.7292243039773; Wed, 7 Oct 2020 12:23:16 -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-305--JH93dgXMYyV-Yeco_0Fmw-1; Wed, 07 Oct 2020 15:23:05 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 357C6101962F; Wed, 7 Oct 2020 19:22:58 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0F406100164C; Wed, 7 Oct 2020 19:22:58 +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 D21C31832FC3; Wed, 7 Oct 2020 19:22:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 097JMip5006005 for ; Wed, 7 Oct 2020 15:22:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0225E1002C04; Wed, 7 Oct 2020 19:22:44 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E0E41001281 for ; Wed, 7 Oct 2020 19:22:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602098594; 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=X7sNdf/WgDs8UB1X+oo/HG84Gr6lmjmSpdMxM+UXi3M=; b=KjlmTgDXLQEOql8ArBrRA73U2ub4nOHoqmWRODPft0yCDyhhLKzHPrUECxGp9DbEXysIEO putzDybqY2E+Z4Wi/9tUV4B924z4UJhNXBqfQkRgYFuvaLPjbOHTNMr3MO4SkCy6PYGAFg PWUNw/xHeNl7BJ7H/Ysb7hs4jxKxJ6o= X-MC-Unique: -JH93dgXMYyV-Yeco_0Fmw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 12/13] conf: use g_new0 Date: Wed, 7 Oct 2020 21:22:28 +0200 Message-Id: <9e0442374a43aee38b5ddf012fa66c43c1a53cf3.1602098503.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.84 on 10.5.11.22 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 Reviewed-by: Erik Skultety Reviewed-by: Neal Gompa --- src/conf/checkpoint_conf.c | 4 ++-- src/conf/domain_capabilities.c | 7 +------ src/conf/domain_event.c | 3 +-- src/conf/domain_nwfilter.c | 3 +-- src/conf/netdev_bandwidth_conf.c | 9 +++------ src/conf/netdev_vlan_conf.c | 4 +--- src/conf/netdev_vport_profile_conf.c | 3 +-- src/conf/networkcommon_conf.c | 3 +-- src/conf/nwfilter_conf.c | 12 ++++-------- src/conf/object_event.c | 11 +++-------- src/conf/secret_conf.c | 3 +-- src/conf/snapshot_conf.c | 4 ++-- src/conf/virchrdev.c | 10 +++------- src/conf/virdomaincheckpointobjlist.c | 10 +++++----- src/conf/virdomainmomentobjlist.c | 6 ++---- src/conf/virdomainobjlist.c | 8 ++------ src/conf/virdomainsnapshotobjlist.c | 9 ++++----- src/conf/virinterfaceobj.c | 5 ++--- src/conf/virnetworkobj.c | 7 +++---- src/conf/virnetworkportdef.c | 4 ++-- src/conf/virnodedeviceobj.c | 7 ++----- src/conf/virnwfilterbindingdef.c | 6 ++---- src/conf/virnwfilterbindingobjlist.c | 8 ++------ src/conf/virnwfilterobj.c | 9 +++------ 24 files changed, 53 insertions(+), 102 deletions(-) diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c index f97621dabf..e175917eae 100644 --- a/src/conf/checkpoint_conf.c +++ b/src/conf/checkpoint_conf.c @@ -182,8 +182,8 @@ virDomainCheckpointDefParse(xmlXPathContextPtr ctxt, =20 if ((n =3D virXPathNodeSet("./disks/*", ctxt, &nodes)) < 0) return NULL; - if (n && VIR_ALLOC_N(def->disks, n) < 0) - return NULL; + if (n) + def->disks =3D g_new0(virDomainCheckpointDiskDef, n); def->ndisks =3D n; for (i =3D 0; i < def->ndisks; i++) { if (virDomainCheckpointDiskDefParseXML(nodes[i], ctxt, diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index 59ad8937a4..6ee8730111 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -155,15 +155,10 @@ virDomainCapsCPUModelsNew(size_t nmodels) if (!(cpuModels =3D virObjectNew(virDomainCapsCPUModelsClass))) return NULL; =20 - if (VIR_ALLOC_N(cpuModels->models, nmodels) < 0) - goto error; + cpuModels->models =3D g_new0(virDomainCapsCPUModel, nmodels); cpuModels->nmodels_max =3D nmodels; =20 return cpuModels; - - error: - virObjectUnref(cpuModels); - return NULL; } =20 =20 diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c index d3acde0236..a8bd9f1595 100644 --- a/src/conf/domain_event.c +++ b/src/conf/domain_event.c @@ -2242,8 +2242,7 @@ virDomainQemuMonitorEventStateRegisterID(virConnectPt= r conn, virCheckFlags(VIR_CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_REGEX= | VIR_CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_NOCAS= E, -1); - if (VIR_ALLOC(data) < 0) - return -1; + data =3D g_new0(virDomainQemuMonitorEventData, 1); data->flags =3D flags; if (event && flags !=3D -1) { if (flags & VIR_CONNECT_DOMAIN_QEMU_MONITOR_EVENT_REGISTER_REGEX) { diff --git a/src/conf/domain_nwfilter.c b/src/conf/domain_nwfilter.c index a72db6f876..ef388d5d02 100644 --- a/src/conf/domain_nwfilter.c +++ b/src/conf/domain_nwfilter.c @@ -44,8 +44,7 @@ virNWFilterBindingDefForNet(const char *vmname, { virNWFilterBindingDefPtr ret; =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(virNWFilterBindingDef, 1); =20 ret->ownername =3D g_strdup(vmname); =20 diff --git a/src/conf/netdev_bandwidth_conf.c b/src/conf/netdev_bandwidth_c= onf.c index 396ac62019..831ee036ac 100644 --- a/src/conf/netdev_bandwidth_conf.c +++ b/src/conf/netdev_bandwidth_conf.c @@ -121,8 +121,7 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidt= h, xmlNodePtr in =3D NULL, out =3D NULL; char *class_id_prop =3D NULL; =20 - if (VIR_ALLOC(def) < 0) - return ret; + def =3D g_new0(virNetDevBandwidth, 1); =20 if (!node || !virXMLNodeNameEqual(node, "bandwidth")) { virReportError(VIR_ERR_INVALID_ARG, "%s", @@ -173,8 +172,7 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidt= h, } =20 if (in) { - if (VIR_ALLOC(def->in) < 0) - goto cleanup; + def->in =3D g_new0(virNetDevBandwidthRate, 1); =20 if (virNetDevBandwidthParseRate(in, def->in) < 0) { /* helper reported error for us */ @@ -189,8 +187,7 @@ virNetDevBandwidthParse(virNetDevBandwidthPtr *bandwidt= h, } =20 if (out) { - if (VIR_ALLOC(def->out) < 0) - goto cleanup; + def->out =3D g_new0(virNetDevBandwidthRate, 1); =20 if (virNetDevBandwidthParseRate(out, def->out) < 0) { /* helper reported error for us */ diff --git a/src/conf/netdev_vlan_conf.c b/src/conf/netdev_vlan_conf.c index 493708fee1..6c93279ec5 100644 --- a/src/conf/netdev_vlan_conf.c +++ b/src/conf/netdev_vlan_conf.c @@ -53,9 +53,7 @@ virNetDevVlanParse(xmlNodePtr node, xmlXPathContextPtr ct= xt, virNetDevVlanPtr de goto cleanup; } =20 - if (VIR_ALLOC_N(def->tag, nTags) < 0) - goto cleanup; - + def->tag =3D g_new0(unsigned int, nTags); def->nativeMode =3D 0; def->nativeTag =3D 0; for (i =3D 0; i < nTags; i++) { diff --git a/src/conf/netdev_vport_profile_conf.c b/src/conf/netdev_vport_p= rofile_conf.c index 1dd8439adb..fdc689b38a 100644 --- a/src/conf/netdev_vport_profile_conf.c +++ b/src/conf/netdev_vport_profile_conf.c @@ -39,8 +39,7 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned int = flags) virNetDevVPortProfilePtr virtPort =3D NULL; xmlNodePtr cur =3D node->children; =20 - if (VIR_ALLOC(virtPort) < 0) - return NULL; + virtPort =3D g_new0(virNetDevVPortProfile, 1); =20 if ((virtPortType =3D virXMLPropString(node, "type")) && (virtPort->virtPortType =3D virNetDevVPortTypeFromString(virtPortT= ype)) <=3D 0) { diff --git a/src/conf/networkcommon_conf.c b/src/conf/networkcommon_conf.c index 2e51c80174..26eeb6dbda 100644 --- a/src/conf/networkcommon_conf.c +++ b/src/conf/networkcommon_conf.c @@ -44,8 +44,7 @@ virNetDevIPRouteCreate(const char *errorDetail, virNetDevIPRoutePtr def =3D NULL; virSocketAddr testAddr; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virNetDevIPRoute, 1); =20 def->family =3D g_strdup(family); =20 diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index 53794e8f6d..be684c3512 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -2069,8 +2069,7 @@ virNWFilterIncludeParse(xmlNodePtr cur) { virNWFilterIncludeDefPtr ret; =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(virNWFilterIncludeDef, 1); =20 ret->filterref =3D virXMLPropString(cur, "filter"); if (!ret->filterref) { @@ -2423,8 +2422,7 @@ virNWFilterRuleParse(xmlNodePtr node) xmlNodePtr cur; virNWFilterRuleDefPtr ret; =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(virNWFilterRuleDef, 1); =20 action =3D virXMLPropString(node, "action"); direction =3D virXMLPropString(node, "direction"); @@ -2616,8 +2614,7 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt) int chain_priority; const char *name_prefix; =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(virNWFilterDef, 1); =20 ret->name =3D virXPathString("string(./@name)", ctxt); if (!ret->name) { @@ -2689,8 +2686,7 @@ virNWFilterDefParseXML(xmlXPathContextPtr ctxt) =20 while (curr !=3D NULL) { if (curr->type =3D=3D XML_ELEMENT_NODE) { - if (VIR_ALLOC(entry) < 0) - goto cleanup; + entry =3D g_new0(virNWFilterEntry, 1); =20 if (virXMLNodeNameEqual(curr, "rule")) { if (!(entry->rule =3D virNWFilterRuleParse(curr))) { diff --git a/src/conf/object_event.c b/src/conf/object_event.c index 408e0fd2b2..28e75f8b59 100644 --- a/src/conf/object_event.c +++ b/src/conf/object_event.c @@ -424,8 +424,7 @@ virObjectEventCallbackListAddID(virConnectPtr conn, return -1; } /* Allocate new cb */ - if (VIR_ALLOC(cb) < 0) - goto cleanup; + cb =3D g_new0(virObjectEventCallback, 1); cb->conn =3D virObjectRef(conn); *callbackID =3D cb->callbackID =3D cbList->nextID++; cb->cb =3D callback; @@ -501,10 +500,7 @@ virObjectEventQueueFree(virObjectEventQueuePtr queue) static virObjectEventQueuePtr virObjectEventQueueNew(void) { - virObjectEventQueuePtr ret; - - ignore_value(VIR_ALLOC(ret)); - return ret; + return g_new0(virObjectEventQueue, 1); } =20 =20 @@ -566,8 +562,7 @@ virObjectEventStateNew(void) if (!(state =3D virObjectLockableNew(virObjectEventStateClass))) return NULL; =20 - if (VIR_ALLOC(state->callbacks) < 0) - goto error; + state->callbacks =3D g_new0(virObjectEventCallbackList, 1); =20 if (!(state->queue =3D virObjectEventQueueNew())) goto error; diff --git a/src/conf/secret_conf.c b/src/conf/secret_conf.c index 2e35348ce1..273987bdb4 100644 --- a/src/conf/secret_conf.c +++ b/src/conf/secret_conf.c @@ -149,8 +149,7 @@ secretXMLParseNode(xmlDocPtr xml, xmlNodePtr root) =20 ctxt->node =3D root; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virSecretDef, 1); =20 prop =3D virXPathString("string(./@ephemeral)", ctxt); if (prop !=3D NULL) { diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 7090e3a1b0..31cce15d53 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -367,8 +367,8 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, if ((n =3D virXPathNodeSet("./disks/*", ctxt, &nodes)) < 0) goto cleanup; if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_DISKS) { - if (n && VIR_ALLOC_N(def->disks, n) < 0) - goto cleanup; + if (n) + def->disks =3D g_new0(virDomainSnapshotDiskDef, n); def->ndisks =3D n; for (i =3D 0; i < def->ndisks; i++) { if (virDomainSnapshotDiskDefParseXML(nodes[i], ctxt, &def->dis= ks[i], diff --git a/src/conf/virchrdev.c b/src/conf/virchrdev.c index 635aa43c49..c50f9ca720 100644 --- a/src/conf/virchrdev.c +++ b/src/conf/virchrdev.c @@ -255,8 +255,7 @@ static void virChrdevFDStreamCloseCb(virStreamPtr st G_= GNUC_UNUSED, virChrdevsPtr virChrdevAlloc(void) { virChrdevsPtr devs; - if (VIR_ALLOC(devs) < 0) - return NULL; + devs =3D g_new0(virChrdevs, 1); =20 if (virMutexInit(&devs->lock) < 0) { virReportSystemError(errno, "%s", @@ -388,11 +387,8 @@ int virChrdevOpen(virChrdevsPtr devs, return -1; } =20 - if (VIR_ALLOC(cbdata) < 0) - goto error; - - if (VIR_ALLOC(ent) < 0) - goto error; + cbdata =3D g_new0(virChrdevStreamInfo, 1); + ent =3D g_new0(virChrdevHashEntry, 1); =20 ent->st =3D st; ent->dev =3D g_strdup(path); diff --git a/src/conf/virdomaincheckpointobjlist.c b/src/conf/virdomainchec= kpointobjlist.c index a4942ea706..c6f2fbe46f 100644 --- a/src/conf/virdomaincheckpointobjlist.c +++ b/src/conf/virdomaincheckpointobjlist.c @@ -62,8 +62,8 @@ virDomainCheckpointObjListNew(void) { virDomainCheckpointObjListPtr checkpoints; =20 - if (VIR_ALLOC(checkpoints) < 0) - return NULL; + checkpoints =3D g_new0(virDomainCheckpointObjList, + 1); checkpoints->base =3D virDomainMomentObjListNew(); if (!checkpoints->base) { VIR_FREE(checkpoints); @@ -216,9 +216,9 @@ virDomainListCheckpoints(virDomainCheckpointObjListPtr = checkpoints, =20 if (!chks || count < 0) return count; - if (VIR_ALLOC_N(names, count) < 0 || - VIR_ALLOC_N(list, count + 1) < 0) - goto cleanup; + + names =3D g_new0(char *, count); + list =3D g_new0(virDomainCheckpointPtr, count + 1); =20 if (virDomainCheckpointObjListGetNames(checkpoints, from, names, count, flags) < 0) diff --git a/src/conf/virdomainmomentobjlist.c b/src/conf/virdomainmomentob= jlist.c index 18dbd434fb..8a1eb6b734 100644 --- a/src/conf/virdomainmomentobjlist.c +++ b/src/conf/virdomainmomentobjlist.c @@ -212,8 +212,7 @@ virDomainMomentObjNew(void) { virDomainMomentObjPtr moment; =20 - if (VIR_ALLOC(moment) < 0) - return NULL; + moment =3D g_new0(virDomainMomentObj, 1); =20 VIR_DEBUG("obj=3D%p", moment); =20 @@ -275,8 +274,7 @@ virDomainMomentObjListNew(void) { virDomainMomentObjListPtr moments; =20 - if (VIR_ALLOC(moments) < 0) - return NULL; + moments =3D g_new0(virDomainMomentObjList, 1); moments->objs =3D virHashCreate(50, virDomainMomentObjListDataFree); if (!moments->objs) { VIR_FREE(moments); diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c index 417025ae9f..46b28cc9a6 100644 --- a/src/conf/virdomainobjlist.c +++ b/src/conf/virdomainobjlist.c @@ -981,10 +981,7 @@ virDomainObjListCollect(virDomainObjListPtr domlist, =20 virObjectRWLockRead(domlist); sa_assert(domlist->objs); - if (VIR_ALLOC_N(data.vms, virHashSize(domlist->objs)) < 0) { - virObjectRWUnlock(domlist); - return -1; - } + data.vms =3D g_new0(virDomainObjPtr, virHashSize(domlist->objs)); =20 virHashForEach(domlist->objs, virDomainObjListCollectIterator, &data); virObjectRWUnlock(domlist); @@ -1074,8 +1071,7 @@ virDomainObjListExport(virDomainObjListPtr domlist, return -1; =20 if (domains) { - if (VIR_ALLOC_N(doms, nvms + 1) < 0) - goto cleanup; + doms =3D g_new0(virDomainPtr, nvms + 1); =20 for (i =3D 0; i < nvms; i++) { virDomainObjPtr vm =3D vms[i]; diff --git a/src/conf/virdomainsnapshotobjlist.c b/src/conf/virdomainsnapsh= otobjlist.c index 910b0714c7..f13150e463 100644 --- a/src/conf/virdomainsnapshotobjlist.c +++ b/src/conf/virdomainsnapshotobjlist.c @@ -85,8 +85,8 @@ virDomainSnapshotObjListNew(void) { virDomainSnapshotObjListPtr snapshots; =20 - if (VIR_ALLOC(snapshots) < 0) - return NULL; + snapshots =3D g_new0(virDomainSnapshotObjList, + 1); snapshots->base =3D virDomainMomentObjListNew(); if (!snapshots->base) { VIR_FREE(snapshots); @@ -267,9 +267,8 @@ virDomainListSnapshots(virDomainSnapshotObjListPtr snap= shots, =20 if (!snaps || count < 0) return count; - if (VIR_ALLOC_N(names, count) < 0 || - VIR_ALLOC_N(list, count + 1) < 0) - goto cleanup; + names =3D g_new0(char *, count); + list =3D g_new0(virDomainSnapshotPtr, count + 1); =20 if (virDomainSnapshotObjListGetNames(snapshots, from, names, count, flags) < 0) diff --git a/src/conf/virinterfaceobj.c b/src/conf/virinterfaceobj.c index 43ba395d2b..5a5fd65e14 100644 --- a/src/conf/virinterfaceobj.c +++ b/src/conf/virinterfaceobj.c @@ -319,9 +319,8 @@ virInterfaceObjListExport(virConnectPtr conn, .nifaces =3D 0, .error =3D false }; =20 virObjectRWLockRead(ifaceobjs); - if (ifaces && VIR_ALLOC_N(data.ifaces, - virHashSize(ifaceobjs->objsName) + 1) < 0) - goto cleanup; + if (ifaces) + data.ifaces =3D g_new0(virInterfacePtr, virHashSize(ifaceobjs->obj= sName)); =20 virHashForEach(ifaceobjs->objsName, virInterfaceObjListExportCallback,= &data); =20 diff --git a/src/conf/virnetworkobj.c b/src/conf/virnetworkobj.c index aefe23fde1..1fcfa9cdc2 100644 --- a/src/conf/virnetworkobj.c +++ b/src/conf/virnetworkobj.c @@ -1406,8 +1406,8 @@ virNetworkObjListExport(virConnectPtr conn, .nnets =3D 0, .error =3D false }; =20 virObjectRWLockRead(netobjs); - if (nets && VIR_ALLOC_N(data.nets, virHashSize(netobjs->objs) + 1) < 0) - goto cleanup; + if (nets) + data.nets =3D g_new0(virNetworkPtr, virHashSize(netobjs->objs)); =20 virHashForEach(netobjs->objs, virNetworkObjListExportCallback, &data); =20 @@ -1801,8 +1801,7 @@ virNetworkObjPortListExport(virNetworkPtr net, if (ports) { *ports =3D NULL; =20 - if (VIR_ALLOC_N(data.ports, virHashSize(obj->ports) + 1) < 0) - goto cleanup; + data.ports =3D g_new0(virNetworkPortPtr, virHashSize(obj->ports)); } =20 virHashForEach(obj->ports, virNetworkObjPortListExportCallback, &data); diff --git a/src/conf/virnetworkportdef.c b/src/conf/virnetworkportdef.c index 1db3dc69e2..3183078195 100644 --- a/src/conf/virnetworkportdef.c +++ b/src/conf/virnetworkportdef.c @@ -95,8 +95,8 @@ virNetworkPortDefParseXML(xmlXPathContextPtr ctxt) g_autofree char *managed =3D NULL; g_autofree char *driver =3D NULL; =20 - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virNetworkPortDef, + 1); =20 uuid =3D virXPathString("string(./uuid)", ctxt); if (!uuid) { diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c index 8aefd15e94..28905c67b6 100644 --- a/src/conf/virnodedeviceobj.c +++ b/src/conf/virnodedeviceobj.c @@ -930,11 +930,8 @@ virNodeDeviceObjListExport(virConnectPtr conn, .devices =3D NULL, .ndevices =3D 0, .error =3D false }; =20 virObjectRWLockRead(devs); - if (devices && - VIR_ALLOC_N(data.devices, virHashSize(devs->objs) + 1) < 0) { - virObjectRWUnlock(devs); - return -1; - } + if (devices) + data.devices =3D g_new0(virNodeDevicePtr, virHashSize(devs->objs)); =20 virHashForEach(devs->objs, virNodeDeviceObjListExportCallback, &data); virObjectRWUnlock(devs); diff --git a/src/conf/virnwfilterbindingdef.c b/src/conf/virnwfilterbinding= def.c index f286bdd840..81f8e72182 100644 --- a/src/conf/virnwfilterbindingdef.c +++ b/src/conf/virnwfilterbindingdef.c @@ -51,8 +51,7 @@ virNWFilterBindingDefCopy(virNWFilterBindingDefPtr src) { virNWFilterBindingDefPtr ret; =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(virNWFilterBindingDef, 1); =20 ret->ownername =3D g_strdup(src->ownername); =20 @@ -88,8 +87,7 @@ virNWFilterBindingDefParseXML(xmlXPathContextPtr ctxt) char *mac =3D NULL; xmlNodePtr node; =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(virNWFilterBindingDef, 1); =20 ret->portdevname =3D virXPathString("string(./portdev/@name)", ctxt); if (!ret->portdevname) { diff --git a/src/conf/virnwfilterbindingobjlist.c b/src/conf/virnwfilterbin= dingobjlist.c index 97e4d3c49b..328b1b8482 100644 --- a/src/conf/virnwfilterbindingobjlist.c +++ b/src/conf/virnwfilterbindingobjlist.c @@ -434,10 +434,7 @@ virNWFilterBindingObjListCollect(virNWFilterBindingObj= ListPtr domlist, =20 virObjectRWLockRead(domlist); sa_assert(domlist->objs); - if (VIR_ALLOC_N(data.bindings, virHashSize(domlist->objs)) < 0) { - virObjectRWUnlock(domlist); - return -1; - } + data.bindings =3D g_new0(virNWFilterBindingObjPtr, virHashSize(domlist= ->objs)); =20 virHashForEach(domlist->objs, virNWFilterBindingObjListCollectIterator= , &data); virObjectRWUnlock(domlist); @@ -467,8 +464,7 @@ virNWFilterBindingObjListExport(virNWFilterBindingObjLi= stPtr bindings, return -1; =20 if (bindinglist) { - if (VIR_ALLOC_N(*bindinglist, nbindings + 1) < 0) - goto cleanup; + *bindinglist =3D g_new0(virNWFilterBindingPtr, nbindings + 1); =20 for (i =3D 0; i < nbindings; i++) { virNWFilterBindingObjPtr binding =3D bindingobjs[i]; diff --git a/src/conf/virnwfilterobj.c b/src/conf/virnwfilterobj.c index c9e224061d..fce402f907 100644 --- a/src/conf/virnwfilterobj.c +++ b/src/conf/virnwfilterobj.c @@ -53,8 +53,7 @@ virNWFilterObjNew(void) { virNWFilterObjPtr obj; =20 - if (VIR_ALLOC(obj) < 0) - return NULL; + obj =3D g_new0(virNWFilterObj, 1); =20 if (virMutexInitRecursive(&obj->lock) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -120,8 +119,7 @@ virNWFilterObjListNew(void) { virNWFilterObjListPtr nwfilters; =20 - if (VIR_ALLOC(nwfilters) < 0) - return NULL; + nwfilters =3D g_new0(virNWFilterObjList, 1); return nwfilters; } =20 @@ -450,8 +448,7 @@ virNWFilterObjListExport(virConnectPtr conn, goto cleanup; } =20 - if (VIR_ALLOC_N(tmp_filters, nwfilters->count + 1) < 0) - goto cleanup; + tmp_filters =3D g_new0(virNWFilterPtr, nwfilters->count + 1); =20 for (i =3D 0; i < nwfilters->count; i++) { obj =3D nwfilters->objs[i]; --=20 2.26.2 From nobody Thu May 2 14:38:28 2024 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=1602098591; cv=none; d=zohomail.com; s=zohoarc; b=QNlOo4wQG9xwyrV0zT9+GQ1o7vMQ3JgkwbNT8xdPSIjWJ3o5J54bzHzy8n3nQAJbTJealMcCNwx61XPxX0M0/kYI4tB1A1vvWbvD9XDTOc06LyX+KRMsQ7JkJPrBvQUXpe/ltvT4yqsHjMKynS/OIjxSGiYNDFhbTeV9RKWAw6o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602098591; 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=GeLARcztHSNxtsjH8EtqVZx+iCUvX96IwIqQhf7YJtU=; b=msQsEejeNDkxD8W2TgkXU4gumv6I/lxnI7uGF7DKGuCeER55qKONG6xTD01GEO6T62HvBZrtEodi/WC+7UqQd+g/hmayrm1immuGXbr2jm8XjaX+aRssS09nKmFJvkWfM0X9NNtT73Hk5u+0UpABeP9cmMM+C25BJ84xapTNWGU= 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 1602098591213822.8708838518219; Wed, 7 Oct 2020 12:23:11 -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-459-jnd7HG_UPyCAFx7PvetDCA-1; Wed, 07 Oct 2020 15:23:06 -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 096CE18A8230; Wed, 7 Oct 2020 19:23:01 +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 DBF8165F5E; Wed, 7 Oct 2020 19:23:00 +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 A85858C7BD; Wed, 7 Oct 2020 19:23:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 097JMiwk006011 for ; Wed, 7 Oct 2020 15:22:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id C7F5C1001281; Wed, 7 Oct 2020 19:22:44 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50353100239A for ; Wed, 7 Oct 2020 19:22:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602098590; 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=GeLARcztHSNxtsjH8EtqVZx+iCUvX96IwIqQhf7YJtU=; b=E8x3ImWapftZQzFLwuL5pBaHylJBF4dvJfjqcd4nOjH4L5P/sYvyNz0uVBNAZNPuC5DRPD hn3/dRbwkx+g4MmPOTw4bT8G4KCV2N7NXXQ4SX7M8bhJew0HhwfXyp3+qOr5llJz5FfUQ5 NlRp83nLwD03SrzPmK3jMeM7MnSbl7A= X-MC-Unique: jnd7HG_UPyCAFx7PvetDCA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 13/13] conf: virDomainUSBAddressHubNew: refactor Date: Wed, 7 Oct 2020 21:22:29 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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) Remove the pointless variable and pointer stealing. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety Reviewed-by: Neal Gompa --- src/conf/domain_addr.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index ab508b0c8f..03d0c6825d 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -2029,7 +2029,7 @@ virDomainUSBAddressControllerModelToPorts(virDomainCo= ntrollerDefPtr cont) static virDomainUSBAddressHubPtr virDomainUSBAddressHubNew(size_t nports) { - virDomainUSBAddressHubPtr hub =3D NULL, ret =3D NULL; + virDomainUSBAddressHubPtr hub; =20 hub =3D g_new0(virDomainUSBAddressHub, 1); =20 @@ -2038,9 +2038,7 @@ virDomainUSBAddressHubNew(size_t nports) hub->ports =3D g_new0(virDomainUSBAddressHubPtr, nports); hub->nports =3D nports; =20 - ret =3D g_steal_pointer(&hub); - virDomainUSBAddressHubFree(hub); - return ret; + return hub; } =20 =20 --=20 2.26.2