From nobody Thu May 2 13:21:31 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=1601039877; cv=none; d=zohomail.com; s=zohoarc; b=g6/NRRg1Wb+9WR0xrLZh/7WCgnrtnKKmfXLrbK5iidUBn2j96F2bnAiKQYXISsS58miBk9HbsP2D6ce9of7hyhoqix0SewEcfscHBZb5Zjo4Y7GRcw4TsstJAJiWW8cdolkNFOjS3MvlTnhDA13+3bsb2Y7aqCNbNcAUOmi58fw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601039877; 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=lez8eyVEpd2V5hHY9lyQ6iOHE0d6DaKTPtWlXnN0RUc=; b=jIrKt8yFsvOviCPRVn34nI28fNyBF1C6UvWI2iXBACGu++TuSl9q9/dXyLLQ4klLkf5LZyIG68fLlubUasfcgMU3ZbukZt1W6z23gGLQMgPP4xQO+NqavgYVjgx/IUhttXl+OMHaSHR2aV7tNnXB+FLNnrzhoaJCb1LypMTBScY= 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 1601039877452221.32233039487642; Fri, 25 Sep 2020 06:17: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-437-I_pnLbjsMRWYChFC1VwA_w-1; Fri, 25 Sep 2020 09:17:51 -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 271AE1882FB5; Fri, 25 Sep 2020 13:17: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 AB6F19CBA; Fri, 25 Sep 2020 13:17: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 10C8F44A7F; Fri, 25 Sep 2020 13:17:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 08PDGKsU005129 for ; Fri, 25 Sep 2020 09:16:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id E8D3B5C1C2; Fri, 25 Sep 2020 13:16:20 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6FE525C1BB for ; Fri, 25 Sep 2020 13:16:20 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601039874; 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=lez8eyVEpd2V5hHY9lyQ6iOHE0d6DaKTPtWlXnN0RUc=; b=QHllx2k10Jnip1ey8DmuDeFrXi+MJ/dhCwqP6puKq8P9ltwADSRFZ5cDbs8cjkh0AyXbu9 duc5XsfIV0AmrZenDvOuahs3uLDCFNpudTjefWML6UadKg6VwPAHJdpiRaSYR5iBh74MOg mA30EUENvYEhpb+o2mfgOWxvcj1zAUw= X-MC-Unique: I_pnLbjsMRWYChFC1VwA_w-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/7] bhyve: use g_new0 instead of VIR_ALLOC* Date: Fri, 25 Sep 2020 15:16:07 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: Peter Krempa Reviewed-by: Roman Bogorodskiy --- src/bhyve/bhyve_capabilities.c | 3 +-- src/bhyve/bhyve_domain.c | 9 +++------ src/bhyve/bhyve_driver.c | 3 +-- src/bhyve/bhyve_parse_command.c | 7 +++---- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c index 523a31e287..96cfe8357a 100644 --- a/src/bhyve/bhyve_capabilities.c +++ b/src/bhyve/bhyve_capabilities.c @@ -150,8 +150,7 @@ virBhyveDomainCapsBuild(bhyveConnPtr conn, goto cleanup; } =20 - if (VIR_ALLOC(firmwares) < 0) - goto cleanup; + firmwares =3D g_new0(virDomainCapsStringValues, 1); =20 if (virDirOpenIfExists(&dir, firmware_dir) > 0) { while ((virDirRead(dir, &entry, firmware_dir)) > 0) { diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c index 91994c3da5..6935609b96 100644 --- a/src/bhyve/bhyve_domain.c +++ b/src/bhyve/bhyve_domain.c @@ -38,8 +38,7 @@ bhyveDomainObjPrivateAlloc(void *opaque G_GNUC_UNUSED) { bhyveDomainObjPrivatePtr priv; =20 - if (VIR_ALLOC(priv) < 0) - return NULL; + priv =3D g_new0(bhyveDomainObjPrivate, 1); =20 return priv; } @@ -236,8 +235,7 @@ bhyveDomainDefNamespaceParse(xmlXPathContextPtr ctxt, size_t i; int ret =3D -1; =20 - if (VIR_ALLOC(cmd) < 0) - return -1; + cmd =3D g_new0(bhyveDomainCmdlineDef, 1); =20 n =3D virXPathNodeSet("./bhyve:commandline/bhyve:arg", ctxt, &nodes); if (n =3D=3D 0) @@ -245,8 +243,7 @@ bhyveDomainDefNamespaceParse(xmlXPathContextPtr ctxt, if (n <=3D 0) goto cleanup; =20 - if (VIR_ALLOC_N(cmd->args, n) < 0) - goto cleanup; + cmd->args =3D g_new0(char *, n); =20 for (i =3D 0; i < n; i++) { cmd->args[cmd->num_args] =3D virXMLPropString(nodes[i], "value"); diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index daa20bad40..91f41aa238 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -1224,8 +1224,7 @@ bhyveStateInitialize(bool privileged, return VIR_DRV_STATE_INIT_SKIPPED; } =20 - if (VIR_ALLOC(bhyve_driver) < 0) - return VIR_DRV_STATE_INIT_ERROR; + bhyve_driver =3D g_new0(bhyveConn, 1); =20 bhyve_driver->lockFD =3D -1; if (virMutexInit(&bhyve_driver->lock) < 0) { diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_comman= d.c index cf063da289..969e782b27 100644 --- a/src/bhyve/bhyve_parse_command.c +++ b/src/bhyve/bhyve_parse_command.c @@ -53,8 +53,7 @@ bhyveParseCommandLineUnescape(const char *command) =20 /* Since we are only removing characters, allocating a buffer of the s= ame * size as command shouldn't be a problem here */ - if (VIR_ALLOC_N(unescaped, len+1) < 0) - return NULL; + unescaped =3D g_new0(char, len + 1); =20 /* Iterate over characters in the command, skipping "\\\n", "\\\r" as = well * as "\\\r\n". */ @@ -590,8 +589,8 @@ bhyveParsePCIFbuf(virDomainDefPtr def, =20 for (i =3D 0; i < nparams; i++) { param =3D params[i]; - if (!video->driver && VIR_ALLOC(video->driver) < 0) - goto error; + if (!video->driver) + video->driver =3D g_new0(virDomainVideoDriverDef, 1); =20 if (STREQ(param, "vga=3Don")) video->driver->vgaconf =3D VIR_DOMAIN_VIDEO_VGACONF_ON; --=20 2.26.2 From nobody Thu May 2 13:21:31 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=1601039944; cv=none; d=zohomail.com; s=zohoarc; b=gdK1xFImuO9ulEF2G2uumXBHeyamAuhVXOKpEP4meHko1E7wZBJWo8GegyT5MDsDrfXoAfvGb7+cieN0qtDQUFPofmCEsLiioTVs4xRHPwRpAE5fsTIFQi4wTzhowxHrDiGIM+CyeYBmzCoBah1qy3jaJXB3EsmKaQUARgROWu4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601039944; 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=QQlLA48UqQzmjeQZJd281B1lK/G8Ez+OOEs+1y4wJ1Y=; b=IHc/aiZqAQVFf/bXZIIBQ7j+2ZVmxg8pBrqTHbSNyQXjQQViGkaNeRu4Opnswd61JkXWohKZJsIV9HCiHEkzmHcOcVwCB36Xj0nfcz9ECIeOx8KvQ2oZxJWO0B05dnhLfNjej0mL6cYk4twy4eGs//pUs/cTdw/unGtO0qsJqFc= 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 1601039944841141.39290176647535; Fri, 25 Sep 2020 06:19: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-18-3_iD0-IUPieS7l-Ug_V8Eg-1; Fri, 25 Sep 2020 09:19:01 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D2EAE5703A; Fri, 25 Sep 2020 13:18:55 +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 A2028277DC; Fri, 25 Sep 2020 13:18: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 6E12F1826D2A; Fri, 25 Sep 2020 13:18:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 08PDGLuN005138 for ; Fri, 25 Sep 2020 09:16:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id BC91B5C1C2; Fri, 25 Sep 2020 13:16:21 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 41DD65C1BB for ; Fri, 25 Sep 2020 13:16:21 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601039943; 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=QQlLA48UqQzmjeQZJd281B1lK/G8Ez+OOEs+1y4wJ1Y=; b=i5Iwjl5w4/hIcwEPfynWIhP4U/OwNHaUacLPURbHuRVZd91B2WmmCi5sZHiRTilVaNmfzn 9dsmIyuLrSnsF6Km/4Qyw/w/t5hN8rZuO5+sWzrlXLolIVYFJWupdVwvnYOFckcjFzRAOa DRCeVMXVFOc2GbEDpPYUSgDC0kskvFo= X-MC-Unique: 3_iD0-IUPieS7l-Ug_V8Eg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/7] esx: use g_new0 instead of VIR_ALLOC* Date: Fri, 25 Sep 2020 15:16:08 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.23 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: Peter Krempa --- src/esx/esx_driver.c | 14 +++++--------- src/esx/esx_network_driver.c | 17 ++++++----------- src/esx/esx_storage_backend_iscsi.c | 3 +-- src/esx/esx_storage_backend_vmfs.c | 8 +++----- src/esx/esx_stream.c | 6 ++---- src/esx/esx_util.c | 3 +-- src/esx/esx_vi.c | 12 ++++-------- src/esx/esx_vi_types.c | 3 +-- 8 files changed, 23 insertions(+), 43 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 5a742ed3df..e82e5ed835 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -824,8 +824,7 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr au= th, } =20 /* Allocate per-connection private data */ - if (VIR_ALLOC(priv) < 0) - goto cleanup; + priv =3D g_new0(esxPrivate, 1); =20 if (esxUtil_ParseUri(&priv->parsedUri, conn->uri) < 0) goto cleanup; @@ -4823,9 +4822,8 @@ esxConnectListAllDomains(virConnectPtr conn, !MATCH(VIR_CONNECT_LIST_DOMAINS_PERSISTENT)) || (MATCH(VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE) && !MATCH(VIR_CONNECT_LIST_DOMAINS_NO_MANAGEDSAVE))) { - if (domains && - VIR_ALLOC_N(*domains, 1) < 0) - goto cleanup; + if (domains) + *domains =3D g_new0(virDomainPtr, 1); =20 ret =3D 0; goto cleanup; @@ -4885,8 +4883,7 @@ esxConnectListAllDomains(virConnectPtr conn, goto cleanup; =20 if (domains) { - if (VIR_ALLOC_N(doms, 1) < 0) - goto cleanup; + doms =3D g_new0(virDomainPtr, 1); ndoms =3D 1; } =20 @@ -5218,8 +5215,7 @@ esxDomainInterfaceAddresses(virDomainPtr domain, if (VIR_EXPAND_N(ifaces_ret, ifaces_count, 1) < 0) goto cleanup; =20 - if (VIR_ALLOC(ifaces_ret[ifaces_count - 1]) < 0) - goto cleanup; + ifaces_ret[ifaces_count - 1] =3D g_new0(virDomainInterface, 1); =20 iface =3D ifaces_ret[ifaces_count - 1]; iface->naddrs =3D 0; diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c index a4e738ba72..15fc7931c0 100644 --- a/src/esx/esx_network_driver.c +++ b/src/esx/esx_network_driver.c @@ -604,10 +604,9 @@ esxShapingPolicyToBandwidth(esxVI_HostNetworkTrafficSh= apingPolicy *shapingPolicy if (!shapingPolicy || shapingPolicy->enabled !=3D esxVI_Boolean_True) return 0; =20 - if (VIR_ALLOC(*bandwidth) < 0 || - VIR_ALLOC((*bandwidth)->in) < 0 || - VIR_ALLOC((*bandwidth)->out) < 0) - return -1; + *bandwidth =3D g_new0(virNetDevBandwidth, 1); + (*bandwidth)->in =3D g_new0(virNetDevBandwidthRate, 1); + (*bandwidth)->out =3D g_new0(virNetDevBandwidthRate, 1); =20 if (shapingPolicy->averageBandwidth) { /* Scale bits per second to kilobytes per second */ @@ -655,8 +654,7 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned i= nt flags) if (esxVI_EnsureSession(priv->primary) < 0) return NULL; =20 - if (VIR_ALLOC(def) < 0) - goto cleanup; + def =3D g_new0(virNetworkDef, 1); =20 /* Lookup HostVirtualSwitch */ if (esxVI_LookupHostVirtualSwitchByName(priv->primary, network_->name, @@ -682,9 +680,7 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned i= nt flags) =20 if (count > 0) { def->forward.type =3D VIR_NETWORK_FORWARD_BRIDGE; - - if (VIR_ALLOC_N(def->forward.ifs, count) < 0) - goto cleanup; + def->forward.ifs =3D g_new0(virNetworkForwardIfDef, count); =20 /* Find PhysicalNic by key */ if (esxVI_LookupPhysicalNicList(priv->primary, &physicalNicList) <= 0) @@ -726,8 +722,7 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned i= nt flags) } =20 if (count > 0) { - if (VIR_ALLOC_N(def->portGroups, count) < 0) - goto cleanup; + def->portGroups =3D g_new0(virPortGroupDef, count); =20 /* Lookup Network list and create name list */ if (esxVI_String_AppendValueToList(&propertyNameList, "name") < 0 = || diff --git a/src/esx/esx_storage_backend_iscsi.c b/src/esx/esx_storage_back= end_iscsi.c index 017b800f06..edbc65f5c0 100644 --- a/src/esx/esx_storage_backend_iscsi.c +++ b/src/esx/esx_storage_backend_iscsi.c @@ -337,8 +337,7 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsign= ed int flags) =20 def.source.nhost =3D 1; =20 - if (VIR_ALLOC_N(def.source.hosts, def.source.nhost) < 0) - goto cleanup; + def.source.hosts =3D g_new0(virStoragePoolSourceHost, def.source.nhost= ); =20 def.source.hosts[0].name =3D target->address; =20 diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backe= nd_vmfs.c index a98001d6b2..e397853bf7 100644 --- a/src/esx/esx_storage_backend_vmfs.c +++ b/src/esx/esx_storage_backend_vmfs.c @@ -512,8 +512,7 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsign= ed int flags) if (esxVI_LocalDatastoreInfo_DynamicCast(info)) { def.type =3D VIR_STORAGE_POOL_DIR; } else if ((nasInfo =3D esxVI_NasDatastoreInfo_DynamicCast(info))) { - if (VIR_ALLOC_N(def.source.hosts, 1) < 0) - goto cleanup; + def.source.hosts =3D g_new0(virStoragePoolSourceHost, 1); def.type =3D VIR_STORAGE_POOL_NETFS; def.source.nhost =3D 1; def.source.hosts[0].name =3D nasInfo->nas->remoteHost; @@ -1016,8 +1015,7 @@ esxStorageVolCreateXML(virStoragePoolPtr pool, } =20 if (priv->primary->hasQueryVirtualDiskUuid) { - if (VIR_ALLOC_N(key, VIR_UUID_STRING_BUFLEN) < 0) - goto cleanup; + key =3D g_new0(char, VIR_UUID_STRING_BUFLEN); =20 if (esxVI_QueryVirtualDiskUuid(priv->primary, datastorePath, priv->primary->datacenter->_ref= erence, @@ -1196,7 +1194,7 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, } =20 if (priv->primary->hasQueryVirtualDiskUuid) { - if (VIR_ALLOC_N(key, VIR_UUID_STRING_BUFLEN) < 0) + key =3D g_new0(char, VIR_UUID_STRING_BUFLEN); goto cleanup; =20 if (esxVI_QueryVirtualDiskUuid(priv->primary, datastorePath, diff --git a/src/esx/esx_stream.c b/src/esx/esx_stream.c index fe3c42ae02..2e7f979e79 100644 --- a/src/esx/esx_stream.c +++ b/src/esx/esx_stream.c @@ -132,8 +132,7 @@ esxVI_CURL_WriteStream(char *input, size_t size, size_t= nmemb, void *userdata) priv->backlog_size =3D input_remaining; priv->backlog_used =3D 0; =20 - if (VIR_ALLOC_N(priv->backlog, priv->backlog_size) < 0) - return 0; + priv->backlog =3D g_new0(char, priv->backlog_size); } else if (input_remaining > backlog_remaining) { priv->backlog_size +=3D input_remaining - backlog_remaining; =20 @@ -409,8 +408,7 @@ esxStreamOpen(virStreamPtr stream, esxPrivate *priv, co= nst char *url, return -1; } =20 - if (VIR_ALLOC(streamPriv) < 0) - return -1; + streamPriv =3D g_new0(esxStreamPrivate, 1); =20 streamPriv->mode =3D mode; =20 diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c index cd3d8925b9..9100873326 100644 --- a/src/esx/esx_util.c +++ b/src/esx/esx_util.c @@ -49,8 +49,7 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr= uri) =20 ESX_VI_CHECK_ARG_LIST(parsedUri); =20 - if (VIR_ALLOC(*parsedUri) < 0) - return -1; + *parsedUri =3D g_new0(esxUtil_ParsedUri, 1); =20 for (i =3D 0; i < uri->paramsCount; i++) { virURIParamPtr queryParam =3D &uri->params[i]; diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index f099716d3e..c7af092569 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -53,8 +53,7 @@ VIR_LOG_INIT("esx.esx_vi"); { \ ESX_VI_CHECK_ARG_LIST(ptrptr); \ \ - if (VIR_ALLOC(*ptrptr) < 0) \ - return -1; \ + *ptrptr =3D g_new0(esxVI_##_type, 1); \ return 0; \ } =20 @@ -182,8 +181,7 @@ esxVI_CURL_Debug(CURL *curl G_GNUC_UNUSED, curl_infotyp= e type, * To handle this properly in order to pass the info string to VIR_DEB= UG * a zero terminated copy of the info string has to be allocated. */ - if (VIR_ALLOC_N(buffer, size + 1) < 0) - return 0; + buffer =3D g_new0(char, size + 1); =20 memcpy(buffer, info, size); buffer[size] =3D '\0'; @@ -861,8 +859,7 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *u= rl, ctx->username =3D g_strdup(username); ctx->password =3D g_strdup(password); =20 - if (VIR_ALLOC(ctx->sessionLock) < 0) - goto cleanup; + ctx->sessionLock =3D g_new0(virMutex, 1); =20 =20 if (virMutexInit(ctx->sessionLock) < 0) { @@ -3714,8 +3711,7 @@ esxVI_LookupStorageVolumeKeyByDatastorePath(esxVI_Con= text *ctx, goto cleanup; } =20 - if (VIR_ALLOC_N(*key, VIR_UUID_STRING_BUFLEN) < 0) - goto cleanup; + *key =3D g_new0(char, VIR_UUID_STRING_BUFLEN); =20 if (esxUtil_ReformatUuid(uuid_string, *key) < 0) goto cleanup; diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c index ad40ddf54b..6821587e44 100644 --- a/src/esx/esx_vi_types.c +++ b/src/esx/esx_vi_types.c @@ -44,8 +44,7 @@ VIR_LOG_INIT("esx.esx_vi_types"); { \ ESX_VI_CHECK_ARG_LIST(ptrptr); \ \ - if (VIR_ALLOC(*ptrptr) < 0) \ - return -1; \ + *ptrptr =3D g_new0(esxVI_##__type, 1); \ \ (*ptrptr)->_type =3D esxVI_Type_##__type; \ \ --=20 2.26.2 From nobody Thu May 2 13:21:31 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=1601039956; cv=none; d=zohomail.com; s=zohoarc; b=V3iHggo13JLOxhq8eKnk+J1FHlMjSjgDCT2Ek3cNQ+x3OuMT1nZi/waUqLIWc9XfdjOA16lIQvlgcbDNUWjdhOeuBxeVeCKo4BZNrpLIpywluAmUgG5uPwDznJ4GLl3KfYgnMwhlsdC6X1iNaXCySNqWxyxM+vbHEW4jf59dq2E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601039956; 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=ETK5ClE/LkY/YawpmmhIQVzFT49xMof96aVriX93sds=; b=fmHL7iW28BmJBsg3r15UqB7by3vcifA2QlmxR0jDy2DUlWWlmYarDAx4TsrDfW4q987OBuyyHGNy9QCFlm2S3iP9jOXAqYBHl6IzwbOfFM6vZovuQ+f1t9Z+Mw6+XeqBH7WqYJu/OL+Y/gtot6rtzMUrLxn1JpccOx5GeemCg1M= 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 1601039956372692.2197217721334; Fri, 25 Sep 2020 06:19: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-65-ltnRT-fsMoWvI-2wzx7xTA-1; Fri, 25 Sep 2020 09:19:12 -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 B8C4C100A607; Fri, 25 Sep 2020 13:19:05 +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 94DFD5577D; Fri, 25 Sep 2020 13:19:05 +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 629771826D2F; Fri, 25 Sep 2020 13:19:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 08PDGMQe005147 for ; Fri, 25 Sep 2020 09:16:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 90DD95C1C2; Fri, 25 Sep 2020 13:16:22 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 161525C1BB for ; Fri, 25 Sep 2020 13:16:21 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601039955; 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=ETK5ClE/LkY/YawpmmhIQVzFT49xMof96aVriX93sds=; b=eT9zLhT+5H8u5mRN41sUambxVFJVKFU2e2eCFHZ0I3v1CfhuSvz99I+GuwWBxIWO0J3Bp6 YxZt66W3Nlmp50VMvdiRLNLnKMGpzWIIO17I/P0eaZ4AMEhrS0tXXSomdrp0TbLLVmhyZI /L39sJ/xCe6ya6w6qBFlZHtNApVfDMw= X-MC-Unique: ltnRT-fsMoWvI-2wzx7xTA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 3/7] hyperv: use g_new0 instead of VIR_ALLOC* Date: Fri, 25 Sep 2020 15:16:09 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: Peter Krempa --- src/hyperv/hyperv_driver.c | 13 +++++-------- src/hyperv/hyperv_util.c | 3 +-- src/hyperv/hyperv_wmi.c | 13 +++---------- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 9b181ebfff..b57325f2a5 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -128,8 +128,7 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthPtr= auth, virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); =20 /* Allocate per-connection private data */ - if (VIR_ALLOC(priv) < 0) - goto cleanup; + priv =3D g_new0(hypervPrivate, 1); =20 if (hypervParseUri(&priv->parsedUri, conn->uri) < 0) goto cleanup; @@ -1221,8 +1220,8 @@ hypervConnectListAllDomains(virConnectPtr conn, !MATCH(VIR_CONNECT_LIST_DOMAINS_NO_AUTOSTART)) || (MATCH(VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT) && !MATCH(VIR_CONNECT_LIST_DOMAINS_NO_SNAPSHOT))) { - if (domains && VIR_ALLOC_N(*domains, 1) < 0) - goto cleanup; + if (domains) + *domains =3D g_new0(virDomainPtr, 1); =20 ret =3D 0; goto cleanup; @@ -1251,8 +1250,7 @@ hypervConnectListAllDomains(virConnectPtr conn, goto cleanup; =20 if (domains) { - if (VIR_ALLOC_N(doms, 1) < 0) - goto cleanup; + doms =3D g_new0(virDomainPtr, 1); ndoms =3D 1; } =20 @@ -1357,8 +1355,7 @@ hypervDomainSendKey(virDomainPtr domain, unsigned int= codeset, if (hypervGetMsvmKeyboardList(priv, &query, &keyboard) < 0) goto cleanup; =20 - if (VIR_ALLOC_N(translatedKeycodes, nkeycodes) < 0) - goto cleanup; + translatedKeycodes =3D g_new0(int, nkeycodes); =20 /* translate keycodes to win32 and generate keyup scancodes. */ for (i =3D 0; i < nkeycodes; i++) { diff --git a/src/hyperv/hyperv_util.c b/src/hyperv/hyperv_util.c index 2425d6a0c6..56c9e8bebd 100644 --- a/src/hyperv/hyperv_util.c +++ b/src/hyperv/hyperv_util.c @@ -45,8 +45,7 @@ hypervParseUri(hypervParsedUri **parsedUri, virURIPtr uri) return -1; } =20 - if (VIR_ALLOC(*parsedUri) < 0) - return -1; + *parsedUri =3D g_new0(hypervParsedUri, 1); =20 for (i =3D 0; i < uri->paramsCount; i++) { virURIParamPtr queryParam =3D &uri->params[i]; diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index 917298d027..809f68a844 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -176,14 +176,9 @@ hypervCreateInvokeParamsList(hypervPrivate *priv, cons= t char *method, if (hypervGetWmiClassInfo(priv, obj, &info) < 0) return NULL; =20 - if (VIR_ALLOC(params) < 0) - return NULL; + params =3D g_new0(hypervInvokeParamsList, 1); =20 - if (VIR_ALLOC_N(params->params, - HYPERV_DEFAULT_PARAM_COUNT) < 0) { - VIR_FREE(params); - return NULL; - } + params->params =3D g_new0(hypervParam, HYPERV_DEFAULT_PARAM_COUNT); =20 params->method =3D method; params->ns =3D info->rootUri; @@ -1052,9 +1047,7 @@ hypervEnumAndPull(hypervPrivate *priv, hypervWqlQuery= Ptr wqlQuery, goto cleanup; } =20 - if (VIR_ALLOC(object) < 0) - goto cleanup; - + object =3D g_new0(hypervObject, 1); object->info =3D wmiInfo; object->data.common =3D data; =20 --=20 2.26.2 From nobody Thu May 2 13:21:31 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=1601039950; cv=none; d=zohomail.com; s=zohoarc; b=dKcNvJxEHFLnFjJ5k46kL2v2D/OBUQhh5nFGBSJFBtogpriR3auWtxm/jO3ZoLMtt4EG5BHps2Rd+d2y8IZUUG54bcJXg4Y+Rg18eXvrxD3ydcYdfn8yPmxEH755SP2ojfHNKAYYyuQFXYLoyEPAztF7/eUUcYcjjrCxt8ktF1g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601039950; 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=h6+KHC4u/pEgyw8Rt2hmcp/6B5mBgUkvIZV5/gMJ4jg=; b=OeVbtw4iY7a/9yRNy8/tVBbCrhdl8qOsk9ffIw1Zn64x3ya5aU/oNTTuKb+XQcoNujBOUxpm/UNjegJDorCg9LhVpUMbSBCV/47uzuR4YFQA+B8h7jkLQhn7sKTCIJmA0TAWOIuT8ASLo0XqSJkZ/Tatx+dntbftmJnPZgMtlwE= 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 1601039950963238.7647827748632; Fri, 25 Sep 2020 06:19:10 -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-29-z58LHSflPx6mN3UnwX9JUw-1; Fri, 25 Sep 2020 09:19:05 -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 088A657244; Fri, 25 Sep 2020 13:18: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 D94067368C; Fri, 25 Sep 2020 13:18: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 A297E8C7A4; Fri, 25 Sep 2020 13:18:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 08PDGNnS005158 for ; Fri, 25 Sep 2020 09:16:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 688705C1C2; Fri, 25 Sep 2020 13:16:23 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id E06705C1BB for ; Fri, 25 Sep 2020 13:16:22 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601039949; 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=h6+KHC4u/pEgyw8Rt2hmcp/6B5mBgUkvIZV5/gMJ4jg=; b=DRzfjE2gyubedOL4mB0MbnDP1gULSRheyF9Sx5R+JR0R1zIz4fbC82UtRZ7dagnAFsiLz1 ilhyctr5bwknDGrikZyTVmGPPwPKIPUxrd6lcWX0ACJTsR2fcSQdh43GTnHKCAjtskFVe/ cjwf81Tzo+5Q28qtPyh8p/mi0F/tbf8= X-MC-Unique: z58LHSflPx6mN3UnwX9JUw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 4/7] interface: use g_new0 instead of VIR_ALLOC* Date: Fri, 25 Sep 2020 15:16:10 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: Peter Krempa --- src/interface/interface_backend_netcf.c | 16 ++++++---------- src/interface/interface_backend_udev.c | 22 ++++++++-------------- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interf= ace_backend_netcf.c index f30829442d..df04484c59 100644 --- a/src/interface/interface_backend_netcf.c +++ b/src/interface/interface_backend_netcf.c @@ -247,8 +247,7 @@ netcfGetMinimalDefForDevice(struct netcf_if *iface) virInterfaceDef *def; =20 /* Allocate our interface definition structure */ - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virInterfaceDef, 1); =20 def->name =3D g_strdup(ncf_if_name(iface)); def->mac =3D g_strdup(ncf_if_mac_string(iface)); @@ -375,8 +374,7 @@ static int netcfConnectNumOfInterfacesImpl(virConnectPt= r conn, goto cleanup; } =20 - if (VIR_ALLOC_N(names, count) < 0) - goto cleanup; + names =3D g_new0(char *, count); =20 if ((count =3D ncf_list_interfaces(driver->netcf, count, names, status= )) < 0) { const char *errmsg, *details; @@ -465,8 +463,7 @@ static int netcfConnectListInterfacesImpl(virConnectPtr= conn, goto cleanup; } =20 - if (VIR_ALLOC_N(allnames, count) < 0) - goto cleanup; + allnames =3D g_new0(char *, count); =20 if ((count =3D ncf_list_interfaces(driver->netcf, count, allnames, sta= tus)) < 0) { const char *errmsg, *details; @@ -651,8 +648,7 @@ netcfConnectListAllInterfaces(virConnectPtr conn, goto cleanup; } =20 - if (VIR_ALLOC_N(names, count) < 0) - goto cleanup; + names =3D g_new0(char *, count); =20 if ((count =3D ncf_list_interfaces(driver->netcf, count, names, ncf_flags)) < 0) { @@ -666,8 +662,8 @@ netcfConnectListAllInterfaces(virConnectPtr conn, goto cleanup; } =20 - if (ifaces && VIR_ALLOC_N(tmp_iface_objs, count + 1) < 0) - goto cleanup; + if (ifaces) + tmp_iface_objs =3D g_new0(virInterfacePtr, count + 1); =20 for (i =3D 0; i < count; i++) { virInterfaceDefPtr def; diff --git a/src/interface/interface_backend_udev.c b/src/interface/interfa= ce_backend_udev.c index 670de48d52..4e0a80765c 100644 --- a/src/interface/interface_backend_udev.c +++ b/src/interface/interface_backend_udev.c @@ -86,8 +86,7 @@ udevGetMinimalDefForDevice(struct udev_device *dev) virInterfaceDef *def; =20 /* Allocate our interface definition structure */ - if (VIR_ALLOC(def) < 0) - return NULL; + def =3D g_new0(virInterfaceDef, 1); =20 def->name =3D g_strdup(udev_device_get_sysname(dev)); def->mac =3D g_strdup(udev_device_get_sysattr_value(dev, "address")); @@ -352,10 +351,8 @@ udevConnectListAllInterfaces(virConnectPtr conn, } =20 /* If we're asked for the ifaces then alloc up memory */ - if (ifaces && VIR_ALLOC_N(ifaces_list, count + 1) < 0) { - ret =3D -1; - goto cleanup; - } + if (ifaces) + ifaces_list =3D g_new0(virInterfacePtr, count + 1); =20 /* Get a list we can walk */ devices =3D udev_enumerate_get_list_entry(enumerate); @@ -758,8 +755,8 @@ udevGetIfaceDefBond(struct udev *udev, } =20 /* Allocate our list of slave devices */ - if (VIR_ALLOC_N(ifacedef->data.bond.itf, slave_count) < 0) - goto error; + ifacedef->data.bond.itf =3D g_new0(struct _virInterfaceDef *, + slave_count); ifacedef->data.bond.nbItf =3D slave_count; =20 for (i =3D 0; i < slave_count; i++) { @@ -873,8 +870,7 @@ udevGetIfaceDefBridge(struct udev *udev, } =20 /* Allocate our list of member devices */ - if (VIR_ALLOC_N(ifacedef->data.bridge.itf, member_count) < 0) - goto error; + ifacedef->data.bridge.itf =3D g_new0(struct _virInterfaceDef *, member= _count); ifacedef->data.bridge.nbItf =3D member_count; =20 /* Get the interface definitions for each member of the bridge */ @@ -976,8 +972,7 @@ udevGetIfaceDef(struct udev *udev, const char *name) const char *devtype; =20 /* Allocate our interface definition structure */ - if (VIR_ALLOC(ifacedef) < 0) - return NULL; + ifacedef =3D g_new0(virInterfaceDef, 1); =20 /* Clear our structure and set safe defaults */ ifacedef->startmode =3D VIR_INTERFACE_START_UNSPECIFIED; @@ -1158,8 +1153,7 @@ udevStateInitialize(bool privileged, return -1; } =20 - if (VIR_ALLOC(driver) < 0) - goto cleanup; + driver =3D g_new0(struct udev_iface_driver, 1); =20 driver->lockFD =3D -1; =20 --=20 2.26.2 From nobody Thu May 2 13:21:31 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=1601039890; cv=none; d=zohomail.com; s=zohoarc; b=OfCWj5q/Hd4V+9DPttWIiRpbMCy9+VjCl4+XXioOMPf/0TFJquSEjc3Y6XrG/3aTO17ux1+3hqyo1pPtbGhJbsC4OOGPwYSziwooyJJGINVyGl1nmTKiKHSq98k9qYj9nXeD5gfby6V7HG667tmZSFjtx27bZ+u+DJT+uU6GciU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601039890; 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=DmdFG5KL879RJul0wFpl9thOsHxJ5Lgx7EpP9eyMihU=; b=dWJGwqBV6M0bgLRX/VnlxF688+PBqZ2ke0bn0l/Fg53bMvi9AXltyc9KuSqX2mHMkyT1xYHTX+phhz5X6qrkQeR2AocFZALkzu3+vfeJqAWo/6tkhL4BOLpVkLavJegxtASTL1bdHFdRXlojngAPnoXzLdntWuiOIYq0X5QqOH8= 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 1601039890403891.5650252437711; Fri, 25 Sep 2020 06:18:10 -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-267-qA0TEsSUNNKsLjEfbxMvbQ-1; Fri, 25 Sep 2020 09:18:06 -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 A943C80732A; Fri, 25 Sep 2020 13:18:00 +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 5247E5C1C2; Fri, 25 Sep 2020 13:18: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 E49B51826D2B; Fri, 25 Sep 2020 13:17:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 08PDGPii005172 for ; Fri, 25 Sep 2020 09:16:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 421595C1C2; Fri, 25 Sep 2020 13:16:25 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id B8E835C1BB for ; Fri, 25 Sep 2020 13:16:23 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601039889; 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=DmdFG5KL879RJul0wFpl9thOsHxJ5Lgx7EpP9eyMihU=; b=Iv+s+a0ZhmGqEsBMxPwZNehVWZMgNxtGkNtC9w6n6nEqbSr2jhDDRhn77kZy/Cg1iRf7yE zm4Gs3lrO0kmZn6T71a113OIVkC78TQq3VDfcv7JYTvktSoEPfh8FkhTp8cZvNT+SrtNk+ B8LfxV2kwKLCGwFgveFxPBCDxoCMnWA= X-MC-Unique: qA0TEsSUNNKsLjEfbxMvbQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 5/7] src: libvirt-stream: use g_new0 instead of VIR_ALLOC* Date: Fri, 25 Sep 2020 15:16:11 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: Peter Krempa --- src/libvirt-stream.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/libvirt-stream.c b/src/libvirt-stream.c index aeb7562018..873d7b1d4e 100644 --- a/src/libvirt-stream.c +++ b/src/libvirt-stream.c @@ -588,8 +588,7 @@ virStreamSendAll(virStreamPtr stream, goto cleanup; } =20 - if (VIR_ALLOC_N(bytes, want) < 0) - goto cleanup; + bytes =3D g_new0(char, want); =20 errno =3D 0; for (;;) { @@ -724,8 +723,7 @@ int virStreamSparseSendAll(virStreamPtr stream, goto cleanup; } =20 - if (VIR_ALLOC_N(bytes, bufLen) < 0) - goto cleanup; + bytes =3D g_new0(char, bufLen); =20 errno =3D 0; for (;;) { @@ -859,8 +857,7 @@ virStreamRecvAll(virStreamPtr stream, } =20 =20 - if (VIR_ALLOC_N(bytes, want) < 0) - goto cleanup; + bytes =3D g_new0(char, want); =20 errno =3D 0; for (;;) { @@ -977,8 +974,7 @@ virStreamSparseRecvAll(virStreamPtr stream, goto cleanup; } =20 - if (VIR_ALLOC_N(bytes, want) < 0) - goto cleanup; + bytes =3D g_new0(char, want); =20 errno =3D 0; for (;;) { --=20 2.26.2 From nobody Thu May 2 13:21:31 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=1601039962; cv=none; d=zohomail.com; s=zohoarc; b=ZPxGBw6RHfHFyOk1XMnAjberEcKlm7WV8CZylUR/rmqemf2jsYuJTekE8AwK0jy4lrWT0jYs38wBp/kcgj8YL4GNfHkHeBGF6+sgYwMluTLSWdaHmH7LOwEWSYpxU/FwqZhQuyKAq5ht0ND4mAM63nLhewieIwW30AiEoR/dOXY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601039962; 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=EOaRN/IEm5VG2EURFWrAhq2KfEUwH9RsxgH4+EKy0Zc=; b=cOXsBj6rJkGQr8AkAEFLxYHgqo2Ni9jw0G3nneqMqe7GReKIMDJWXL62X6+0LVL9Aa6Xffir7KM+RqkjPGDD5xVGzpFWj9AOW/bMpvxgr7a7wxJoeRWnj9/H0S+bxHjQJqP0evsmDkRhO7zEdTVj2AFNeB1mwzvFD69q481tygs= 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 1601039962654899.3305398655039; Fri, 25 Sep 2020 06:19: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-555-u-lhTP_IOPC5RYy1ig9-rg-1; Fri, 25 Sep 2020 09:19:18 -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 0DDB064158; Fri, 25 Sep 2020 13:19:12 +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 DAF8555789; Fri, 25 Sep 2020 13:19:11 +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 A99DB8C7A9; Fri, 25 Sep 2020 13:19:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 08PDGSkv005192 for ; Fri, 25 Sep 2020 09:16:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4C1755C1C2; Fri, 25 Sep 2020 13:16:28 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id C52175C1BB for ; Fri, 25 Sep 2020 13:16:25 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601039961; 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=EOaRN/IEm5VG2EURFWrAhq2KfEUwH9RsxgH4+EKy0Zc=; b=LyqrnT6cR0NxRSHiPgJlaOpsEHcbHvrrIyAbBqNvuiw6u4AYDgPhNEwpgHjCS5lu0yImlc 8Q4aXIXK14rJ9vn9FGfgk4DHQWTpfxZkd9sjo1cSksZCNU3OQo8uuroZpeY8qyPTBFZBa1 KUTveWp3BJSxdYThbDnbnJUfce90AoY= X-MC-Unique: u-lhTP_IOPC5RYy1ig9-rg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 6/7] storage: scsi: invert logic in createVport Date: Fri, 25 Sep 2020 15:16:12 +0200 Message-Id: <892da6d53c655bccec88dab3155e7f4f53e7f5f9.1601039656.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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) Check whether the alloc result is negative (which is cannot happen with current code) to reduce churn in the following commit. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- src/storage/storage_backend_scsi.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backe= nd_scsi.c index e528d7622c..b5866935d1 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -329,16 +329,17 @@ createVport(virStoragePoolDefPtr def, * retry logic set to true. If the thread isn't created, then no big * deal since it's still possible to refresh the pool later. */ - if (VIR_ALLOC(cbdata) =3D=3D 0) { - memcpy(cbdata->pool_uuid, def->uuid, VIR_UUID_BUFLEN); - cbdata->fchost_name =3D g_steal_pointer(&name); + if (VIR_ALLOC(cbdata) < 0) + return -1; =20 - if (virThreadCreateFull(&thread, false, virStoragePoolFCRefreshThr= ead, - "scsi-refresh", false, cbdata) < 0) { - /* Oh well - at least someone can still refresh afterwards */ - VIR_DEBUG("Failed to create FC Pool Refresh Thread"); - virStoragePoolFCRefreshDataFree(cbdata); - } + memcpy(cbdata->pool_uuid, def->uuid, VIR_UUID_BUFLEN); + cbdata->fchost_name =3D g_steal_pointer(&name); + + if (virThreadCreateFull(&thread, false, virStoragePoolFCRefreshThread, + "scsi-refresh", false, cbdata) < 0) { + /* Oh well - at least someone can still refresh afterwards */ + VIR_DEBUG("Failed to create FC Pool Refresh Thread"); + virStoragePoolFCRefreshDataFree(cbdata); } =20 return 0; --=20 2.26.2 From nobody Thu May 2 13:21:31 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=1601039963; cv=none; d=zohomail.com; s=zohoarc; b=PA1WfXQSwmhZ7ssE2Exsait4Q9CgA7tnKWhUD/M2zDB3oAhjJpGW1GI/UJAm8b9V8zAxNswg6Fc+EVgrVkbMzLwLMs5mvza2TYFP/efFbupb+Cae1qe3JhNPZdQI3YI9V44fEt3IyHQLN7BZJveMEKSdt5fXQnB871dvyZsY/r0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601039963; 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=ZepLfF667uoQhSJ9YX5Jqxfdt26eMZnkpuC0/80bm9A=; b=K4fUz8s4JqSKP1zSenNcWyNjySVFUFpQpx6JJeceA2vgmV7foA0SO9BarzCeiKyezSKmrL5BANzCWiCoa8C3yl7hzjUOZuymM2egwZ/Ic/GZPX5aQ+4FW79iyhZVjYWDlfJs7pmohwXXJs0ymoyvxpXOvbx4cWjUpLWENDiGCU0= 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 1601039963905490.8976404741643; Fri, 25 Sep 2020 06:19:23 -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-380-ULdcDOQ1MnWTkyINtC8--g-1; Fri, 25 Sep 2020 09:19:20 -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 8BCFF10BBECF; Fri, 25 Sep 2020 13:19:14 +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 6BCD060C17; Fri, 25 Sep 2020 13:19:14 +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 39F661826D2F; Fri, 25 Sep 2020 13:19:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 08PDGTk0005203 for ; Fri, 25 Sep 2020 09:16:29 -0400 Received: by smtp.corp.redhat.com (Postfix) id 469C65C1C2; Fri, 25 Sep 2020 13:16:29 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9AD775C1BB for ; Fri, 25 Sep 2020 13:16:28 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601039962; 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=ZepLfF667uoQhSJ9YX5Jqxfdt26eMZnkpuC0/80bm9A=; b=EdtvtFfb96BZf9BG0ZdMzQ8JoUdgIy5d/w7oqP5rGJWUbZLrZ14po+Ql/FVlLCEPM33Crk 4GYCds1AjYYUDuhITXDiFaQZ74i+X/8J0yKZ29TeBz+d79XLKVvwgC4og/ufjie3KXOLac +sZ5G9tYkE9VCytdzKu2tslrfnUamk4= X-MC-Unique: ULdcDOQ1MnWTkyINtC8--g-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 7/7] storage: use g_new0 instead of VIR_ALLOC* Date: Fri, 25 Sep 2020 15:16:13 +0200 Message-Id: <5dadeeafa0a07e47a66ea1a87632cf4c88fe8626.1601039656.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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: Peter Krempa --- src/storage/storage_backend_disk.c | 6 ++-- src/storage/storage_backend_fs.c | 8 ++--- src/storage/storage_backend_gluster.c | 12 +++----- src/storage/storage_backend_iscsi.c | 8 ++--- src/storage/storage_backend_iscsi_direct.c | 13 ++++----- src/storage/storage_backend_logical.c | 6 ++-- src/storage/storage_backend_mpath.c | 3 +- src/storage/storage_backend_rbd.c | 29 +++++++----------- src/storage/storage_backend_scsi.c | 4 +-- src/storage/storage_backend_sheepdog.c | 3 +- src/storage/storage_backend_zfs.c | 3 +- src/storage/storage_driver.c | 14 +++------ src/storage/storage_file_fs.c | 3 +- src/storage/storage_file_gluster.c | 6 ++-- src/storage/storage_util.c | 34 ++++++++-------------- 15 files changed, 52 insertions(+), 100 deletions(-) diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backe= nd_disk.c index ec0679d353..af90f3fc45 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -74,8 +74,7 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr poo= l, * we're discovering the existing partitions for the pool */ addVol =3D true; - if (VIR_ALLOC(vol) < 0) - return -1; + vol =3D g_new0(virStorageVolDef, 1); vol->name =3D g_strdup(partname); } =20 @@ -132,8 +131,7 @@ virStorageBackendDiskMakeDataVol(virStoragePoolObjPtr p= ool, } =20 if (vol->source.extents =3D=3D NULL) { - if (VIR_ALLOC(vol->source.extents) < 0) - goto error; + vol->source.extents =3D g_new0(virStorageVolSourceExtent, 1); vol->source.nextent =3D 1; =20 if (virStrToLong_ull(groups[3], NULL, 10, diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend= _fs.c index 30c2367df4..b98d06c644 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -76,8 +76,7 @@ virStorageBackendFileSystemNetFindPoolSourcesFunc(char **= const groups, if (!(src =3D virStoragePoolSourceListNewSource(&state->list))) return -1; =20 - if (VIR_ALLOC_N(src->hosts, 1) < 0) - return -1; + src->hosts =3D g_new0(virStoragePoolSourceHost, 1); src->nhost =3D 1; =20 src->hosts[0].name =3D g_strdup(state->host); @@ -576,9 +575,8 @@ virStoragePoolDefFSNamespaceParse(xmlXPathContextPtr ct= xt, if (nnodes =3D=3D 0) return 0; =20 - if (VIR_ALLOC(cmdopts) < 0 || - VIR_ALLOC_N(cmdopts->options, nnodes) < 0) - goto cleanup; + cmdopts =3D g_new0(virStoragePoolFSMountOptionsDef, 1); + cmdopts->options =3D g_new0(char *, nnodes); =20 for (i =3D 0; i < nnodes; i++) { if (!(cmdopts->options[cmdopts->noptions] =3D diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_ba= ckend_gluster.c index 4763a569e3..6c99c270da 100644 --- a/src/storage/storage_backend_gluster.c +++ b/src/storage/storage_backend_gluster.c @@ -97,16 +97,14 @@ virStorageBackendGlusterOpen(virStoragePoolObjPtr pool) trailing_slash =3D false; } =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(virStorageBackendGlusterState, 1); =20 ret->volname =3D g_strdup(name); ret->dir =3D g_strdup_printf("%s%s", dir ? dir : "/", trailing_slash ?= "" : "/"); =20 /* FIXME: Currently hard-coded to tcp transport; XML needs to be * extended to allow alternate transport */ - if (VIR_ALLOC(ret->uri) < 0) - goto error; + ret->uri =3D g_new0(virURI, 1); ret->uri->scheme =3D g_strdup("gluster"); ret->uri->server =3D g_strdup(def->source.hosts[0].name); ret->uri->path =3D g_strdup_printf("/%s%s", ret->volname, ret->dir); @@ -151,8 +149,7 @@ virStorageBackendGlusterRead(glfs_fd_t *fd, char *s; size_t nread =3D 0; =20 - if (VIR_ALLOC_N(*buf, len) < 0) - return -1; + *buf =3D g_new0(char, len); =20 s =3D *buf; while (len) { @@ -245,8 +242,7 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlu= sterStatePtr state, return ret; } =20 - if (VIR_ALLOC(vol) < 0) - goto cleanup; + vol =3D g_new0(virStorageVolDef, 1); =20 if (virStorageBackendUpdateVolTargetInfoFD(&vol->target, -1, st) < 0) goto cleanup; diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_back= end_iscsi.c index 32892e1d75..436d5e09c7 100644 --- a/src/storage/storage_backend_iscsi.c +++ b/src/storage/storage_backend_iscsi.c @@ -189,13 +189,11 @@ virStorageBackendISCSIFindPoolSources(const char *src= Spec, &ntargets, &targets) < 0) goto cleanup; =20 - if (VIR_ALLOC_N(list.sources, ntargets) < 0) - goto cleanup; + list.sources =3D g_new0(virStoragePoolSource, ntargets); =20 for (i =3D 0; i < ntargets; i++) { - if (VIR_ALLOC_N(list.sources[i].devices, 1) < 0 || - VIR_ALLOC_N(list.sources[i].hosts, 1) < 0) - goto cleanup; + list.sources[i].devices =3D g_new0(virStoragePoolSourceDevice, 1); + list.sources[i].hosts =3D g_new0(virStoragePoolSourceHost, 1); list.sources[i].nhost =3D 1; list.sources[i].hosts[0] =3D source->hosts[0]; list.sources[i].initiator =3D source->initiator; diff --git a/src/storage/storage_backend_iscsi_direct.c b/src/storage/stora= ge_backend_iscsi_direct.c index 027fa83de7..66ceb48e6a 100644 --- a/src/storage/storage_backend_iscsi_direct.c +++ b/src/storage/storage_backend_iscsi_direct.c @@ -309,8 +309,7 @@ virISCSIDirectRefreshVol(virStoragePoolObjPtr pool, if (virISCSIDirectTestUnitReady(iscsi, lun) < 0) return -1; =20 - if (VIR_ALLOC(vol) < 0) - return -1; + vol =3D g_new0(virStorageVolDef, 1); =20 vol->type =3D VIR_STORAGE_VOL_NETWORK; =20 @@ -518,13 +517,11 @@ virStorageBackendISCSIDirectFindPoolSources(const cha= r *srcSpec, if (virISCSIDirectScanTargets(source->initiator.iqn, portal, &ntargets= , &targets) < 0) goto cleanup; =20 - if (VIR_ALLOC_N(list.sources, ntargets) < 0) - goto cleanup; + list.sources =3D g_new0(virStoragePoolSource, ntargets); =20 for (i =3D 0; i < ntargets; i++) { - if (VIR_ALLOC_N(list.sources[i].devices, 1) < 0 || - VIR_ALLOC_N(list.sources[i].hosts, 1) < 0) - goto cleanup; + list.sources[i].devices =3D g_new0(virStoragePoolSourceDevice, 1); + list.sources[i].hosts =3D g_new0(virStoragePoolSourceHost, 1); list.sources[i].nhost =3D 1; list.sources[i].hosts[0] =3D source->hosts[0]; list.sources[i].initiator =3D source->initiator; @@ -628,7 +625,7 @@ virStorageBackendISCSIDirectVolWipeZero(virStorageVolDe= fPtr vol, return ret; if (virISCSIDirectGetVolumeCapacity(iscsi, lun, &block_size, &nb_block= )) return ret; - if (VIR_ALLOC_N(data, block_size * BLOCK_PER_PACKET)) + data =3D g_new0(unsigned char, block_size * BLOCK_PER_PACKET); return ret; =20 while (lba < nb_block) { diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_ba= ckend_logical.c index e3debc390c..ead3dab4fd 100644 --- a/src/storage/storage_backend_logical.c +++ b/src/storage/storage_backend_logical.c @@ -161,8 +161,7 @@ virStorageBackendLogicalParseVolExtents(virStorageVolDe= fPtr vol, } =20 /* Allocate space for 'nextents' regex_unit strings plus a comma for e= ach */ - if (VIR_ALLOC_N(regex, nextents * (strlen(regex_unit) + 1) + 1) < 0) - goto cleanup; + regex =3D g_new0(char, nextents * (strlen(regex_unit) + 1) + 1); strcat(regex, regex_unit); for (i =3D 1; i < nextents; i++) { /* "," is the separator of "devices" field */ @@ -252,8 +251,7 @@ virStorageBackendLogicalMakeVol(char **const groups, =20 /* Or a completely new volume */ if (vol =3D=3D NULL) { - if (VIR_ALLOC(vol) < 0) - return -1; + vol =3D g_new0(virStorageVolDef, 1); =20 is_new_vol =3D true; vol->type =3D VIR_STORAGE_VOL_BLOCK; diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_back= end_mpath.c index f474ab32a9..20e9b34bbf 100644 --- a/src/storage/storage_backend_mpath.c +++ b/src/storage/storage_backend_mpath.c @@ -49,8 +49,7 @@ virStorageBackendMpathNewVol(virStoragePoolObjPtr pool, virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); g_autoptr(virStorageVolDef) vol =3D NULL; =20 - if (VIR_ALLOC(vol) < 0) - return -1; + vol =3D g_new0(virStorageVolDef, 1); =20 vol->type =3D VIR_STORAGE_VOL_BLOCK; =20 diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backen= d_rbd.c index 09928fdc3c..1630d6eede 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -94,12 +94,10 @@ virStoragePoolDefRBDNamespaceParse(xmlXPathContextPtr c= txt, if (nnodes =3D=3D 0) return 0; =20 - if (VIR_ALLOC(cmdopts) < 0) - goto cleanup; + cmdopts =3D g_new0(virStoragePoolRBDConfigOptionsDef, 1); =20 - if (VIR_ALLOC_N(cmdopts->names, nnodes) < 0 || - VIR_ALLOC_N(cmdopts->values, nnodes) < 0) - goto cleanup; + cmdopts->names =3D g_new0(char *, nnodes); + cmdopts->values =3D g_new0(char *, nnodes); =20 for (i =3D 0; i < nnodes; i++) { if (!(cmdopts->names[cmdopts->noptions] =3D @@ -384,8 +382,7 @@ virStorageBackendRBDNewState(virStoragePoolObjPtr pool) virStorageBackendRBDStatePtr ptr; virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); =20 - if (VIR_ALLOC(ptr) < 0) - return NULL; + ptr =3D g_new0(virStorageBackendRBDState, 1); =20 if (virStorageBackendRBDOpenRADOSConn(ptr, def) < 0) goto error; @@ -604,8 +601,7 @@ virStorageBackendRBDGetVolNames(virStorageBackendRBDSta= tePtr ptr) } } =20 - if (VIR_ALLOC_N(names, nimages + 1) < 0) - goto error; + names =3D g_new0(char *, nimages + 1); nnames =3D nimages; =20 for (i =3D 0; i < nimages; i++) @@ -633,8 +629,7 @@ virStorageBackendRBDGetVolNames(virStorageBackendRBDSta= tePtr ptr) const char *name; =20 while (true) { - if (VIR_ALLOC_N(namebuf, max_size) < 0) - goto error; + namebuf =3D g_new0(char, max_size); =20 rc =3D rbd_list(ptr->ioctx, namebuf, &max_size); if (rc >=3D 0) @@ -712,8 +707,7 @@ virStorageBackendRBDRefreshPool(virStoragePoolObjPtr po= ol) for (i =3D 0; names[i] !=3D NULL; i++) { g_autoptr(virStorageVolDef) vol =3D NULL; =20 - if (VIR_ALLOC(vol) < 0) - goto cleanup; + vol =3D g_new0(virStorageVolDef, 1); =20 vol->name =3D g_steal_pointer(&names[i]); =20 @@ -770,8 +764,7 @@ virStorageBackendRBDCleanupSnapshots(rados_ioctx_t ioct= x, } =20 do { - if (VIR_ALLOC_N(snaps, max_snaps)) - goto cleanup; + snaps =3D g_new0(rbd_snap_info_t, max_snaps); =20 snap_count =3D rbd_snap_list(image, snaps, &max_snaps); if (snap_count <=3D 0) @@ -1028,8 +1021,7 @@ virStorageBackendRBDSnapshotFindNoDiff(rbd_image_t im= age, } =20 do { - if (VIR_ALLOC_N(snaps, max_snaps)) - goto cleanup; + snaps =3D g_new0(rbd_snap_info_t, max_snaps); =20 snap_count =3D rbd_snap_list(image, snaps, &max_snaps); if (snap_count <=3D 0) @@ -1320,8 +1312,7 @@ virStorageBackendRBDVolWipeZero(rbd_image_t image, unsigned long long length; g_autofree char *writebuf =3D NULL; =20 - if (VIR_ALLOC_N(writebuf, info->obj_size * stripe_count) < 0) - return -1; + writebuf =3D g_new0(char, info->obj_size * stripe_count); =20 while (offset < info->size) { length =3D MIN((info->size - offset), (info->obj_size * stripe_cou= nt)); diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backe= nd_scsi.c index b5866935d1..69a01d1a24 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -329,9 +329,7 @@ createVport(virStoragePoolDefPtr def, * retry logic set to true. If the thread isn't created, then no big * deal since it's still possible to refresh the pool later. */ - if (VIR_ALLOC(cbdata) < 0) - return -1; - + cbdata =3D g_new0(virStoragePoolFCRefreshInfo, 1); memcpy(cbdata->pool_uuid, def->uuid, VIR_UUID_BUFLEN); cbdata->fchost_name =3D g_steal_pointer(&name); =20 diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_b= ackend_sheepdog.c index f253c0ed57..12ff9f44d0 100644 --- a/src/storage/storage_backend_sheepdog.c +++ b/src/storage/storage_backend_sheepdog.c @@ -118,8 +118,7 @@ virStorageBackendSheepdogAddVolume(virStoragePoolObjPtr= pool, const char *diskIn return -1; } =20 - if (VIR_ALLOC(vol) < 0) - return -1; + vol =3D g_new0(virStorageVolDef, 1); =20 vol->name =3D g_strdup(diskInfo); =20 diff --git a/src/storage/storage_backend_zfs.c b/src/storage/storage_backen= d_zfs.c index dc692f47ed..4a89f98350 100644 --- a/src/storage/storage_backend_zfs.c +++ b/src/storage/storage_backend_zfs.c @@ -121,8 +121,7 @@ virStorageBackendZFSParseVol(virStoragePoolObjPtr pool, volume =3D vol; =20 if (volume =3D=3D NULL) { - if (VIR_ALLOC(volume) < 0) - goto cleanup; + volume =3D g_new0(virStorageVolDef, 1); =20 is_new_vol =3D true; volume->type =3D VIR_STORAGE_VOL_BLOCK; diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 9e79dbe1e4..16bc53aa46 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -265,8 +265,7 @@ storageStateInitialize(bool privileged, return -1; } =20 - if (VIR_ALLOC(driver) < 0) - return VIR_DRV_STATE_INIT_ERROR; + driver =3D g_new0(virStorageDriverState, 1); =20 driver->lockFD =3D -1; if (virMutexInit(&driver->lock) < 0) { @@ -1956,10 +1955,7 @@ storageVolCreateXML(virStoragePoolPtr pool, int buildret; virStorageVolDefPtr buildvoldef =3D NULL; =20 - if (VIR_ALLOC(buildvoldef) < 0) { - voldef =3D NULL; - goto cleanup; - } + buildvoldef =3D g_new0(virStorageVolDef, 1); =20 /* Make a shallow copy of the 'defined' volume definition, since t= he * original allocation value will change as the user polls 'info', @@ -2143,8 +2139,7 @@ storageVolCreateXMLFrom(virStoragePoolPtr pool, * original allocation value will change as the user polls 'info', * but we only need the initial requested values */ - if (VIR_ALLOC(shadowvol) < 0) - goto cleanup; + shadowvol =3D g_new0(virStorageVolDef, 1); =20 memcpy(shadowvol, voldef, sizeof(*voldef)); =20 @@ -2428,8 +2423,7 @@ storageVolUpload(virStorageVolPtr vol, * interaction and we can just lookup the backend in the callback * routine in order to call the refresh API. */ - if (VIR_ALLOC(cbdata) < 0) - goto cleanup; + cbdata =3D g_new0(virStorageVolStreamInfo, 1); cbdata->pool_name =3D g_strdup(def->name); if (voldef->type =3D=3D VIR_STORAGE_VOL_PLOOP) cbdata->vol_path =3D g_strdup(voldef->target.path); diff --git a/src/storage/storage_file_fs.c b/src/storage/storage_file_fs.c index 8d9023bead..b379a8ca8e 100644 --- a/src/storage/storage_file_fs.c +++ b/src/storage/storage_file_fs.c @@ -73,8 +73,7 @@ virStorageFileBackendFileInit(virStorageSourcePtr src) src->path, (unsigned int)src->drv->uid, (unsigned int)src->drv->gid); =20 - if (VIR_ALLOC(priv) < 0) - return -1; + priv =3D g_new0(virStorageFileBackendFsPriv, 1); =20 src->drv->priv =3D priv; =20 diff --git a/src/storage/storage_file_gluster.c b/src/storage/storage_file_= gluster.c index 608f93d2f6..c84af8a4e8 100644 --- a/src/storage/storage_file_gluster.c +++ b/src/storage/storage_file_gluster.c @@ -109,8 +109,7 @@ virStorageFileBackendGlusterInit(virStorageSourcePtr sr= c) return -1; } =20 - if (VIR_ALLOC(priv) < 0) - return -1; + priv =3D g_new0(virStorageFileBackendGlusterPriv, 1); =20 VIR_DEBUG("initializing gluster storage file %p " "(priv=3D'%p' volume=3D'%s' path=3D'%s') as [%u:%u]", @@ -209,8 +208,7 @@ virStorageFileBackendGlusterRead(virStorageSourcePtr sr= c, } =20 =20 - if (VIR_ALLOC_N(*buf, len) < 0) - return -1; + *buf =3D g_new0(char, len); =20 s =3D *buf; while (len) { diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 7fc529046a..21ad54ac54 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -154,11 +154,9 @@ virStorageBackendCopyToFD(virStorageVolDefPtr vol, if (wbytes < WRITE_BLOCK_SIZE_DEFAULT) wbytes =3D WRITE_BLOCK_SIZE_DEFAULT; =20 - if (VIR_ALLOC_N(zerobuf, wbytes) < 0) - return -errno; + zerobuf =3D g_new0(char, wbytes); =20 - if (VIR_ALLOC_N(buf, rbytes) < 0) - return -errno; + buf =3D g_new0(char, rbytes); =20 if (reflink_copy) { if (reflinkCloneFile(fd, inputfd) < 0) { @@ -1839,14 +1837,14 @@ virStorageBackendUpdateVolTargetInfoFD(virStorageSo= urcePtr target, if (virStorageSourceUpdateBackingSizes(target, fd, sb) < 0) return -1; =20 - if (!target->perms && VIR_ALLOC(target->perms) < 0) - return -1; + if (!target->perms) + target->perms =3D g_new0(virStoragePerms, 1); target->perms->mode =3D sb->st_mode & S_IRWXUGO; target->perms->uid =3D sb->st_uid; target->perms->gid =3D sb->st_gid; =20 - if (!target->timestamps && VIR_ALLOC(target->timestamps) < 0) - return -1; + if (!target->timestamps) + target->timestamps =3D g_new0(virStorageTimestamps, 1); =20 #ifdef __APPLE__ target->timestamps->atime =3D sb->st_atimespec; @@ -2214,12 +2212,8 @@ storageBackendLoadDefaultSecrets(virStorageVolDefPtr= vol) if (!sec) return 0; =20 - if (VIR_ALLOC_N(vol->target.encryption->secrets, 1) < 0 || - VIR_ALLOC(encsec) < 0) { - VIR_FREE(vol->target.encryption->secrets); - virObjectUnref(sec); - return -1; - } + vol->target.encryption->secrets =3D g_new0(virStorageEncryptionSecretP= tr, 1); + encsec =3D g_new0(virStorageEncryptionSecret, 1); =20 vol->target.encryption->nsecrets =3D 1; vol->target.encryption->secrets[0] =3D encsec; @@ -2528,8 +2522,7 @@ storageBackendWipeLocal(const char *path, off_t size; g_autofree char *writebuf =3D NULL; =20 - if (VIR_ALLOC_N(writebuf, writebuf_length) < 0) - return -1; + writebuf =3D g_new0(char, writebuf_length); =20 if (!zero_end) { if ((size =3D lseek(fd, 0, SEEK_SET)) < 0) { @@ -2873,8 +2866,7 @@ virStorageUtilGlusterExtractPoolSources(const char *h= ost, goto cleanup; } =20 - if (VIR_ALLOC_N(src->hosts, 1) < 0) - goto cleanup; + src->hosts =3D g_new0(virStoragePoolSourceHost, 1); src->nhost =3D 1; =20 src->hosts[0].name =3D g_strdup(host); @@ -3535,8 +3527,7 @@ virStorageBackendRefreshLocal(virStoragePoolObjPtr po= ol) continue; } =20 - if (VIR_ALLOC(vol) < 0) - goto cleanup; + vol =3D g_new0(virStorageVolDef, 1); =20 vol->name =3D g_strdup(ent->d_name); =20 @@ -3671,8 +3662,7 @@ virStorageBackendSCSINewLun(virStoragePoolObjPtr pool, return -1; } =20 - if (VIR_ALLOC(vol) < 0) - return -1; + vol =3D g_new0(virStorageVolDef, 1); =20 vol->type =3D VIR_STORAGE_VOL_BLOCK; =20 --=20 2.26.2