From nobody Sun Feb 8 16:53:13 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601894254; cv=none; d=zohomail.com; s=zohoarc; b=cxe8B05NF9slGB0u6HIbc61ES8XDEY5Y7jgpTshzvA8FbAqPdUxpVDdiBMguDGelkh4u4ESIEsqdoW7pnzzYb1NGn7yfHJ9kI8V4y8tGxHXknMsn4W91dnU2fsZgqWzSV62pe+rkZeOcyQ6UCAFzGCnsl6mWfoam+TR8pNmQq88= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601894254; 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=Kx3cEE+jcNKYUzipxP5TyucllhOQ08yg0cjY5hFjkVg=; b=Bj4kyZBAqz7GuS2c7IzCxbqlBNtKwTWNqZ/48oSo/Wed/g1dccBYnVnvO6KH+w6yEUBmgpBTdeGkJMSJJvAl74mUQSHGiMnOoJ4MD8pb/lqzcmoYz5ARINmitw3Gj/CrjB8HM6va+7bnpIMx1bTX8KXvgIu5AZRVr7eIXvcdHFg= 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 1601894254418977.982662563996; Mon, 5 Oct 2020 03:37:34 -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-370-hPER7oRROOCBZARa1u4iww-1; Mon, 05 Oct 2020 06:37:30 -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 E7B861008542; Mon, 5 Oct 2020 10:37:24 +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 C27B9277C9; Mon, 5 Oct 2020 10:37:24 +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 92E8744A5E; Mon, 5 Oct 2020 10:37:24 +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 095Aash3018942 for ; Mon, 5 Oct 2020 06:36:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id EB3145C225; Mon, 5 Oct 2020 10:36:54 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 73C195C1BD for ; Mon, 5 Oct 2020 10:36:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601894253; 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=Kx3cEE+jcNKYUzipxP5TyucllhOQ08yg0cjY5hFjkVg=; b=FV502j6vY3B74Uq+527qT2393uU80htdo2qlQzs9ItJ7cvacsS5GUcFLjsl0e0QjuHFlTx R14fo5xSx03ZxilLGC5IiemPV+5z50yKjvRBK+c8rSzjD3UDonjAW6P1xkBccXm+sAgzd5 lqaHz+7r26gfow7z2f9j4iBDR7cOQy4= X-MC-Unique: hPER7oRROOCBZARa1u4iww-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 8/9] qemu: firmware: use g_new0 Date: Mon, 5 Oct 2020 12:36:38 +0200 Message-Id: <20a79ba223337dc150602740db9c66295585dc8c.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_firmware.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index 480ce0b00d..eebe6fcf78 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -301,8 +301,7 @@ qemuFirmwareInterfaceParse(const char *path, =20 ninterfaces =3D virJSONValueArraySize(interfacesJSON); =20 - if (VIR_ALLOC_N(interfaces, ninterfaces) < 0) - return -1; + interfaces =3D g_new0(qemuFirmwareOSInterface, ninterfaces); =20 for (i =3D 0; i < ninterfaces; i++) { virJSONValuePtr item =3D virJSONValueArrayGet(interfacesJSON, i); @@ -504,8 +503,7 @@ qemuFirmwareTargetParse(const char *path, =20 ntargets =3D virJSONValueArraySize(targetsJSON); =20 - if (VIR_ALLOC_N(targets, ntargets) < 0) - return -1; + targets =3D g_new0(qemuFirmwareTargetPtr, ntargets); =20 for (i =3D 0; i < ntargets; i++) { virJSONValuePtr item =3D virJSONValueArrayGet(targetsJSON, i); @@ -515,8 +513,7 @@ qemuFirmwareTargetParse(const char *path, size_t nmachines; size_t j; =20 - if (VIR_ALLOC(t) < 0) - goto cleanup; + t =3D g_new0(qemuFirmwareTarget, 1); =20 if (!(architectureStr =3D virJSONValueObjectGetString(item, "archi= tecture"))) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -541,8 +538,7 @@ qemuFirmwareTargetParse(const char *path, =20 nmachines =3D virJSONValueArraySize(machines); =20 - if (VIR_ALLOC_N(t->machines, nmachines) < 0) - goto cleanup; + t->machines =3D g_new0(char *, nmachines); =20 for (j =3D 0; j < nmachines; j++) { virJSONValuePtr machine =3D virJSONValueArrayGet(machines, j); @@ -588,8 +584,7 @@ qemuFirmwareFeatureParse(const char *path, =20 nfeatures =3D virJSONValueArraySize(featuresJSON); =20 - if (VIR_ALLOC_N(features, nfeatures) < 0) - return -1; + features =3D g_new0(qemuFirmwareFeature, nfeatures); =20 for (i =3D 0; i < nfeatures; i++) { virJSONValuePtr item =3D virJSONValueArrayGet(featuresJSON, i); @@ -632,8 +627,7 @@ qemuFirmwareParse(const char *path) return NULL; } =20 - if (VIR_ALLOC(fw) < 0) - return NULL; + fw =3D g_new0(qemuFirmware, 1); =20 if (qemuFirmwareInterfaceParse(path, doc, fw) < 0) return NULL; @@ -1050,9 +1044,8 @@ qemuFirmwareEnableFeatures(virQEMUDriverPtr driver, =20 switch (fw->mapping.device) { case QEMU_FIRMWARE_DEVICE_FLASH: - if (!def->os.loader && - VIR_ALLOC(def->os.loader) < 0) - return -1; + if (!def->os.loader) + def->os.loader =3D g_new0(virDomainLoaderDef, 1); =20 def->os.loader->type =3D VIR_DOMAIN_LOADER_TYPE_PFLASH; def->os.loader->readonly =3D VIR_TRISTATE_BOOL_YES; @@ -1093,9 +1086,8 @@ qemuFirmwareEnableFeatures(virQEMUDriverPtr driver, break; =20 case QEMU_FIRMWARE_DEVICE_MEMORY: - if (!def->os.loader && - VIR_ALLOC(def->os.loader) < 0) - return -1; + if (!def->os.loader) + def->os.loader =3D g_new0(virDomainLoaderDef, 1); =20 def->os.loader->type =3D VIR_DOMAIN_LOADER_TYPE_ROM; def->os.loader->path =3D g_strdup(memory->filename); @@ -1201,8 +1193,7 @@ qemuFirmwareFetchParsedConfigs(bool privileged, =20 npaths =3D virStringListLength((const char **)paths); =20 - if (VIR_ALLOC_N(firmwares, npaths) < 0) - return -1; + firmwares =3D g_new0(qemuFirmwarePtr, npaths); =20 for (i =3D 0; i < npaths; i++) { if (!(firmwares[i] =3D qemuFirmwareParse(paths[i]))) @@ -1431,8 +1422,7 @@ qemuFirmwareGetSupported(const char *machine, } =20 if (j =3D=3D *nfws) { - if (VIR_ALLOC(tmp) < 0) - return -1; + tmp =3D g_new0(virFirmware, 1); =20 tmp->name =3D g_strdup(fwpath); tmp->nvram =3D g_strdup(nvrampath); --=20 2.26.2