From nobody Mon Nov 25 21:27:59 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1594156444; cv=none; d=zohomail.com; s=zohoarc; b=DIZSmkLR5SSGiV0xSrU9TSYZgdfZvT+xlsE+/WDbnCFTtEDNHu9aJECrzZ5UcWq7g+lQZ4p+KIEPLubpEuyY2ry05+B9teGEKrqoVzdQjthn3tOQuOf2YuijSWsH4lZhWy4ztMqR+v/7Jv4mlItaZ1HQfxhYarxyI89HToKF5kw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594156444; 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=7YroraUqqy5ywvPA8rJg5OC0Z/GgfHaoYoYjlxKaQX8=; b=bJZOobadGapsytb9bcLWcuIdEsVbG/zocvmSpeX6lXaBypQyPWG3lDenKEX5FFMEkQDgw3B0eJ+CIwzxVryhsa6O9PkdB2urabvjfs1uKTBbrPiLwlQ6EVt2KD+QHhEGpZiYnT+qoV4z3HTYwGwjGTgAj2IkswGAV/o6DeDbZWU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1594156444137380.74283808820667; Tue, 7 Jul 2020 14:14:04 -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-394-UtUEOvCzMbKrE8jJPNLEzQ-1; Tue, 07 Jul 2020 17:12:05 -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 A4C1FEC1A5; Tue, 7 Jul 2020 21:11:59 +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 878295BAC3; Tue, 7 Jul 2020 21:11:59 +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 5B32472F74; Tue, 7 Jul 2020 21:11:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 067L8OOr007948 for ; Tue, 7 Jul 2020 17:08:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id D6C10797E0; Tue, 7 Jul 2020 21:08:24 +0000 (UTC) Received: from vhost2.laine.org (ovpn-112-194.phx2.redhat.com [10.3.112.194]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8FCDF79220 for ; Tue, 7 Jul 2020 21:08:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594156442; 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=7YroraUqqy5ywvPA8rJg5OC0Z/GgfHaoYoYjlxKaQX8=; b=PZC9SywYUwe25dckixWAC6E6AJo5dBKcN3bpe4itUEvlEt/SuscXwZAr78ibJLbAmj5r8b YIFnNg919rYChHXkkwgq2PA6oisyBRQixDArWt2hstTtyuz4vU8spw+4BqTSZ7cQ8Z5GmF 0iKWFcID/csXAXcSQtNE7sS6hATiX6I= X-MC-Unique: UtUEOvCzMbKrE8jJPNLEzQ-1 From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH v2 04/15] network: replace VIR_ALLOC/REALLOC with g_new0/g_renew Date: Tue, 7 Jul 2020 17:08:04 -0400 Message-Id: <20200707210815.1797463-5-laine@redhat.com> In-Reply-To: <20200707210815.1797463-1-laine@redhat.com> References: <20200707210815.1797463-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Laine Stump Reviewed-by: J=C3=A1n Tomko --- src/network/bridge_driver.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 713763130b..ab359acdb5 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -177,8 +177,7 @@ networkDnsmasqDefNamespaceParseOptions(networkDnsmasqXm= lNsDefPtr nsdef, if (nnodes =3D=3D 0) return 0; =20 - if (VIR_ALLOC_N(nsdef->options, nnodes) < 0) - return -1; + nsdef->options =3D g_new0(char *, nnodes); =20 for (i =3D 0; i < nnodes; i++) { if (!(nsdef->options[nsdef->noptions++] =3D virXMLPropString(nodes= [i], "value"))) { @@ -196,12 +195,9 @@ static int networkDnsmasqDefNamespaceParse(xmlXPathContextPtr ctxt, void **data) { - networkDnsmasqXmlNsDefPtr nsdata =3D NULL; + networkDnsmasqXmlNsDefPtr nsdata =3D g_new0(networkDnsmasqXmlNsDef, 1); int ret =3D -1; =20 - if (VIR_ALLOC(nsdata) < 0) - return -1; - if (networkDnsmasqDefNamespaceParseOptions(nsdata, ctxt)) goto cleanup; =20 @@ -733,8 +729,7 @@ networkStateInitialize(bool privileged, return -1; } =20 - if (VIR_ALLOC(network_driver) < 0) - goto error; + network_driver =3D g_new0(virNetworkDriverState, 1); =20 network_driver->lockFD =3D -1; if (virMutexInit(&network_driver->lock) < 0) { @@ -2753,8 +2748,7 @@ networkCreateInterfacePool(virNetworkDefPtr netdef) goto cleanup; } =20 - if (VIR_ALLOC_N(netdef->forward.ifs, numVirtFns) < 0) - goto cleanup; + netdef->forward.ifs =3D g_new0(virNetworkForwardIfDef, numVirtFns); =20 for (i =3D 0; i < numVirtFns; i++) { virPCIDeviceAddressPtr thisVirtFn =3D virtFns[i]; @@ -4323,8 +4317,7 @@ networkGetDHCPLeases(virNetworkPtr net, continue; =20 if (need_results) { - if (VIR_ALLOC(lease) < 0) - goto error; + lease =3D g_new0(virNetworkDHCPLease, 1); =20 lease->expirytime =3D expirytime_tmp; =20 @@ -4378,9 +4371,8 @@ networkGetDHCPLeases(virNetworkPtr net, =20 if (leases_ret) { /* NULL terminated array */ - ignore_value(VIR_REALLOC_N(leases_ret, nleases + 1)); - *leases =3D leases_ret; - leases_ret =3D NULL; + leases_ret =3D g_renew(virNetworkDHCPLeasePtr, leases_ret, nlease= s + 1); + *leases =3D g_steal_pointer(&leases_ret); } =20 rv =3D nleases; @@ -5612,10 +5604,9 @@ networkPortSetParameters(virNetworkPortPtr port, if (!(dir =3D virNetworkObjGetPortStatusDir(obj, driver->stateDir))) goto cleanup; =20 - if ((VIR_ALLOC(bandwidth) < 0) || - (VIR_ALLOC(bandwidth->in) < 0) || - (VIR_ALLOC(bandwidth->out) < 0)) - goto cleanup; + bandwidth =3D g_new0(virNetDevBandwidth, 1); + bandwidth->in =3D g_new0(virNetDevBandwidthRate, 1); + bandwidth->out =3D g_new0(virNetDevBandwidthRate, 1); =20 for (i =3D 0; i < nparams; i++) { virTypedParameterPtr param =3D ¶ms[i]; --=20 2.25.4