From nobody Sun Feb 8 11:59:17 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=1601894256; cv=none; d=zohomail.com; s=zohoarc; b=YMZQemvUaUXHaIgaZ+qOXMHpYDr+2I49Vlnq57SjGmNhTPBetrzVKyRiWpNZgS8PaTAVRbaiPnfw4zi0R42pVg4e6ZQXA8c+u5CwSmlQrSMZorMh2AYfNk4Ckvb5j0ziYN5SZ/xGG9IK7OQegSHR61cudHHqcVXvSeZ1DfP6WN4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601894256; 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=nWWWkE79I4qdDdPTy6yrJtF1Y93LYqPWBNm4kPSv/C0=; b=aVlNCgwpI3mQjTc2JrVDyFvxh6ts3nFhh+Sv6BMN9uANYAqbzRl81cyfpnaWxWD9mODhdpWVfV7fEb0sCEud4kpCxWEd0gXIjXcGJzaRzyXdwwbhvk+QS3s0gIOhu2aqFm4RhIZrQm2L6Xa86WoOU6LfJqqIFJHM/7kwNHMB6S0= 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 1601894256301719.2738489624631; Mon, 5 Oct 2020 03:37:36 -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-595-LNS7w_N2PpeXbgBNmzvFyg-1; Mon, 05 Oct 2020 06:37:32 -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 BA7AD100854F; Mon, 5 Oct 2020 10:37:26 +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 95A431964D; Mon, 5 Oct 2020 10:37:26 +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 547C244A64; Mon, 5 Oct 2020 10:37:26 +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 095AajP8018879 for ; Mon, 5 Oct 2020 06:36:45 -0400 Received: by smtp.corp.redhat.com (Postfix) id A91DE5C225; Mon, 5 Oct 2020 10:36:45 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 31B055C1BD for ; Mon, 5 Oct 2020 10:36:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601894255; 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=nWWWkE79I4qdDdPTy6yrJtF1Y93LYqPWBNm4kPSv/C0=; b=HxYG/YC7xICyt/2PQFqZix0T4AuDbZPEE8Cvv6MgJHd2ynf/CFu82VYjgLJC+N2LsZe7Gf 72TW4EdUnZ/a29NUpGmbkw3kXWPft5PeT8EH6/KIipilUDh1o8ttCyzkzCQKqWbs4zDKxC n1JpMBSkewD1R01zt1lyM7Uiccc9aMg= X-MC-Unique: LNS7w_N2PpeXbgBNmzvFyg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/9] qemu: capabilities: use g_new0 Date: Mon, 5 Oct 2020 12:36:32 +0200 Message-Id: <2b91bb615fcb9ba3cab9f92c46c10f02b04de94f.1601894130.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.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 --- src/qemu/qemu_capabilities.c | 48 ++++++++++++------------------------ 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 5dcfcd574d..2e0e4492a4 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -943,14 +943,12 @@ virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCap= s, *machines =3D NULL; *nmachines =3D accel->nmachineTypes; =20 - if (*nmachines && - VIR_ALLOC_N(*machines, accel->nmachineTypes) < 0) - goto error; + if (*nmachines) + *machines =3D g_new0(virCapsGuestMachinePtr, accel->nmachineTypes); =20 for (i =3D 0; i < accel->nmachineTypes; i++) { virCapsGuestMachinePtr mach; - if (VIR_ALLOC(mach) < 0) - goto error; + mach =3D g_new0(virCapsGuestMachine, 1); (*machines)[i] =3D mach; if (accel->machineTypes[i].alias) { mach->name =3D g_strdup(accel->machineTypes[i].alias); @@ -985,8 +983,7 @@ virQEMUCapsGetMachineTypesCaps(virQEMUCapsPtr qemuCaps, =20 if (!found) { virCapsGuestMachinePtr mach; - if (VIR_ALLOC(mach) < 0) - goto error; + mach =3D g_new0(virCapsGuestMachine, 1); if (VIR_INSERT_ELEMENT_COPY(*machines, i, *nmachines, mach) < = 0) { VIR_FREE(mach); goto error; @@ -1868,8 +1865,7 @@ virQEMUCapsSEVInfoCopy(virSEVCapabilityPtr *dst, { g_autoptr(virSEVCapability) tmp =3D NULL; =20 - if (VIR_ALLOC(tmp) < 0) - return -1; + tmp =3D g_new0(virSEVCapability, 1); =20 tmp->pdh =3D g_strdup(src->pdh); tmp->cert_chain =3D g_strdup(src->cert_chain); @@ -1949,8 +1945,7 @@ virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemu= Caps) virQEMUCapsAccelCopy(&ret->tcg, &qemuCaps->tcg) < 0) goto error; =20 - if (VIR_ALLOC_N(ret->gicCapabilities, qemuCaps->ngicCapabilities) < 0) - goto error; + ret->gicCapabilities =3D g_new0(virGICCapability, qemuCaps->ngicCapabi= lities); ret->ngicCapabilities =3D qemuCaps->ngicCapabilities; for (i =3D 0; i < qemuCaps->ngicCapabilities; i++) ret->gicCapabilities[i] =3D qemuCaps->gicCapabilities[i]; @@ -3184,8 +3179,7 @@ virQEMUCapsGetCPUFeatures(virQEMUCapsPtr qemuCaps, if (!modelInfo) return 0; =20 - if (VIR_ALLOC_N(list, modelInfo->nprops + 1) < 0) - return -1; + list =3D g_new0(char *, modelInfo->nprops + 1); =20 n =3D 0; for (i =3D 0; i < modelInfo->nprops; i++) { @@ -3561,8 +3555,7 @@ virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps, } =20 cpu->model =3D g_strdup(modelInfo->name); - if (VIR_ALLOC_N(cpu->features, modelInfo->nprops) < 0) - return -1; + cpu->features =3D g_new0(virCPUFeatureDef, modelInfo->nprops); =20 cpu->nfeatures_max =3D modelInfo->nprops; cpu->nfeatures =3D 0; @@ -3872,8 +3865,7 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccelPtr c= aps, goto cleanup; } =20 - if (VIR_ALLOC(hostCPU) < 0) - goto cleanup; + hostCPU =3D g_new0(qemuMonitorCPUModelInfo, 1); =20 if (!(hostCPU->name =3D virXMLPropString(hostCPUNode, "model"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -3894,9 +3886,7 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccelPtr c= aps, ctxt->node =3D hostCPUNode; =20 if ((n =3D virXPathNodeSet("./property", ctxt, &nodes)) > 0) { - if (VIR_ALLOC_N(hostCPU->props, n) < 0) - goto cleanup; - + hostCPU->props =3D g_new0(qemuMonitorCPUProperty, n); hostCPU->nprops =3D n; =20 for (i =3D 0; i < n; i++) { @@ -4041,8 +4031,7 @@ virQEMUCapsLoadCPUModels(virQEMUCapsAccelPtr caps, if (nblockers > 0) { size_t j; =20 - if (VIR_ALLOC_N(cpu->blockers, nblockers + 1) < 0) - return -1; + cpu->blockers =3D g_new0(char *, nblockers + 1); =20 for (j =3D 0; j < nblockers; j++) { if (!(cpu->blockers[j] =3D virXMLPropString(blockerNodes[j= ], "name"))) { @@ -4081,8 +4070,7 @@ virQEMUCapsLoadMachines(virQEMUCapsAccelPtr caps, return 0; =20 caps->nmachineTypes =3D n; - if (VIR_ALLOC_N(caps->machineTypes, caps->nmachineTypes) < 0) - return -1; + caps->machineTypes =3D g_new0(virQEMUCapsMachineType, caps->nmachineTy= pes); =20 for (i =3D 0; i < n; i++) { if (!(caps->machineTypes[i].name =3D virXMLPropString(nodes[i], "n= ame"))) { @@ -4189,8 +4177,7 @@ virQEMUCapsParseSEVInfo(virQEMUCapsPtr qemuCaps, xmlX= PathContextPtr ctxt) return -1; } =20 - if (VIR_ALLOC(sev) < 0) - return -1; + sev =3D g_new0(virSEVCapability, 1); =20 if (virXPathUInt("string(./sev/cbitpos)", ctxt, &sev->cbitpos) < 0) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -4408,8 +4395,7 @@ virQEMUCapsLoadCache(virArch hostArch, bool boolValue; =20 qemuCaps->ngicCapabilities =3D n; - if (VIR_ALLOC_N(qemuCaps->gicCapabilities, n) < 0) - goto cleanup; + qemuCaps->gicCapabilities =3D g_new0(virGICCapability, n); =20 for (i =3D 0; i < n; i++) { virGICCapabilityPtr cap =3D &qemuCaps->gicCapabilities[i]; @@ -5674,8 +5660,7 @@ virQEMUCapsCacheNew(const char *libDir, if (!(cache =3D virFileCacheNew(capsCacheDir, "xml", &qemuCapsCacheHan= dlers))) goto error; =20 - if (VIR_ALLOC(priv) < 0) - goto error; + priv =3D g_new0(virQEMUCapsCachePriv, 1); virFileCacheSetPriv(cache, priv); =20 priv->libDir =3D g_strdup(libDir); @@ -5899,8 +5884,7 @@ virQEMUCapsFillDomainLoaderCaps(virDomainCapsLoaderPt= r capsLoader, capsLoader->readonly.report =3D true; capsLoader->secure.report =3D true; =20 - if (VIR_ALLOC_N(capsLoader->values.values, nfirmwares) < 0) - return -1; + capsLoader->values.values =3D g_new0(char *, nfirmwares); =20 for (i =3D 0; i < nfirmwares; i++) { const char *filename =3D firmwares[i]->name; --=20 2.26.2