From nobody Sun Feb 8 14:06:57 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=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 --- 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