From nobody Sun May 5 10:23:18 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=1601894244; cv=none; d=zohomail.com; s=zohoarc; b=C9szL/6BfzZZ/3Vauq3tOt68EvYKA0PcxTLlDPbFoJmMgyE6POhcj8v+XrOsNUNEKXxkT2ux/SQtLl2riy3kgaWqIdPOrYvZvB3RCPscJzRYudPZSCQUm+HK/+E4byU9z2Thip10HvzGaJF6x6D/YSN7obSZDFajEeG3LJ6eXNw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601894244; 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=jXdmoz3A03T5p7RYMDhltXDU6+mYhpZ+o4CZ6lq/lpE=; b=aRJcHboFaoiZXZryVh/QDU72Zlbwwsqoc4STTT+SFP5Pc93o/Y5yb6Ry1dSUpXR3G0Xfyp7QF5JEiLphyxMa5Eamw47Uq+dwEwpqYsIo5uTrR28U8bW7Ut57VjL52OFWA+DkIALEesIVgHYDdjVYKgVgUTu+1l0zw7Dfn7/XGFg= 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 1601894244808265.2972122621388; Mon, 5 Oct 2020 03:37:24 -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-53-kiMaOS96PcGk-Y_3gFBnBw-1; Mon, 05 Oct 2020 06:37:20 -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 9840281CBDF; Mon, 5 Oct 2020 10:37: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 6FBBD1C92B; Mon, 5 Oct 2020 10:37: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 3955E181A6DF; Mon, 5 Oct 2020 10:37: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 095AaiN1018871 for ; Mon, 5 Oct 2020 06:36:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id D87145C1BD; Mon, 5 Oct 2020 10:36:44 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 614205C225 for ; Mon, 5 Oct 2020 10:36:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601894243; 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=jXdmoz3A03T5p7RYMDhltXDU6+mYhpZ+o4CZ6lq/lpE=; b=B/IyEaUPLfqzbJSfXpvhdi8m+IX2Vjtg5UlViME9AFhcU33J30bczMiLUXptGtJhvbkCkp ZCHDa1Jkf29pTySHIcFnqgTh4yzJBWjh4RGAEcmnAL+PvdyRcSShlSturW26kO8NXbfJJ2 ym7502lMu532ymNccgIuAugBV0j8ItA= X-MC-Unique: kiMaOS96PcGk-Y_3gFBnBw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/9] qemu: separate out VIR_ALLOC calls Date: Mon, 5 Oct 2020 12:36:31 +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) Move them to separate conditions to reduce churn in following patches. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Erik Skultety --- src/qemu/qemu_domain.c | 6 ++++-- src/qemu/qemu_monitor_json.c | 6 ++++-- src/qemu/qemu_process.c | 23 ++++++++++++----------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0331fd55e0..491fb0ed3d 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3719,8 +3719,10 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def, =20 if (j =3D=3D def->npanics) { virDomainPanicDefPtr panic; - if (VIR_ALLOC(panic) < 0 || - VIR_APPEND_ELEMENT_COPY(def->panics, + if (VIR_ALLOC(panic) < 0) + return -1; + + if (VIR_APPEND_ELEMENT_COPY(def->panics, def->npanics, panic) < 0) { VIR_FREE(panic); return -1; diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index bc242c798b..c399100dbe 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -4890,8 +4890,10 @@ qemuMonitorJSONParseBlockJobInfo(virHashTablePtr blo= ckJobs, if (!rawjobname) device =3D qemuAliasDiskDriveSkipPrefix(device); =20 - if (VIR_ALLOC(info) < 0 || - virHashAddEntry(blockJobs, device, info) < 0) { + if (VIR_ALLOC(info) < 0) + return -1; + + if (virHashAddEntry(blockJobs, device, info) < 0) { VIR_FREE(info); return -1; } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 9122069cc9..93cbb37986 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -832,17 +832,18 @@ qemuProcessHandleWatchdog(qemuMonitorPtr mon G_GNUC_U= NUSED, =20 if (vm->def->watchdog->action =3D=3D VIR_DOMAIN_WATCHDOG_ACTION_DUMP) { struct qemuProcessEvent *processEvent; - if (VIR_ALLOC(processEvent) =3D=3D 0) { - processEvent->eventType =3D QEMU_PROCESS_EVENT_WATCHDOG; - processEvent->action =3D VIR_DOMAIN_WATCHDOG_ACTION_DUMP; - /* Hold an extra reference because we can't allow 'vm' to be - * deleted before handling watchdog event is finished. - */ - processEvent->vm =3D virObjectRef(vm); - if (virThreadPoolSendJob(driver->workerPool, 0, processEvent) = < 0) { - virObjectUnref(vm); - qemuProcessEventFree(processEvent); - } + if (VIR_ALLOC(processEvent) < 0) + ; + + processEvent->eventType =3D QEMU_PROCESS_EVENT_WATCHDOG; + processEvent->action =3D VIR_DOMAIN_WATCHDOG_ACTION_DUMP; + /* Hold an extra reference because we can't allow 'vm' to be + * deleted before handling watchdog event is finished. + */ + processEvent->vm =3D virObjectRef(vm); + if (virThreadPoolSendJob(driver->workerPool, 0, processEvent) < 0)= { + virObjectUnref(vm); + qemuProcessEventFree(processEvent); } } =20 --=20 2.26.2 From nobody Sun May 5 10:23:18 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=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 Reviewed-by: Erik Skultety --- 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 From nobody Sun May 5 10:23:18 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=1601894251; cv=none; d=zohomail.com; s=zohoarc; b=U/D4Cc/SG2+XnhDa3kE+aWtf7Ayqvs00cL2XqUoM846KKbaq3j79N0IopmhWYEKj8ZG6aiAJHo6c/O9E2b+rZnOP92/GWm74T1UVAMWe+w4RBld9ootDwlXaJAkjukWJWoHYT5Am176hlNZcvy5p9TEt4IJymwFJqEYiHB+kFfE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601894251; 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=JAkZUrlnsF5+VbETyk+j0XnnOSFPLklFl7BeaRTtwdo=; b=cXiL14gdpQK267RDQbH4XXrePAO1Cqe2diSaU9zTnYAX8BKFFaW3VaRuFiZVpxdxPEnt21ZFMR7ye+mRK4Lgmb2z7t/qNzkLEuKU5U1FMXnDQ58MPMLXSykB6ZOom9lw0bfAsqYa82/sgth5Fry7PDPQiLGFtN4bQBjxrPgvZMc= 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 1601894251839982.2099659675665; Mon, 5 Oct 2020 03:37:31 -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-45-2EoY_XN_PTGsKDt35HlAww-1; Mon, 05 Oct 2020 06:37:28 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C7A5F8015C6; Mon, 5 Oct 2020 10:37:22 +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 B228A100164C; Mon, 5 Oct 2020 10:37:21 +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 7F155181A720; Mon, 5 Oct 2020 10:37:21 +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 095AakU0018889 for ; Mon, 5 Oct 2020 06:36:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 79BD85C1BD; Mon, 5 Oct 2020 10:36:46 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 025BD5C225 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=1601894250; 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=JAkZUrlnsF5+VbETyk+j0XnnOSFPLklFl7BeaRTtwdo=; b=UnoFpDg8mRx5cgPCrMs+TFhhAz0tNnKMFW5+LFi7krV8E5TzPEaeVMnVk0g2ywFaYz5emn JBWdetP40Qtwl9cEHsJ0jJ4vzkrzXecEZJM/uDXt/u0O+rYdLjrx7FwxD6hwjrgKTBzuAg Ytotf3HDUCYWQn5P1DddtzffLQt6lNY= X-MC-Unique: 2EoY_XN_PTGsKDt35HlAww-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 3/9] qemu: domain: use g_new0 Date: Mon, 5 Oct 2020 12:36:33 +0200 Message-Id: <4c6d9a4f30c788b732644b26a511487a687eacf8.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.22 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: Erik Skultety --- src/qemu/qemu_domain.c | 53 ++++++++++++++---------------------------- 1 file changed, 17 insertions(+), 36 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 491fb0ed3d..15912317de 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -496,8 +496,7 @@ qemuDomainMasterKeyReadFile(qemuDomainObjPrivatePtr pri= v) goto error; } =20 - if (VIR_ALLOC_N(masterKey, 1024) < 0) - goto error; + masterKey =3D g_new0(uint8_t, 1024); =20 if ((masterKeyLen =3D saferead(fd, masterKey, 1024)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -572,8 +571,7 @@ qemuDomainMasterKeyCreate(virDomainObjPtr vm) if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_SECRET)) return 0; =20 - if (VIR_ALLOC_N(priv->masterKey, QEMU_DOMAIN_MASTER_KEY_LEN) < 0) - return -1; + priv->masterKey =3D g_new0(uint8_t, QEMU_DOMAIN_MASTER_KEY_LEN); priv->masterKeyLen =3D QEMU_DOMAIN_MASTER_KEY_LEN; =20 if (virRandomBytes(priv->masterKey, priv->masterKeyLen) < 0) { @@ -1188,8 +1186,7 @@ qemuDomainSecretInfoNewPlain(virSecretUsageType usage= Type, { qemuDomainSecretInfoPtr secinfo =3D NULL; =20 - if (VIR_ALLOC(secinfo) < 0) - return NULL; + secinfo =3D g_new0(qemuDomainSecretInfo, 1); =20 if (qemuDomainSecretPlainSetup(secinfo, usageType, username, lookupDef= ) < 0) { g_clear_pointer(&secinfo, qemuDomainSecretInfoFree); @@ -1689,8 +1686,7 @@ qemuDomainObjPrivateAlloc(void *opaque) { qemuDomainObjPrivatePtr priv; =20 - if (VIR_ALLOC(priv) < 0) - return NULL; + priv =3D g_new0(qemuDomainObjPrivate, 1); =20 if (qemuDomainObjInitJob(&priv->job, &qemuPrivateJobCallbacks) < 0) { virReportSystemError(errno, "%s", @@ -1845,9 +1841,7 @@ qemuStorageSourcePrivateDataAssignSecinfo(qemuDomainS= ecretInfoPtr *secinfo, return 0; =20 if (!*secinfo) { - if (VIR_ALLOC(*secinfo) < 0) - return -1; - + *secinfo =3D g_new0(qemuDomainSecretInfo, 1); (*secinfo)->type =3D VIR_DOMAIN_SECRET_INFO_TYPE_AES; } =20 @@ -3083,8 +3077,7 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, } if (n > 0) { /* NULL-terminated list */ - if (VIR_ALLOC_N(priv->qemuDevices, n + 1) < 0) - goto error; + priv->qemuDevices =3D g_new0(char *, n + 1); =20 for (i =3D 0; i < n; i++) { priv->qemuDevices[i] =3D virXMLPropString(nodes[i], "alias"); @@ -3245,8 +3238,7 @@ qemuDomainDefNamespaceParseCommandlineArgs(qemuDomain= XmlNsDefPtr nsdef, if (nnodes =3D=3D 0) return 0; =20 - if (VIR_ALLOC_N(nsdef->args, nnodes) < 0) - return -1; + nsdef->args =3D g_new0(char *, nnodes); =20 for (i =3D 0; i < nnodes; i++) { if (!(nsdef->args[nsdef->num_args++] =3D virXMLPropString(nodes[i]= , "value"))) { @@ -3293,9 +3285,8 @@ qemuDomainDefNamespaceParseCommandlineEnv(qemuDomainX= mlNsDefPtr nsdef, if (nnodes =3D=3D 0) return 0; =20 - if (VIR_ALLOC_N(nsdef->env_name, nnodes) < 0 || - VIR_ALLOC_N(nsdef->env_value, nnodes) < 0) - return -1; + nsdef->env_name =3D g_new0(char *, nnodes); + nsdef->env_value =3D g_new0(char *, nnodes); =20 for (i =3D 0; i < nnodes; i++) { if (!(nsdef->env_name[nsdef->num_env] =3D virXMLPropString(nodes[i= ], "name"))) { @@ -3331,8 +3322,7 @@ qemuDomainDefNamespaceParseCaps(qemuDomainXmlNsDefPtr= nsdef, return -1; =20 if (nnodesadd > 0) { - if (VIR_ALLOC_N(nsdef->capsadd, nnodesadd) < 0) - return -1; + nsdef->capsadd =3D g_new0(char *, nnodesadd); =20 for (i =3D 0; i < nnodesadd; i++) { if (!(nsdef->capsadd[nsdef->ncapsadd++] =3D virXMLPropString(n= odesadd[i], "capability"))) { @@ -3344,8 +3334,7 @@ qemuDomainDefNamespaceParseCaps(qemuDomainXmlNsDefPtr= nsdef, } =20 if (nnodesdel > 0) { - if (VIR_ALLOC_N(nsdef->capsdel, nnodesdel) < 0) - return -1; + nsdef->capsdel =3D g_new0(char *, nnodesdel); =20 for (i =3D 0; i < nnodesdel; i++) { if (!(nsdef->capsdel[nsdef->ncapsdel++] =3D virXMLPropString(n= odesdel[i], "capability"))) { @@ -3367,8 +3356,7 @@ qemuDomainDefNamespaceParse(xmlXPathContextPtr ctxt, qemuDomainXmlNsDefPtr nsdata =3D NULL; int ret =3D -1; =20 - if (VIR_ALLOC(nsdata) < 0) - return -1; + nsdata =3D g_new0(qemuDomainXmlNsDef, 1); =20 if (qemuDomainDefNamespaceParseCommandlineArgs(nsdata, ctxt) < 0 || qemuDomainDefNamespaceParseCommandlineEnv(nsdata, ctxt) < 0 || @@ -3661,8 +3649,7 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def, =20 if (addDefaultMemballoon && !def->memballoon) { virDomainMemballoonDefPtr memballoon; - if (VIR_ALLOC(memballoon) < 0) - return -1; + memballoon =3D g_new0(virDomainMemballoonDef, 1); =20 memballoon->model =3D VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO; def->memballoon =3D memballoon; @@ -3718,9 +3705,7 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def, } =20 if (j =3D=3D def->npanics) { - virDomainPanicDefPtr panic; - if (VIR_ALLOC(panic) < 0) - return -1; + virDomainPanicDefPtr panic =3D g_new0(virDomainPanicDef, 1); =20 if (VIR_APPEND_ELEMENT_COPY(def->panics, def->npanics, panic) < 0) { @@ -5911,12 +5896,9 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driv= er, virDomainControllerDefPtr *controllers =3D def->controllers; int ncontrollers =3D def->ncontrollers; =20 - if (VIR_ALLOC_N(def->controllers, ncontrollers - toremove) < 0= ) { - def->controllers =3D controllers; - goto cleanup; - } - + def->controllers =3D g_new0(virDomainControllerDefPtr, ncontro= llers - toremove); def->ncontrollers =3D 0; + for (i =3D 0; i < ncontrollers; i++) { if (controllers[i] !=3D usb && controllers[i] !=3D pci) def->controllers[def->ncontrollers++] =3D controllers[= i]; @@ -6347,8 +6329,7 @@ ssize_t qemuDomainLogContextRead(qemuDomainLogContext= Ptr ctxt, /* Best effort jump to start of messages */ ignore_value(lseek(ctxt->readfd, ctxt->pos, SEEK_SET)); =20 - if (VIR_ALLOC_N(buf, buflen) < 0) - return -1; + buf =3D g_new0(char, buflen); =20 got =3D saferead(ctxt->readfd, buf, buflen - 1); if (got < 0) { --=20 2.26.2 From nobody Sun May 5 10:23:18 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=1601894293; cv=none; d=zohomail.com; s=zohoarc; b=Y2vJqHh38YVb5SvsHx1X+qWTGimEirIs26S6B/+RaINm4JiclDpxDyLgIztlXmA40bvuLi/OjLQH3JsoTSaAlW4ELj5mf4QUV0APpWFv7UKCz7C4AqgwxauLb04nCb/qYImkGj9GFHP72hKFMLKAMXqa2Hr2FrZOkxrfUP3J7o0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601894293; 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=hXTUlh1knrfxpt1GnRR16KC3ZuG/QxJxrduX9nsVygo=; b=BKcT0oOP7UmU5cZos5loWYqjqqTLySPb+C2/OrIPhbUvW0fcUpA1imDXDsS2wjSCrWtYZbgrwR/2wXL9npspsH/89dlsA4HlJcUhNFecwSJ/FVHITtqULhlOeybyh2n53Mxg8oplGONVDkj9AI5DWG/9n9X5KsKmWQF/1OI0Hno= 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 1601894293328803.5817783814191; Mon, 5 Oct 2020 03:38:13 -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-162-VfMh3RqBNe-2ZVBY_Gqz2Q-1; Mon, 05 Oct 2020 06:38:10 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CC7221868412; Mon, 5 Oct 2020 10:38:03 +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 AC9245D9E4; Mon, 5 Oct 2020 10:38:03 +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 7AFC2181A88C; Mon, 5 Oct 2020 10:38:03 +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 095Aan7a018908 for ; Mon, 5 Oct 2020 06:36:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id C91955C22B; Mon, 5 Oct 2020 10:36:49 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 51CFB5C1BD for ; Mon, 5 Oct 2020 10:36:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601894292; 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=hXTUlh1knrfxpt1GnRR16KC3ZuG/QxJxrduX9nsVygo=; b=CACfyKzfyD27RExoc5qlPK/LZrIPto6d8b5qCMY5MV6gR/AzbYWM/ko+1SXaFRSbHMCK7z tk+Lr4pSoGJG1RafUnIfMZQY5qH7CmErXMtM5mnosmezDPv1KcqD/9Vda/4fa6PH8g05Yc EcJVx8RK/j8hXH92vmrQ+p5WYp3bPZg= X-MC-Unique: VfMh3RqBNe-2ZVBY_Gqz2Q-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 4/9] qemu: driver: use g_new0 Date: Mon, 5 Oct 2020 12:36:34 +0200 Message-Id: <4c0cbd0a862205b052b36c149b0d8391b081406b.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.79 on 10.5.11.14 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: Erik Skultety --- src/qemu/qemu_driver.c | 62 ++++++++++++++---------------------------- 1 file changed, 21 insertions(+), 41 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 85b6a6a321..e622da56bd 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -625,8 +625,7 @@ qemuStateInitialize(bool privileged, const char *defsecmodel =3D NULL; g_autofree virSecurityManagerPtr *sec_managers =3D NULL; =20 - if (VIR_ALLOC(qemu_driver) < 0) - return VIR_DRV_STATE_INIT_ERROR; + qemu_driver =3D g_new0(virQEMUDriver, 1); =20 qemu_driver->lockFD =3D -1; =20 @@ -1059,8 +1058,7 @@ qemuStateStop(void) VIR_CONNECT_LIST_DOMAINS_AC= TIVE)) < 0) goto cleanup; =20 - if (VIR_ALLOC_N(flags, numDomains) < 0) - goto cleanup; + flags =3D g_new0(unsigned int, numDomains); =20 /* First we pause all VMs to make them stop dirtying pages, etc. We remember if any VMs were paused so @@ -5043,14 +5041,12 @@ qemuDomainGetIOThreadsLive(virQEMUDriverPtr driver, goto endjob; } =20 - if (VIR_ALLOC_N(info_ret, niothreads) < 0) - goto endjob; + info_ret =3D g_new0(virDomainIOThreadInfoPtr, niothreads); =20 for (i =3D 0; i < niothreads; i++) { virBitmapPtr map =3D NULL; =20 - if (VIR_ALLOC(info_ret[i]) < 0) - goto endjob; + info_ret[i] =3D g_new0(virDomainIOThreadInfo, 1); info_ret[i]->iothread_id =3D iothreads[i]->iothread_id; =20 if (!(map =3D virProcessGetAffinity(iothreads[i]->thread_id))) @@ -5098,12 +5094,10 @@ qemuDomainGetIOThreadsConfig(virDomainDefPtr target= Def, if (targetDef->niothreadids =3D=3D 0) return 0; =20 - if (VIR_ALLOC_N(info_ret, targetDef->niothreadids) < 0) - goto cleanup; + info_ret =3D g_new0(virDomainIOThreadInfoPtr, targetDef->niothreadids); =20 for (i =3D 0; i < targetDef->niothreadids; i++) { - if (VIR_ALLOC(info_ret[i]) < 0) - goto cleanup; + info_ret[i] =3D g_new0(virDomainIOThreadInfo, 1); =20 /* IOThread ID's are taken from the iothreadids list */ info_ret[i]->iothread_id =3D targetDef->iothreadids[i]->iothread_i= d; @@ -5945,10 +5939,7 @@ static int qemuDomainGetSecurityLabelList(virDomainP= tr dom, for (i =3D 0; mgrs[i]; i++) len++; =20 - if (VIR_ALLOC_N((*seclabels), len) < 0) { - VIR_FREE(mgrs); - goto cleanup; - } + (*seclabels) =3D g_new0(virSecurityLabel, len); memset(*seclabels, 0, sizeof(**seclabels) * len); =20 /* Fill the array */ @@ -9979,8 +9970,7 @@ qemuDomainBlocksStatsGather(virQEMUDriverPtr driver, if (qemuDomainObjExitMonitor(driver, vm) < 0 || nstats < 0 || rc < 0) goto cleanup; =20 - if (VIR_ALLOC(*retstats) < 0) - goto cleanup; + *retstats =3D g_new0(qemuBlockStats, 1); =20 if (entryname) { if (!(stats =3D virHashLookup(blockstats, entryname))) { @@ -10284,10 +10274,9 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, goto endjob; } =20 - if ((VIR_ALLOC(bandwidth) < 0) || - (VIR_ALLOC(bandwidth->in) < 0) || - (VIR_ALLOC(bandwidth->out) < 0)) - goto endjob; + bandwidth =3D g_new0(virNetDevBandwidth, 1); + bandwidth->in =3D g_new0(virNetDevBandwidthRate, 1); + bandwidth->out =3D g_new0(virNetDevBandwidthRate, 1); =20 for (i =3D 0; i < nparams; i++) { virTypedParameterPtr param =3D ¶ms[i]; @@ -10321,16 +10310,14 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, VIR_FREE(bandwidth->out); =20 if (net) { - if (VIR_ALLOC(newBandwidth) < 0) - goto endjob; + newBandwidth =3D g_new0(virNetDevBandwidth, 1); =20 /* virNetDevBandwidthSet() will clear any previous value of * bandwidth parameters, so merge with old bandwidth parameters * here to prevent them from being lost. */ if (bandwidth->in || (!inboundSpecified && net->bandwidth && net->bandwidth->in)) { - if (VIR_ALLOC(newBandwidth->in) < 0) - goto endjob; + newBandwidth->in =3D g_new0(virNetDevBandwidthRate, 1); =20 memcpy(newBandwidth->in, bandwidth->in ? bandwidth->in : net->bandwidth->in, @@ -10338,8 +10325,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, } if (bandwidth->out || (!outboundSpecified && net->bandwidth && net->bandwidth->out))= { - if (VIR_ALLOC(newBandwidth->out) < 0) - goto endjob; + newBandwidth->out =3D g_new0(virNetDevBandwidthRate, 1); =20 memcpy(newBandwidth->out, bandwidth->out ? bandwidth->out : net->bandwidth->out, @@ -12463,8 +12449,7 @@ qemuConnectCPUModelBaseline(virQEMUCapsPtr qemuCaps, if (qemuProcessQMPStart(proc) < 0) return NULL; =20 - if (VIR_ALLOC(baseline) < 0) - return NULL; + baseline =3D g_new0(virCPUDef, 1); =20 if (virCPUDefCopyModel(baseline, cpus[0], false)) return NULL; @@ -17721,8 +17706,7 @@ qemuDomainGetResctrlMonData(virQEMUDriverPtr driver, if (domresmon->tag !=3D tag) continue; =20 - if (VIR_ALLOC(res) < 0) - return -1; + res =3D g_new0(virQEMUResctrlMonData, 1); =20 /* If virBitmapFormat successfully returns an vcpu string, then * res.vcpus is assigned with an memory space holding it, @@ -18036,9 +18020,8 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver, "vcpu.maximum") < 0) return -1; =20 - if (VIR_ALLOC_N(cpuinfo, virDomainDefGetVcpus(dom->def)) < 0 || - VIR_ALLOC_N(cpuwait, virDomainDefGetVcpus(dom->def)) < 0) - goto cleanup; + cpuinfo =3D g_new0(virVcpuInfo, virDomainDefGetVcpus(dom->def)); + cpuwait =3D g_new0(unsigned long long, virDomainDefGetVcpus(dom->def)); =20 if (HAVE_JOB(privflags) && virDomainObjIsActive(dom) && qemuDomainRefreshVcpuHalted(driver, dom, QEMU_ASYNC_JOB_NONE) < 0)= { @@ -18690,8 +18673,7 @@ qemuDomainGetStats(virConnectPtr conn, g_autoptr(virTypedParamList) params =3D NULL; size_t i; =20 - if (VIR_ALLOC(params) < 0) - return -1; + params =3D g_new0(virTypedParamList, 1); =20 for (i =3D 0; qemuDomainGetStatsWorkers[i].func; i++) { if (stats & qemuDomainGetStatsWorkers[i].stats) { @@ -18701,8 +18683,7 @@ qemuDomainGetStats(virConnectPtr conn, } } =20 - if (VIR_ALLOC(tmp) < 0) - return -1; + tmp =3D g_new0(virDomainStatsRecord, 1); =20 if (!(tmp->dom =3D virGetDomain(conn, dom->def->name, dom->def->uuid, dom->def->id))) @@ -18763,8 +18744,7 @@ qemuConnectGetAllDomainStats(virConnectPtr conn, return -1; } =20 - if (VIR_ALLOC_N(tmpstats, nvms + 1) < 0) - goto cleanup; + tmpstats =3D g_new0(virDomainStatsRecordPtr, nvms + 1); =20 if (qemuDomainGetStatsNeedMonitor(stats)) privflags |=3D QEMU_DOMAIN_STATS_HAVE_JOB; --=20 2.26.2 From nobody Sun May 5 10:23:18 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=1601894258; cv=none; d=zohomail.com; s=zohoarc; b=ZndhYM8i6V919gvdprWS4l7FXm3Ysda/e33fSlUYHy7pzp42nDkNTbtEDrmDLf+BlHCEzFFfwaHpcy6jf1uwYfTxx/K0T87OJxssiIaNKcgmSM+xP8l5EArR7ee/aku2uevhhjD/ct2oPFl9Sq5bUTQuPvqCIYVIMZj0aGMqeY4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601894258; 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=ffhYkJcVOUSkJ5t+RaV5JYi82uVNZrSki42ZibiPFwA=; b=ICc+zflcyuv39W1+alrVgA1hbfnGKiUtIAxPUG2vViEksj1i53D+SGlnuhMepHJisgcR9e45oC7PUAB4P7ed6fv/VPAY/nrmSzfLsXGZbHzhOHx74X6oZ/GRI2KN0t5ZZnQ7LCsjNfuSF3SeNUkgJL9EUPBpPlLdliGCMHFkRtM= 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 160189425880245.029238655556696; Mon, 5 Oct 2020 03:37:38 -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-550-Dfi4MTBtMEqOhYf5h4L0IA-1; Mon, 05 Oct 2020 06:37:35 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 356AF186841F; Mon, 5 Oct 2020 10:37:29 +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 11A5C1002C02; Mon, 5 Oct 2020 10:37:29 +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 D05A644A66; Mon, 5 Oct 2020 10:37:28 +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 095AaqEe018920 for ; Mon, 5 Oct 2020 06:36:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8554D5C1BD; Mon, 5 Oct 2020 10:36:52 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B3865C22B for ; Mon, 5 Oct 2020 10:36:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601894257; 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=ffhYkJcVOUSkJ5t+RaV5JYi82uVNZrSki42ZibiPFwA=; b=Fy2o9kHc4Y6lKTcxVI4AyiLjMKQiNmJg8eUiUOvdnvmN5lAtleon9To+poVGD2QOEBesk8 jLYP+BOBFxH9ohqlwP1es29nErw3NL6rh31Ft8clhKtw8Z4kEL831IMY7r1uTf0Q+5UP1R Gw2CDC2/ZhKyinFQBmlUIvhVibY6IPA= X-MC-Unique: Dfi4MTBtMEqOhYf5h4L0IA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 5/9] qemu: monitor: json: use g_new0 Date: Mon, 5 Oct 2020 12:36:35 +0200 Message-Id: <0afdc1879726b809c72ea838a0ccdeb189533707.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.22 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: Erik Skultety --- src/qemu/qemu_monitor_json.c | 110 ++++++++++++----------------------- 1 file changed, 36 insertions(+), 74 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index c399100dbe..26ac499fc5 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -769,8 +769,7 @@ qemuMonitorJSONGuestPanicExtractInfoHyperv(virJSONValue= Ptr data) { qemuMonitorEventPanicInfoPtr ret; =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(qemuMonitorEventPanicInfo, 1); =20 ret->type =3D QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_HYPERV; =20 @@ -799,8 +798,7 @@ qemuMonitorJSONGuestPanicExtractInfoS390(virJSONValuePt= r data) unsigned long long psw_mask, psw_addr; const char *reason =3D NULL; =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(qemuMonitorEventPanicInfo, 1); =20 ret->type =3D QEMU_MONITOR_EVENT_PANIC_INFO_TYPE_S390; =20 @@ -1900,8 +1898,7 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr data, if ((ncpus =3D virJSONValueArraySize(data)) =3D=3D 0) return -2; =20 - if (VIR_ALLOC_N(cpus, ncpus) < 0) - goto cleanup; + cpus =3D g_new0(struct qemuMonitorQueryCpusEntry, ncpus); =20 for (i =3D 0; i < ncpus; i++) { virJSONValuePtr entry =3D virJSONValueArrayGet(data, i); @@ -2438,8 +2435,7 @@ qemuMonitorJSONBlockInfoAdd(virHashTablePtr table, struct qemuDomainDiskInfo *tmp =3D NULL; int ret =3D -1; =20 - if (VIR_ALLOC(tmp) < 0) - goto cleanup; + tmp =3D g_new0(struct qemuDomainDiskInfo, 1); =20 *tmp =3D *info; tmp->nodename =3D NULL; @@ -2555,8 +2551,7 @@ qemuMonitorJSONBlockStatsCollectData(virJSONValuePtr = dev, return NULL; } =20 - if (VIR_ALLOC(bstats) < 0) - return NULL; + bstats =3D g_new0(qemuBlockStats, 1); =20 #define QEMU_MONITOR_BLOCK_STAT_GET(NAME, VAR, MANDATORY) \ if (MANDATORY || virJSONValueObjectHasKey(stats, NAME)) { \ @@ -2595,8 +2590,7 @@ qemuMonitorJSONAddOneBlockStatsInfo(qemuBlockStatsPtr= bstats, { qemuBlockStatsPtr copy =3D NULL; =20 - if (VIR_ALLOC(copy) < 0) - return -1; + copy =3D g_new0(qemuBlockStats, 1); =20 if (bstats) *copy =3D *bstats; @@ -2744,8 +2738,7 @@ qemuMonitorJSONBlockStatsUpdateCapacityData(virJSONVa= luePtr image, qemuBlockStatsPtr bstats; =20 if (!(bstats =3D virHashLookup(stats, name))) { - if (VIR_ALLOC(bstats) < 0) - return -1; + bstats =3D g_new0(qemuBlockStats, 1); =20 if (virHashAddEntry(stats, name, bstats) < 0) { VIR_FREE(bstats); @@ -4104,8 +4097,7 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValuePtr msg, goto cleanup; } nTable =3D virJSONValueArraySize(table); - if (VIR_ALLOC_N(fil->unicast.table, nTable)) - goto cleanup; + fil->unicast.table =3D g_new0(virMacAddr, nTable); for (i =3D 0; i < nTable; i++) { if (!(element =3D virJSONValueArrayGet(table, i)) || !(tmp =3D virJSONValueGetString(element))) { @@ -4146,8 +4138,7 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValuePtr msg, goto cleanup; } nTable =3D virJSONValueArraySize(table); - if (VIR_ALLOC_N(fil->multicast.table, nTable)) - goto cleanup; + fil->multicast.table =3D g_new0(virMacAddr, nTable); for (i =3D 0; i < nTable; i++) { if (!(element =3D virJSONValueArrayGet(table, i)) || !(tmp =3D virJSONValueGetString(element))) { @@ -4181,8 +4172,7 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValuePtr msg, goto cleanup; } nTable =3D virJSONValueArraySize(table); - if (VIR_ALLOC_N(fil->vlan.table, nTable)) - goto cleanup; + fil->vlan.table =3D g_new0(unsigned int, nTable); for (i =3D 0; i < nTable; i++) { if (!(element =3D virJSONValueArrayGet(table, i)) || virJSONValueGetNumberUint(element, &fil->vlan.table[i]) < 0) { @@ -4284,8 +4274,7 @@ qemuMonitorJSONExtractChardevInfo(virJSONValuePtr rep= ly, goto cleanup; } =20 - if (VIR_ALLOC(entry) < 0) - goto cleanup; + entry =3D g_new0(qemuMonitorChardevInfo, 1); =20 if (STRPREFIX(type, "pty:")) entry->ptyPath =3D g_strdup(type + strlen("pty:")); @@ -4890,8 +4879,7 @@ qemuMonitorJSONParseBlockJobInfo(virHashTablePtr bloc= kJobs, if (!rawjobname) device =3D qemuAliasDiskDriveSkipPrefix(device); =20 - if (VIR_ALLOC(info) < 0) - return -1; + info =3D g_new0(qemuMonitorBlockJobInfo, 1); =20 if (virHashAddEntry(blockJobs, device, info) < 0) { VIR_FREE(info); @@ -5576,16 +5564,14 @@ int qemuMonitorJSONGetMachines(qemuMonitorPtr mon, n =3D virJSONValueArraySize(data); =20 /* null-terminated list */ - if (VIR_ALLOC_N(infolist, n + 1) < 0) - goto cleanup; + infolist =3D g_new0(qemuMonitorMachineInfoPtr, n + 1); =20 for (i =3D 0; i < n; i++) { virJSONValuePtr child =3D virJSONValueArrayGet(data, i); const char *tmp; qemuMonitorMachineInfoPtr info; =20 - if (VIR_ALLOC(info) < 0) - goto cleanup; + info =3D g_new0(qemuMonitorMachineInfo, 1); =20 infolist[i] =3D info; =20 @@ -5745,8 +5731,7 @@ qemuMonitorJSONGetCPUDefinitions(qemuMonitorPtr mon, } =20 cpu->usable =3D VIR_DOMCAPS_CPU_USABLE_NO; - if (VIR_ALLOC_N(cpu->blockers, len + 1) < 0) - return -1; + cpu->blockers =3D g_new0(char *, len + 1); =20 for (j =3D 0; j < len; j++) { virJSONValuePtr blocker =3D virJSONValueArrayGet(blockers,= j); @@ -5899,16 +5884,13 @@ qemuMonitorJSONParseCPUModel(const char *cpu_name, qemuMonitorCPUModelInfoPtr machine_model =3D NULL; int ret =3D -1; =20 - if (VIR_ALLOC(machine_model) < 0) - goto cleanup; - + machine_model =3D g_new0(qemuMonitorCPUModelInfo, 1); machine_model->name =3D g_strdup(cpu_name); =20 if (cpu_props) { size_t nprops =3D virJSONValueObjectKeysNumber(cpu_props); =20 - if (VIR_ALLOC_N(machine_model->props, nprops) < 0) - goto cleanup; + machine_model->props =3D g_new0(qemuMonitorCPUProperty, nprops); =20 if (virJSONValueObjectForeachKeyValue(cpu_props, qemuMonitorJSONParseCPUModel= Property, @@ -6113,8 +6095,7 @@ int qemuMonitorJSONGetCommands(qemuMonitorPtr mon, n =3D virJSONValueArraySize(data); =20 /* null-terminated list */ - if (VIR_ALLOC_N(commandlist, n + 1) < 0) - goto cleanup; + commandlist =3D g_new0(char *, n + 1); =20 for (i =3D 0; i < n; i++) { virJSONValuePtr child =3D virJSONValueArrayGet(data, i); @@ -6173,8 +6154,7 @@ int qemuMonitorJSONGetEvents(qemuMonitorPtr mon, n =3D virJSONValueArraySize(data); =20 /* null-terminated list */ - if (VIR_ALLOC_N(eventlist, n + 1) < 0) - goto cleanup; + eventlist =3D g_new0(char *, n + 1); =20 for (i =3D 0; i < n; i++) { virJSONValuePtr child =3D virJSONValueArrayGet(data, i); @@ -6288,8 +6268,7 @@ qemuMonitorJSONGetCommandLineOptionParameters(qemuMon= itorPtr mon, n =3D virJSONValueArraySize(data); =20 /* null-terminated list */ - if (VIR_ALLOC_N(paramlist, n + 1) < 0) - goto cleanup; + paramlist =3D g_new0(char *, n + 1); =20 for (i =3D 0; i < n; i++) { virJSONValuePtr child =3D virJSONValueArrayGet(data, i); @@ -6392,8 +6371,7 @@ int qemuMonitorJSONGetObjectTypes(qemuMonitorPtr mon, n =3D virJSONValueArraySize(data); =20 /* null-terminated list */ - if (VIR_ALLOC_N(typelist, n + 1) < 0) - goto cleanup; + typelist =3D g_new0(char *, n + 1); =20 for (i =3D 0; i < n; i++) { virJSONValuePtr child =3D virJSONValueArrayGet(data, i); @@ -6449,16 +6427,14 @@ int qemuMonitorJSONGetObjectListPaths(qemuMonitorPt= r mon, n =3D virJSONValueArraySize(data); =20 /* null-terminated list */ - if (VIR_ALLOC_N(pathlist, n + 1) < 0) - goto cleanup; + pathlist =3D g_new0(qemuMonitorJSONListPathPtr, n + 1); =20 for (i =3D 0; i < n; i++) { virJSONValuePtr child =3D virJSONValueArrayGet(data, i); const char *tmp; qemuMonitorJSONListPathPtr info; =20 - if (VIR_ALLOC(info) < 0) - goto cleanup; + info =3D g_new0(qemuMonitorJSONListPath, 1); =20 pathlist[i] =3D info; =20 @@ -6612,8 +6588,7 @@ qemuMonitorJSONGetStringListProperty(qemuMonitorPtr m= on, data =3D virJSONValueObjectGetArray(reply, "return"); n =3D virJSONValueArraySize(data); =20 - if (VIR_ALLOC_N(list, n + 1) < 0) - return -1; + list =3D g_new0(char *, n + 1); =20 for (i =3D 0; i < n; i++) { virJSONValuePtr item =3D virJSONValueArrayGet(data, i); @@ -6718,8 +6693,7 @@ qemuMonitorJSONParsePropsList(virJSONValuePtr cmd, n =3D virJSONValueArraySize(data); =20 /* null-terminated list */ - if (VIR_ALLOC_N(proplist, n + 1) < 0) - goto cleanup; + proplist =3D g_new0(char *, n + 1); =20 for (i =3D 0; i < n; i++) { virJSONValuePtr child =3D virJSONValueArrayGet(data, i); @@ -6900,8 +6874,7 @@ qemuMonitorJSONGetMigrationCapabilities(qemuMonitorPt= r mon, caps =3D virJSONValueObjectGetArray(reply, "return"); n =3D virJSONValueArraySize(caps); =20 - if (VIR_ALLOC_N(list, n + 1) < 0) - goto cleanup; + list =3D g_new0(char *, n + 1); =20 for (i =3D 0; i < n; i++) { virJSONValuePtr cap =3D virJSONValueArrayGet(caps, i); @@ -7019,8 +6992,7 @@ qemuMonitorJSONGetGICCapabilities(qemuMonitorPtr mon, goto cleanup; } =20 - if (VIR_ALLOC_N(list, n) < 0) - goto cleanup; + list =3D g_new0(virGICCapability, n); =20 for (i =3D 0; i < n; i++) { virJSONValuePtr cap =3D virJSONValueArrayGet(caps, i); @@ -7149,8 +7121,7 @@ qemuMonitorJSONGetSEVCapabilities(qemuMonitorPtr mon, goto cleanup; } =20 - if (VIR_ALLOC(capability) < 0) - goto cleanup; + capability =3D g_new0(virSEVCapability, 1); =20 capability->pdh =3D g_strdup(pdh); =20 @@ -7345,8 +7316,7 @@ qemuMonitorJSONGetStringArray(qemuMonitorPtr mon, con= st char *qmpCmd, n =3D virJSONValueArraySize(data); =20 /* null-terminated list */ - if (VIR_ALLOC_N(list, n + 1) < 0) - goto cleanup; + list =3D g_new0(char *, n + 1); =20 for (i =3D 0; i < n; i++) { virJSONValuePtr child =3D virJSONValueArrayGet(data, i); @@ -7641,8 +7611,7 @@ qemuMonitorJSONGetDeviceAliases(qemuMonitorPtr mon, if (n < 0) return -1; =20 - if (VIR_ALLOC_N(*aliases, n + 1) < 0) - goto cleanup; + *aliases =3D g_new0(char *, n + 1); =20 alias =3D *aliases; for (i =3D 0; i < n; i++) { @@ -7655,7 +7624,6 @@ qemuMonitorJSONGetDeviceAliases(qemuMonitorPtr mon, =20 ret =3D 0; =20 - cleanup: for (i =3D 0; i < n; i++) qemuMonitorJSONListPathFree(paths[i]); VIR_FREE(paths); @@ -8066,8 +8034,7 @@ qemuMonitorJSONGetIOThreads(qemuMonitorPtr mon, n =3D virJSONValueArraySize(data); =20 /* null-terminated list */ - if (VIR_ALLOC_N(infolist, n + 1) < 0) - goto cleanup; + infolist =3D g_new0(qemuMonitorIOThreadInfoPtr, n + 1); =20 for (i =3D 0; i < n; i++) { virJSONValuePtr child =3D virJSONValueArrayGet(data, i); @@ -8083,8 +8050,7 @@ qemuMonitorJSONGetIOThreads(qemuMonitorPtr mon, if (!STRPREFIX(tmp, "iothread")) continue; =20 - if (VIR_ALLOC(info) < 0) - goto cleanup; + info =3D g_new0(qemuMonitorIOThreadInfo, 1); =20 infolist[i] =3D info; =20 @@ -8225,8 +8191,7 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitorPtr mon, goto cleanup; } =20 - if (VIR_ALLOC(meminfo) < 0) - goto cleanup; + meminfo =3D g_new0(qemuMonitorMemoryDeviceInfo, 1); =20 if (virJSONValueObjectGetNumberUlong(dimminfo, "addr", &meminfo->address) < 0) { @@ -8672,8 +8637,7 @@ qemuMonitorJSONGetHotpluggableCPUs(qemuMonitorPtr mon, data =3D virJSONValueObjectGet(reply, "return"); ninfo =3D virJSONValueArraySize(data); =20 - if (VIR_ALLOC_N(info, ninfo) < 0) - goto cleanup; + info =3D g_new0(struct qemuMonitorQueryHotpluggableCpusEntry, ninfo); =20 for (i =3D 0; i < ninfo; i++) { vcpu =3D virJSONValueArrayGet(data, i); @@ -9073,8 +9037,7 @@ qemuMonitorJSONExtractPRManagerInfo(virJSONValuePtr r= eply, if (!(alias =3D virJSONValueObjectGetString(prManager, "id"))) goto malformed; =20 - if (VIR_ALLOC(entry) < 0) - goto cleanup; + entry =3D g_new0(qemuMonitorPRManagerInfo, 1); =20 if (virJSONValueObjectGetBoolean(prManager, "connected", @@ -9345,8 +9308,7 @@ qemuMonitorJSONGetJobInfoOne(virJSONValuePtr data) int tmp; g_autoptr(qemuMonitorJobInfo) job =3D NULL; =20 - if (VIR_ALLOC(job) < 0) - return NULL; + job =3D g_new0(qemuMonitorJobInfo, 1); =20 if ((tmp =3D qemuMonitorJobTypeFromString(type)) < 0) tmp =3D QEMU_MONITOR_JOB_TYPE_UNKNOWN; --=20 2.26.2 From nobody Sun May 5 10:23:18 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=1601894349; cv=none; d=zohomail.com; s=zohoarc; b=FP3VuXdCiRaVLPf0YBZ/CsBwGspJuuSLBN8imxnLIi/9dbOx+0G8F0gUyaHMn8PZXrFR6Nx+TyKEvc2oU7TfiiSwSnWPo7BF4Pk3uNQJ4xw84epZCbYQR620WX5XzXyiIYmwz8a/LbV42BG2/0TX7T6hdiVcSFyzkM8pj9ICs24= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601894349; 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=8yw7falJf3u/dJhzrCZ/3mRZMCZz/AjlQ/zAfIkPB4Y=; b=Jww9qQKNyN8Cv7oX6cPbvmPl+WcpdY60DJICyIbs1BNErKv0hzBmbPTRhQAyaOFD6MeielgAUDuqOqJGj6Pv6p23vQ/ChMQ4v7YTAsoNsk18yPphAldJTXYHmou2q4b0jxTnUz4yTeZ0UrDjZMDVEehBVRD2DeOrv9JNs2DexQE= 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 1601894349858923.416688862039; Mon, 5 Oct 2020 03:39:09 -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-3-o1mAYNEdOnyomNzlUaKqlQ-1; Mon, 05 Oct 2020 06:38:13 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D7036801AF0; Mon, 5 Oct 2020 10:38:06 +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 B57465D9E4; Mon, 5 Oct 2020 10:38:06 +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 84BBE44A5F; Mon, 5 Oct 2020 10:38:06 +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 095AarrY018925 for ; Mon, 5 Oct 2020 06:36:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 546335C22B; Mon, 5 Oct 2020 10:36:53 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id D03815C1BD for ; Mon, 5 Oct 2020 10:36:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601894348; 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=8yw7falJf3u/dJhzrCZ/3mRZMCZz/AjlQ/zAfIkPB4Y=; b=PGBETu54AMksiIVYPG3xxEe9FNCSTcnuSyocTuOGV/LBPdnj9GQaoi1MHLDwRhBGZxOL+P NO5RwUn1KSP7vV5+0NBTL2nbo6ycnEXYmCL+lhxFcf5AN/sL7fUe8IrWuY7u3OyBLgheb7 FZCV3qz2CIerOmfDBHZGCCaGP8nOjuY= X-MC-Unique: o1mAYNEdOnyomNzlUaKqlQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 6/9] qemu: process: use g_new0 Date: Mon, 5 Oct 2020 12:36:36 +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.14 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: Erik Skultety --- src/qemu/qemu_process.c | 56 +++++++++++++---------------------------- 1 file changed, 18 insertions(+), 38 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 93cbb37986..94b44f1c5c 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -302,8 +302,7 @@ qemuProcessHandleMonitorEOF(qemuMonitorPtr mon, goto cleanup; } =20 - if (VIR_ALLOC(processEvent) < 0) - goto cleanup; + processEvent =3D g_new0(struct qemuProcessEvent, 1); =20 processEvent->eventType =3D QEMU_PROCESS_EVENT_MONITOR_EOF; processEvent->vm =3D virObjectRef(vm); @@ -832,8 +831,7 @@ qemuProcessHandleWatchdog(qemuMonitorPtr mon G_GNUC_UNU= SED, =20 if (vm->def->watchdog->action =3D=3D VIR_DOMAIN_WATCHDOG_ACTION_DUMP) { struct qemuProcessEvent *processEvent; - if (VIR_ALLOC(processEvent) < 0) - ; + processEvent =3D g_new0(qemuProcessEvent, 1); =20 processEvent->eventType =3D QEMU_PROCESS_EVENT_WATCHDOG; processEvent->action =3D VIR_DOMAIN_WATCHDOG_ACTION_DUMP; @@ -965,8 +963,7 @@ qemuProcessHandleBlockJob(qemuMonitorPtr mon G_GNUC_UNU= SED, virDomainObjBroadcast(vm); } else { /* there is no waiting SYNC API, dispatch the update to a thread */ - if (VIR_ALLOC(processEvent) < 0) - goto cleanup; + processEvent =3D g_new0(qemuProcessEvent, 1); =20 processEvent->eventType =3D QEMU_PROCESS_EVENT_BLOCK_JOB; data =3D g_strdup(diskAlias); @@ -1030,8 +1027,7 @@ qemuProcessHandleJobStatusChange(qemuMonitorPtr mon G= _GNUC_UNUSED, virDomainObjBroadcast(vm); } else { VIR_DEBUG("job '%s' handled by event thread", jobname); - if (VIR_ALLOC(processEvent) < 0) - goto cleanup; + processEvent =3D g_new0(qemuProcessEvent, 1); =20 processEvent->eventType =3D QEMU_PROCESS_EVENT_JOB_STATUS_CHANGE; processEvent->vm =3D virObjectRef(vm); @@ -1074,20 +1070,17 @@ qemuProcessHandleGraphics(qemuMonitorPtr mon G_GNUC= _UNUSED, virDomainEventGraphicsSubjectPtr subject =3D NULL; size_t i; =20 - if (VIR_ALLOC(localAddr) < 0) - goto error; + localAddr =3D g_new0(virDomainEventGraphicsAddress, 1); localAddr->family =3D localFamily; localAddr->service =3D g_strdup(localService); localAddr->node =3D g_strdup(localNode); =20 - if (VIR_ALLOC(remoteAddr) < 0) - goto error; + remoteAddr =3D g_new0(virDomainEventGraphicsAddress, 1); remoteAddr->family =3D remoteFamily; remoteAddr->service =3D g_strdup(remoteService); remoteAddr->node =3D g_strdup(remoteNode); =20 - if (VIR_ALLOC(subject) < 0) - goto error; + subject =3D g_new0(virDomainEventGraphicsSubject, 1); if (x509dname) { if (VIR_REALLOC_N(subject->identities, subject->nidentity+1) < 0) goto error; @@ -1329,8 +1322,7 @@ qemuProcessHandleGuestPanic(qemuMonitorPtr mon G_GNUC= _UNUSED, struct qemuProcessEvent *processEvent; =20 virObjectLock(vm); - if (VIR_ALLOC(processEvent) < 0) - goto cleanup; + processEvent =3D g_new0(struct qemuProcessEvent, 1); =20 processEvent->eventType =3D QEMU_PROCESS_EVENT_GUESTPANIC; processEvent->action =3D vm->def->onCrash; @@ -1345,7 +1337,6 @@ qemuProcessHandleGuestPanic(qemuMonitorPtr mon G_GNUC= _UNUSED, qemuProcessEventFree(processEvent); } =20 - cleanup: virObjectUnlock(vm); =20 return 0; @@ -1371,8 +1362,7 @@ qemuProcessHandleDeviceDeleted(qemuMonitorPtr mon G_G= NUC_UNUSED, QEMU_DOMAIN_UNPLUGGING_DEVICE_STATUS= _OK)) goto cleanup; =20 - if (VIR_ALLOC(processEvent) < 0) - goto error; + processEvent =3D g_new0(struct qemuProcessEvent, 1); =20 processEvent->eventType =3D QEMU_PROCESS_EVENT_DEVICE_DELETED; data =3D g_strdup(devAlias); @@ -1552,8 +1542,7 @@ qemuProcessHandleNicRxFilterChanged(qemuMonitorPtr mo= n G_GNUC_UNUSED, VIR_DEBUG("Device %s RX Filter changed in domain %p %s", devAlias, vm, vm->def->name); =20 - if (VIR_ALLOC(processEvent) < 0) - goto error; + processEvent =3D g_new0(struct qemuProcessEvent, 1); =20 processEvent->eventType =3D QEMU_PROCESS_EVENT_NIC_RX_FILTER_CHANGED; data =3D g_strdup(devAlias); @@ -1590,8 +1579,7 @@ qemuProcessHandleSerialChanged(qemuMonitorPtr mon G_G= NUC_UNUSED, VIR_DEBUG("Serial port %s state changed to '%d' in domain %p %s", devAlias, connected, vm, vm->def->name); =20 - if (VIR_ALLOC(processEvent) < 0) - goto error; + processEvent =3D g_new0(struct qemuProcessEvent, 1); =20 processEvent->eventType =3D QEMU_PROCESS_EVENT_SERIAL_CHANGED; data =3D g_strdup(devAlias); @@ -1800,8 +1788,7 @@ qemuProcessHandlePRManagerStatusChanged(qemuMonitorPt= r mon G_GNUC_UNUSED, priv =3D vm->privateData; priv->prDaemonRunning =3D false; =20 - if (VIR_ALLOC(processEvent) < 0) - goto cleanup; + processEvent =3D g_new0(struct qemuProcessEvent, 1); =20 processEvent->eventType =3D QEMU_PROCESS_EVENT_PR_DISCONNECT; processEvent->vm =3D virObjectRef(vm); @@ -1838,8 +1825,7 @@ qemuProcessHandleRdmaGidStatusChanged(qemuMonitorPtr = mon G_GNUC_UNUSED, VIR_DEBUG("netdev=3D%s,gid_status=3D%d,subnet_prefix=3D0x%llx,interfac= e_id=3D0x%llx", netdev, gid_status, subnet_prefix, interface_id); =20 - if (VIR_ALLOC(info) < 0) - goto cleanup; + info =3D g_new0(qemuMonitorRdmaGidStatus, 1); =20 info->netdev =3D g_strdup(netdev); =20 @@ -1847,8 +1833,7 @@ qemuProcessHandleRdmaGidStatusChanged(qemuMonitorPtr = mon G_GNUC_UNUSED, info->subnet_prefix =3D subnet_prefix; info->interface_id =3D interface_id; =20 - if (VIR_ALLOC(processEvent) < 0) - goto cleanup; + processEvent =3D g_new0(struct qemuProcessEvent, 1); =20 processEvent->eventType =3D QEMU_PROCESS_EVENT_RDMA_GID_STATUS_CHANGED; processEvent->vm =3D virObjectRef(vm); @@ -1877,8 +1862,7 @@ qemuProcessHandleGuestCrashloaded(qemuMonitorPtr mon = G_GNUC_UNUSED, struct qemuProcessEvent *processEvent; =20 virObjectLock(vm); - if (VIR_ALLOC(processEvent) < 0) - goto cleanup; + processEvent =3D g_new0(struct qemuProcessEvent, 1); =20 processEvent->eventType =3D QEMU_PROCESS_EVENT_GUEST_CRASHLOADED; processEvent->vm =3D virObjectRef(vm); @@ -1888,7 +1872,6 @@ qemuProcessHandleGuestCrashloaded(qemuMonitorPtr mon = G_GNUC_UNUSED, qemuProcessEventFree(processEvent); } =20 - cleanup: virObjectUnlock(vm); =20 return 0; @@ -4589,8 +4572,7 @@ qemuProcessIncomingDefNew(virQEMUCapsPtr qemuCaps, if (qemuMigrationDstCheckProtocol(qemuCaps, migrateFrom) < 0) return NULL; =20 - if (VIR_ALLOC(inc) < 0) - return NULL; + inc =3D g_new0(qemuProcessIncomingDef, 1); =20 inc->address =3D g_strdup(listenAddress); =20 @@ -8431,8 +8413,7 @@ qemuProcessReconnectHelper(virDomainObjPtr obj, if (!obj->pid) return 0; =20 - if (VIR_ALLOC(data) < 0) - return -1; + data =3D g_new0(struct qemuProcessReconnectData, 1); =20 memcpy(data, src, sizeof(*data)); data->obj =3D obj; @@ -8588,8 +8569,7 @@ qemuProcessQMPNew(const char *binary, VIR_DEBUG("exec=3D%s, libDir=3D%s, runUid=3D%u, runGid=3D%u, forceTCG= =3D%d", binary, libDir, runUid, runGid, forceTCG); =20 - if (VIR_ALLOC(proc) < 0) - return NULL; + proc =3D g_new0(qemuProcessQMP, 1); =20 proc->binary =3D g_strdup(binary); proc->libDir =3D g_strdup(libDir); --=20 2.26.2 From nobody Sun May 5 10:23:18 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=1601894299; cv=none; d=zohomail.com; s=zohoarc; b=gA4fUi+e/SdlXeT6SYP5cLrGiYBPyjHipt/PoZ8hloaCMzGDkKggcVCe3UDU5JPomtdiuEIjCGfp7LSsJU9FvgfJSs4tN7dne2ShuwKNztTuLrQfkCJ3hFgJEUr7Ps1wk3fcxXxjx88siDAufbi8qgtFZK/GbNhtSCkAQ47wcgg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601894299; 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=gU1Eryo6GXxkvwM8QJ5nElbk1mFLjWSJuUfGN07o5X4=; b=EStgCwA+EZGSCbUwH11J24FRLIe75QH59nccg00U3GICU1BZjVacyT5W7Xz1pnj2UH1GdKWqg/AAb2skOIN3gc0QT3I5rSns1WwyW3zN+mYlvDHuwCeQDsasHSBwrcez47VNHlWohIF4LrVmW18uviRJqZVWr4C3Hl2ybyM+rQI= 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 1601894299207225.60672880906475; Mon, 5 Oct 2020 03:38:19 -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-221-8oC6AnlJMl-iGeM6pOD_Tg-1; Mon, 05 Oct 2020 06:38:15 -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 8BF85800475; Mon, 5 Oct 2020 10:38:09 +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 41F447E731; Mon, 5 Oct 2020 10:38:09 +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 101BE44A6B; Mon, 5 Oct 2020 10:38:09 +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 095AaskY018934 for ; Mon, 5 Oct 2020 06:36:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 25A875C22B; 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 A144E5C1BD for ; Mon, 5 Oct 2020 10:36:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601894297; 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=gU1Eryo6GXxkvwM8QJ5nElbk1mFLjWSJuUfGN07o5X4=; b=YkzT0l3c1+JOo2vL8E0Tt86BH9M6DJy7AysgkVCJnFXagQ6UGrojgGE7Vz9BRORMKwKdE0 ZOr58o6593n9ztJtCMnwFFburYlEPMXL5TnvQTFPca58vh1wbqd8Y6zD/5/ZB6meaSeLGJ PzsCd5gLbyZ+yjzMW0knM6L8a8a/3kI= X-MC-Unique: 8oC6AnlJMl-iGeM6pOD_Tg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 7/9] qemu: command: use g_new0 Date: Mon, 5 Oct 2020 12:36:37 +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: Erik Skultety --- src/qemu/qemu_command.c | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index e9ba81d82f..476cf6972e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7428,8 +7428,7 @@ qemuBuildNumaCommandLine(virQEMUDriverConfigPtr cfg, hmat =3D true; } =20 - if (VIR_ALLOC_N(nodeBackends, ncells) < 0) - goto cleanup; + nodeBackends =3D g_new0(virBuffer, ncells); =20 /* using of -numa memdev=3D cannot be combined with -numa mem=3D, thus= we * need to check which approach to use */ @@ -8119,9 +8118,8 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, if (!tapfdSize) tapfdSize =3D 1; =20 - if (VIR_ALLOC_N(tapfd, tapfdSize) < 0 || - VIR_ALLOC_N(tapfdName, tapfdSize) < 0) - goto cleanup; + tapfd =3D g_new0(int, tapfdSize); + tapfdName =3D g_new0(char *, tapfdSize); =20 memset(tapfd, -1, tapfdSize * sizeof(tapfd[0])); =20 @@ -8135,9 +8133,8 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, if (!tapfdSize) tapfdSize =3D 1; =20 - if (VIR_ALLOC_N(tapfd, tapfdSize) < 0 || - VIR_ALLOC_N(tapfdName, tapfdSize) < 0) - goto cleanup; + tapfd =3D g_new0(int, tapfdSize); + tapfdName =3D g_new0(char *, tapfdSize); =20 memset(tapfd, -1, tapfdSize * sizeof(tapfd[0])); =20 @@ -8151,9 +8148,8 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, if (!tapfdSize) tapfdSize =3D 1; =20 - if (VIR_ALLOC_N(tapfd, tapfdSize) < 0 || - VIR_ALLOC_N(tapfdName, tapfdSize) < 0) - goto cleanup; + tapfd =3D g_new0(int, tapfdSize); + tapfdName =3D g_new0(char *, tapfdSize); =20 memset(tapfd, -1, tapfdSize * sizeof(tapfd[0])); =20 @@ -8268,9 +8264,8 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, if (!vhostfdSize) vhostfdSize =3D 1; =20 - if (VIR_ALLOC_N(vhostfd, vhostfdSize) < 0 || - VIR_ALLOC_N(vhostfdName, vhostfdSize)) - goto cleanup; + vhostfd =3D g_new0(int, vhostfdSize); + vhostfdName =3D g_new0(char *, vhostfdSize); =20 memset(vhostfd, -1, vhostfdSize * sizeof(vhostfd[0])); =20 @@ -10465,8 +10460,7 @@ qemuBuildStorageSourceAttachPrepareDrive(virDomainD= iskDefPtr disk, { g_autoptr(qemuBlockStorageSourceAttachData) data =3D NULL; =20 - if (VIR_ALLOC(data) < 0) - return NULL; + data =3D g_new0(qemuBlockStorageSourceAttachData, 1); =20 if (!(data->driveCmd =3D qemuBuildDriveStr(disk, qemuCaps)) || !(data->driveAlias =3D qemuAliasDiskDriveFromDisk(disk))) @@ -10543,8 +10537,7 @@ qemuBuildStorageSourceChainAttachPrepareDrive(virDo= mainDiskDefPtr disk, g_autoptr(qemuBlockStorageSourceAttachData) elem =3D NULL; g_autoptr(qemuBlockStorageSourceChainData) data =3D NULL; =20 - if (VIR_ALLOC(data) < 0) - return NULL; + data =3D g_new0(qemuBlockStorageSourceChainData, 1); =20 if (!(elem =3D qemuBuildStorageSourceAttachPrepareDrive(disk, qemuCaps= ))) return NULL; @@ -10595,8 +10588,7 @@ qemuBuildStorageSourceChainAttachPrepareBlockdev(vi= rStorageSourcePtr top, g_autoptr(qemuBlockStorageSourceChainData) data =3D NULL; virStorageSourcePtr n; =20 - if (VIR_ALLOC(data) < 0) - return NULL; + data =3D g_new0(qemuBlockStorageSourceChainData, 1); =20 for (n =3D top; virStorageSourceIsBacking(n); n =3D n->backingStore) { if (qemuBuildStorageSourceChainAttachPrepareBlockdevOne(data, n, @@ -10625,8 +10617,7 @@ qemuBuildStorageSourceChainAttachPrepareBlockdevTop= (virStorageSourcePtr top, { g_autoptr(qemuBlockStorageSourceChainData) data =3D NULL; =20 - if (VIR_ALLOC(data) < 0) - return NULL; + data =3D g_new0(qemuBlockStorageSourceChainData, 1); =20 if (qemuBuildStorageSourceChainAttachPrepareBlockdevOne(data, top, bac= kingStore, qemuCaps) < 0) --=20 2.26.2 From nobody Sun May 5 10:23:18 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=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 Reviewed-by: Erik Skultety --- 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 From nobody Sun May 5 10:23:18 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=1601894261; cv=none; d=zohomail.com; s=zohoarc; b=VT2T51wySAbwJKYWH4dCQlqD95cjgVVIbIHfado3Tg8fEOJa4CIiBSeBVxdQa1uuwOsbuxU33lvgfnbiGxom85lrig+z0mvKm4HDLqxM0ntr5TkUBbqAfb9ycsdVfyQGiBtAwL2AsvE1qQufs0DcfDlM8xv57z2PJ9Ce16i45t0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601894261; 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=Vc24kr/PC9jBGbN2fFOgOsT2Av0Dl8kni1hsi+PNyeA=; b=RgL+eZr8w4OXLsj8PqkM2iU7uiaGo5N4FumWxc1VUtw5VZGf8DvP9zCGmPDBo/s6PI261KUiVqIGCLMHNk1dDciXJYIx4bOTgY/4RV8tPWrOPRvKrgPfczlyD+kQZjSt7Pu4WrxWM3gTmkCQuAnljVLhVwN+Ov9omVd1WZuV5z0= 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 1601894261434695.4474420636219; Mon, 5 Oct 2020 03:37:41 -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-564-xo7B-itQMRSTXQAxrt9E4g-1; Mon, 05 Oct 2020 06:37:37 -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 E1574186840B; Mon, 5 Oct 2020 10:37:31 +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 B8C87271A3; Mon, 5 Oct 2020 10:37:31 +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 883FC44A69; Mon, 5 Oct 2020 10:37:31 +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 095AatL2018955 for ; Mon, 5 Oct 2020 06:36:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id E2EA95C22B; Mon, 5 Oct 2020 10:36:55 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 447F55C1BD for ; Mon, 5 Oct 2020 10:36:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601894260; 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=Vc24kr/PC9jBGbN2fFOgOsT2Av0Dl8kni1hsi+PNyeA=; b=cek9vWXKu6sMyQAGS5HAVjHgOSvyJnBBFMH8PRRD53tqa6sGOtZmhgpE/TO2xscCSmWGlZ dssK831Iy66CIEzI5fGVDJ/UsZpPpBO2F1DMquVZWlBOcW+0W25hnO1R8QXAemOFJKf6VC eGZVVYwnrmc2qoeOZt6YucmNa90C4Mg= X-MC-Unique: xo7B-itQMRSTXQAxrt9E4g-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 9/9] qemu: use g_new0 Date: Mon, 5 Oct 2020 12:36:39 +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: Erik Skultety --- src/qemu/qemu_agent.c | 6 ++---- src/qemu/qemu_block.c | 15 +++++---------- src/qemu/qemu_cgroup.c | 6 ++---- src/qemu/qemu_conf.c | 20 ++++++++------------ src/qemu/qemu_domain_address.c | 3 +-- src/qemu/qemu_hotplug.c | 29 +++++++++++------------------ src/qemu/qemu_migration.c | 6 ++---- src/qemu/qemu_monitor.c | 13 +++---------- src/qemu/qemu_namespace.c | 3 +-- src/qemu/qemu_saveimage.c | 3 +-- src/qemu/qemu_vhost_user.c | 17 +++++++---------- 11 files changed, 43 insertions(+), 78 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 1239aceb46..09116e749c 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -1452,8 +1452,7 @@ qemuAgentGetVCPUs(qemuAgentPtr agent, =20 ndata =3D virJSONValueArraySize(data); =20 - if (VIR_ALLOC_N(*info, ndata) < 0) - goto cleanup; + *info =3D g_new0(qemuAgentCPUInfo, ndata); =20 for (i =3D 0; i < ndata; i++) { virJSONValuePtr entry =3D virJSONValueArrayGet(data, i); @@ -2148,8 +2147,7 @@ qemuAgentGetInterfaces(qemuAgentPtr agent, if (VIR_EXPAND_N(ifaces_ret, ifaces_count, 1) < 0) goto error; =20 - if (VIR_ALLOC(ifaces_ret[ifaces_count - 1]) < 0) - goto error; + ifaces_ret[ifaces_count - 1] =3D g_new0(virDomainInterface, 1); =20 if (virHashAddEntry(ifaces_store, ifname_s, ifaces_ret[ifaces_count - 1]) < 0) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 487b0a72e7..6bea21347a 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -169,8 +169,7 @@ qemuBlockNodeNameGetBackingChainBacking(virJSONValuePtr= next, } } =20 - if (VIR_ALLOC(data) < 0) - return -1; + data =3D g_new0(qemuBlockNodeNameBackingChainData, 1); =20 data->nodeformat =3D g_strdup(nodename); data->nodestorage =3D g_strdup(parentnodename); @@ -415,8 +414,7 @@ qemuBlockStorageSourceGetURI(virStorageSourcePtr src) return NULL; } =20 - if (VIR_ALLOC(uri) < 0) - return NULL; + uri =3D g_new0(virURI, 1); =20 if (src->hosts->transport =3D=3D VIR_STORAGE_NET_HOST_TRANS_TCP) { uri->port =3D src->hosts->port; @@ -1595,8 +1593,7 @@ qemuBlockStorageSourceAttachPrepareBlockdev(virStorag= eSourcePtr src, if (autoreadonly) backendpropsflags |=3D QEMU_BLOCK_STORAGE_SOURCE_BACKEND_PROPS_AUT= O_READONLY; =20 - if (VIR_ALLOC(data) < 0) - return NULL; + data =3D g_new0(qemuBlockStorageSourceAttachData, 1); =20 if (!(data->formatProps =3D qemuBlockStorageSourceGetBlockdevProps(src, backi= ngStore)) || @@ -1886,8 +1883,7 @@ qemuBlockStorageSourceChainDetachPrepareBlockdev(virS= torageSourcePtr src) g_autoptr(qemuBlockStorageSourceChainData) data =3D NULL; virStorageSourcePtr n; =20 - if (VIR_ALLOC(data) < 0) - return NULL; + data =3D g_new0(qemuBlockStorageSourceChainData, 1); =20 for (n =3D src; virStorageSourceIsBacking(n); n =3D n->backingStore) { if (!(backend =3D qemuBlockStorageSourceDetachPrepare(n, NULL))) @@ -1916,8 +1912,7 @@ qemuBlockStorageSourceChainDetachPrepareDrive(virStor= ageSourcePtr src, g_autoptr(qemuBlockStorageSourceAttachData) backend =3D NULL; g_autoptr(qemuBlockStorageSourceChainData) data =3D NULL; =20 - if (VIR_ALLOC(data) < 0) - return NULL; + data =3D g_new0(qemuBlockStorageSourceChainData, 1); =20 if (!(backend =3D qemuBlockStorageSourceDetachPrepare(src, driveAlias)= )) return NULL; diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index e88da02341..b671991ad6 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -926,8 +926,7 @@ qemuInitCgroup(virDomainObjPtr vm, if (!vm->def->resource) { virDomainResourceDefPtr res; =20 - if (VIR_ALLOC(res) < 0) - return -1; + res =3D g_new0(virDomainResourceDef, 1); =20 res->partition =3D g_strdup("/machine"); =20 @@ -1252,8 +1251,7 @@ qemuCgroupEmulatorAllNodesAllow(virCgroupPtr cgroup, if (!(all_nodes_str =3D virBitmapFormat(all_nodes))) goto cleanup; =20 - if (VIR_ALLOC(data) < 0) - goto cleanup; + data =3D g_new0(qemuCgroupEmulatorAllNodesData, 1); =20 if (virCgroupNewThread(cgroup, VIR_CGROUP_THREAD_EMULATOR, 0, false, &data->emulatorCgroup) < 0) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index f4ed1fa061..6d16c11017 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -641,9 +641,8 @@ virQEMUDriverConfigLoadProcessEntry(virQEMUDriverConfig= Ptr cfg, VIR_FREE(cfg->hugetlbfs); =20 cfg->nhugetlbfs =3D virStringListLength((const char *const *)huget= lbfs); - if (hugetlbfs[0] && - VIR_ALLOC_N(cfg->hugetlbfs, cfg->nhugetlbfs) < 0) - return -1; + if (hugetlbfs[0]) + cfg->hugetlbfs =3D g_new0(virHugeTLBFS, cfg->nhugetlbfs); =20 for (i =3D 0; hugetlbfs[i] !=3D NULL; i++) { if (virQEMUDriverConfigHugeTLBFSInit(&cfg->hugetlbfs[i], @@ -840,12 +839,11 @@ virQEMUDriverConfigLoadNVRAMEntry(virQEMUDriverConfig= Ptr cfg, } =20 cfg->nfirmwares =3D virStringListLength((const char *const *)nvram= ); - if (nvram[0] && VIR_ALLOC_N(cfg->firmwares, cfg->nfirmwares) < 0) - return -1; + if (nvram[0]) + cfg->firmwares =3D g_new0(virFirmwarePtr, cfg->nfirmwares); =20 for (i =3D 0; nvram[i] !=3D NULL; i++) { - if (VIR_ALLOC(cfg->firmwares[i]) < 0) - return -1; + cfg->firmwares[i] =3D g_new0(virFirmware, 1); if (virFirmwareParse(nvram[i], cfg->firmwares[i]) < 0) return -1; } @@ -1349,8 +1347,7 @@ virCapsPtr virQEMUDriverCreateCapabilities(virQEMUDri= verPtr driver) ; caps->host.nsecModels =3D i; =20 - if (VIR_ALLOC_N(caps->host.secModels, caps->host.nsecModels) < 0) - return NULL; + caps->host.secModels =3D g_new0(virCapsHostSecModel, caps->host.nsecMo= dels); =20 for (i =3D 0; sec_managers[i]; i++) { virCapsHostSecModelPtr sm =3D &caps->host.secModels[i]; @@ -1616,9 +1613,8 @@ qemuSharedDeviceEntryInsert(virQEMUDriverPtr driver, entry->domains[entry->ref - 1] =3D g_strdup(name); } } else { - if (VIR_ALLOC(entry) < 0 || - VIR_ALLOC_N(entry->domains, 1) < 0) - goto error; + entry =3D g_new0(qemuSharedDeviceEntry, 1); + entry->domains =3D g_new0(char *, 1); =20 entry->domains[0] =3D g_strdup(name); =20 diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 61eb53ea2c..0199a620a0 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -3038,8 +3038,7 @@ qemuDomainUSBAddressAddHubs(virDomainDefPtr def) data.count, available_ports, hubs_needed); =20 for (i =3D 0; i < hubs_needed; i++) { - if (VIR_ALLOC(hub) < 0) - return -1; + hub =3D g_new0(virDomainHubDef, 1); hub->type =3D VIR_DOMAIN_HUB_TYPE_USB; =20 if (VIR_APPEND_ELEMENT(def->hubs, def->nhubs, hub) < 0) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 11b549b12b..09f8525cfa 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -928,8 +928,7 @@ qemuDomainFindOrCreateSCSIDiskController(virQEMUDriverP= tr driver, =20 /* No SCSI controller present, for backward compatibility we * now hotplug a controller */ - if (VIR_ALLOC(cont) < 0) - return NULL; + cont =3D g_new0(virDomainControllerDef, 1); cont->type =3D VIR_DOMAIN_CONTROLLER_TYPE_SCSI; cont->idx =3D controller; if (model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT) @@ -1243,11 +1242,9 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, if (!tapfdSize) tapfdSize =3D vhostfdSize =3D 1; queueSize =3D tapfdSize; - if (VIR_ALLOC_N(tapfd, tapfdSize) < 0) - goto cleanup; + tapfd =3D g_new0(int, tapfdSize); memset(tapfd, -1, sizeof(*tapfd) * tapfdSize); - if (VIR_ALLOC_N(vhostfd, vhostfdSize) < 0) - goto cleanup; + vhostfd =3D g_new0(int, vhostfdSize); memset(vhostfd, -1, sizeof(*vhostfd) * vhostfdSize); if (qemuInterfaceBridgeConnect(vm->def, driver, net, tapfd, &tapfdSize) < 0) @@ -1262,11 +1259,9 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, if (!tapfdSize) tapfdSize =3D vhostfdSize =3D 1; queueSize =3D tapfdSize; - if (VIR_ALLOC_N(tapfd, tapfdSize) < 0) - goto cleanup; + tapfd =3D g_new0(int, tapfdSize); memset(tapfd, -1, sizeof(*tapfd) * tapfdSize); - if (VIR_ALLOC_N(vhostfd, vhostfdSize) < 0) - goto cleanup; + vhostfd =3D g_new0(int, vhostfdSize); memset(vhostfd, -1, sizeof(*vhostfd) * vhostfdSize); if (qemuInterfaceDirectConnect(vm->def, driver, net, tapfd, tapfdSize, @@ -1282,10 +1277,9 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, if (!tapfdSize) tapfdSize =3D vhostfdSize =3D 1; queueSize =3D tapfdSize; - if (VIR_ALLOC_N(tapfd, tapfdSize) < 0) - goto cleanup; + tapfd =3D g_new0(int, tapfdSize); memset(tapfd, -1, sizeof(*tapfd) * tapfdSize); - if (VIR_ALLOC_N(vhostfd, vhostfdSize) < 0) + vhostfd =3D g_new0(int, vhostfdSize); goto cleanup; memset(vhostfd, -1, sizeof(*vhostfd) * vhostfdSize); if (qemuInterfaceEthernetConnect(vm->def, driver, net, @@ -1381,9 +1375,8 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, goto cleanup; } =20 - if (VIR_ALLOC_N(tapfdName, tapfdSize) < 0 || - VIR_ALLOC_N(vhostfdName, vhostfdSize) < 0) - goto cleanup; + tapfdName =3D g_new0(char *, tapfdSize); + vhostfdName =3D g_new0(char *, vhostfdSize); =20 for (i =3D 0; i < tapfdSize; i++) tapfdName[i] =3D g_strdup_printf("fd-%s%zu", net->info.alias, i); @@ -1973,8 +1966,8 @@ qemuDomainChrPreInsert(virDomainDefPtr vmdef, */ if (vmdef->nserials =3D=3D 0 && vmdef->nconsoles =3D=3D 0 && chr->deviceType =3D=3D VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL) { - if (!vmdef->consoles && VIR_ALLOC(vmdef->consoles) < 0) - return -1; + if (!vmdef->consoles) + vmdef->consoles =3D g_new0(virDomainChrDefPtr, 1); =20 /* We'll be dealing with serials[0] directly, so NULL is fine here= . */ if (!(vmdef->consoles[0] =3D virDomainChrDefNew(NULL))) { diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 403f5d3e13..2000c86640 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -3309,8 +3309,7 @@ static void qemuMigrationSrcIOFunc(void *arg) VIR_DEBUG("Running migration tunnel; stream=3D%p, sock=3D%d", data->st, data->sock); =20 - if (VIR_ALLOC_N(buffer, TUNNEL_SEND_BUF_SIZE) < 0) - goto abrt; + buffer =3D g_new0(char, TUNNEL_SEND_BUF_SIZE); =20 fds[0].fd =3D data->sock; fds[1].fd =3D data->wakeupRecvFD; @@ -3414,8 +3413,7 @@ qemuMigrationSrcStartTunnel(virStreamPtr st, if (virPipe(wakeupFD) < 0) goto error; =20 - if (VIR_ALLOC(io) < 0) - goto error; + io =3D g_new0(qemuMigrationIOThread, 1); =20 io->st =3D st; io->sock =3D sock; diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index eb4b04dc1a..27ad739983 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -1869,8 +1869,7 @@ qemuMonitorGetCPUInfo(qemuMonitorPtr mon, =20 QEMU_CHECK_MONITOR(mon); =20 - if (VIR_ALLOC_N(info, maxvcpus) < 0) - return -1; + info =3D g_new0(qemuMonitorCPUInfo, maxvcpus); =20 /* initialize a few non-zero defaults */ qemuMonitorCPUInfoClear(info, maxvcpus); @@ -3685,11 +3684,9 @@ qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUMode= lInfo *orig) qemuMonitorCPUModelInfoPtr copy; size_t i; =20 - if (VIR_ALLOC(copy) < 0) - goto error; + copy =3D g_new0(qemuMonitorCPUModelInfo, 1); =20 - if (VIR_ALLOC_N(copy->props, orig->nprops) < 0) - goto error; + copy->props =3D g_new0(qemuMonitorCPUProperty, orig->nprops); =20 copy->name =3D g_strdup(orig->name); =20 @@ -3720,10 +3717,6 @@ qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUMode= lInfo *orig) } =20 return copy; - - error: - qemuMonitorCPUModelInfoFree(copy); - return NULL; } =20 =20 diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c index b0d1d0d083..5c58893693 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -155,8 +155,7 @@ qemuDomainGetPreservedMounts(virQEMUDriverConfigPtr cfg, } } =20 - if (VIR_ALLOC_N(paths, nmounts) < 0) - goto error; + paths =3D g_new0(char *, nmounts); =20 for (i =3D 0; i < nmounts; i++) { if (!(paths[i] =3D qemuDomainGetPreservedMountPath(cfg, vm, mounts= [i]))) diff --git a/src/qemu/qemu_saveimage.c b/src/qemu/qemu_saveimage.c index 52468056ad..0e588d463d 100644 --- a/src/qemu/qemu_saveimage.c +++ b/src/qemu/qemu_saveimage.c @@ -103,8 +103,7 @@ virQEMUSaveDataNew(char *domXML, virQEMUSaveDataPtr data =3D NULL; virQEMUSaveHeaderPtr header; =20 - if (VIR_ALLOC(data) < 0) - return NULL; + data =3D g_new0(virQEMUSaveData, 1); =20 data->xml =3D g_steal_pointer(&domXML); =20 diff --git a/src/qemu/qemu_vhost_user.c b/src/qemu/qemu_vhost_user.c index be7c3dd5b8..260f3cd550 100644 --- a/src/qemu/qemu_vhost_user.c +++ b/src/qemu/qemu_vhost_user.c @@ -196,8 +196,7 @@ qemuVhostUserParse(const char *path) return NULL; } =20 - if (VIR_ALLOC(vu) < 0) - return NULL; + vu =3D g_new0(qemuVhostUser, 1); =20 if (qemuVhostUserTypeParse(path, doc, vu) < 0) return NULL; @@ -253,8 +252,7 @@ qemuVhostUserFetchParsedConfigs(bool privileged, =20 npaths =3D virStringListLength((const char **)paths); =20 - if (VIR_ALLOC_N(vus, npaths) < 0) - return -1; + vus =3D g_new0(qemuVhostUserPtr, npaths); =20 for (i =3D 0; i < npaths; i++) { if (!(vus[i] =3D qemuVhostUserParse(paths[i]))) @@ -292,8 +290,7 @@ qemuVhostUserGPUFillCapabilities(qemuVhostUserPtr vu, } =20 nfeatures =3D virJSONValueArraySize(featuresJSON); - if (VIR_ALLOC_N(features, nfeatures) < 0) - return -1; + features =3D g_new0(qemuVhostUserGPUFeature, nfeatures); =20 for (i =3D 0; i < nfeatures; i++) { virJSONValuePtr item =3D virJSONValueArrayGet(featuresJSON, i); @@ -382,8 +379,8 @@ qemuVhostUserFillDomainGPU(virQEMUDriverPtr driver, continue; } =20 - if (!video->driver && VIR_ALLOC(video->driver) < 0) - goto end; + if (!video->driver) + video->driver =3D g_new0(virDomainVideoDriverDef, 1); =20 VIR_FREE(video->driver->vhost_user_binary); video->driver->vhost_user_binary =3D g_strdup(vu->binary); @@ -397,8 +394,8 @@ qemuVhostUserFillDomainGPU(virQEMUDriverPtr driver, goto end; } =20 - if (!video->accel && VIR_ALLOC(video->accel) < 0) - goto end; + if (!video->accel) + video->accel =3D g_new0(virDomainVideoAccelDef, 1); =20 if (!video->accel->rendernode && qemuVhostUserGPUHasFeature(&vu->capabilities.gpu, --=20 2.26.2