From nobody Sun Feb 8 13:27:39 2026 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 --- 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