From nobody Sat Apr 27 18:03:57 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=1600815905; cv=none; d=zohomail.com; s=zohoarc; b=gggxVLlq2P4hvR4mX8NTNRxA5k5NVi4p1HTy7mILuIuaqM+X7BM2hZFknzCVnxBnOg4FUYnFG7Hv+IDhoI5fYayK5Mc5kkxDT+wtzB6+sBjof9U4JBCBqfRdJicmmvqQ+2+paEt4j/PjkP4eHdC/UpaQ0W1i4211f1Tblev9zwI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600815905; 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=Is/TyyGA0dfQjJ9bX6rvqBM0N+iqV8Nycu+jw257kzk=; b=jjXuzdSKvD5XzQm3SPJmvLT00nbjKmBUJp6DIaQ/di6pU3Db1fl/l/ozFRdnX105HYGcK9/LCl7t3RUzKbCRNtIrqqk/0TUGKNN0BdkOmpZ9LSqIflpKNvFpIz3wTU54VBnU65HfmWWtC4V+Ir1Tn16csE0y51xUY7mYdvtpcDE= 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 160081590535042.797459259906645; Tue, 22 Sep 2020 16:05:05 -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-429-CSfoQGabP8-aL7oWMpiP-w-1; Tue, 22 Sep 2020 19:05:01 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4B7302FD0D; Tue, 22 Sep 2020 23:04:55 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 165C35577D; Tue, 22 Sep 2020 23:04:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C6F751826D30; Tue, 22 Sep 2020 23:04:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 08MN4PNH032466 for ; Tue, 22 Sep 2020 19:04:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0EC8773670; Tue, 22 Sep 2020 23:04:25 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 89395614F5 for ; Tue, 22 Sep 2020 23:04:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600815904; 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=Is/TyyGA0dfQjJ9bX6rvqBM0N+iqV8Nycu+jw257kzk=; b=eakql9RJUSeePkBt952OuLMOknLAYcO8XUXjdhVrzFORMg9XnORQHRGff8wio9LTTVjLF7 U7MT8kUrSyM9rNNIV6HmMT9cg1NvjapUqBt9or66PJ+/N35YS0HLhDiYFlbrF7eVTLt3As z3lG78OjKXabZKuV3ELrC+bjf5cG2Ts= X-MC-Unique: CSfoQGabP8-aL7oWMpiP-w-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/4] tests: virNumaGetPages: use g_new0 instead of VIR_ALLOC_N Date: Wed, 23 Sep 2020 01:04:15 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- tests/virnumamock.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/tests/virnumamock.c b/tests/virnumamock.c index e6282c7f33..40e18e646e 100644 --- a/tests/virnumamock.c +++ b/tests/virnumamock.c @@ -133,23 +133,13 @@ virNumaGetPages(int node, size_t i =3D 0; =20 if (pages_size) - *pages_size =3D NULL; + *pages_size =3D g_new0(unsigned int, npages_def); =20 if (pages_avail) - *pages_avail =3D NULL; + *pages_avail =3D g_new0(unsigned long long, npages_def); =20 if (pages_free) - *pages_free =3D NULL; - - *npages =3D 0; - - if ((pages_size && VIR_ALLOC_N(*pages_size, npages_def) < 0) || - (pages_avail && VIR_ALLOC_N(*pages_avail, npages_def) < 0) || - (pages_free && VIR_ALLOC_N(*pages_free, npages_def) < 0)) { - VIR_FREE(*pages_size); - VIR_FREE(*pages_avail); - return -1; - } + *pages_free =3D g_new0(unsigned long long, npages_def); =20 *npages =3D npages_def; if (pages_size) --=20 2.26.2 From nobody Sat Apr 27 18:03:57 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=1600815927; cv=none; d=zohomail.com; s=zohoarc; b=FEBMrcKtqXmwGLPiPpCzgQu9HMBwJ1Ez+FqgJBI4oCYXinJHdwteiM5XlkCZtnT4geW+/ZWiNDvKNKAW0qNP3VGqc2A+ivzqblQ9fItUVODchlEa9NS3eRImRSr0qMWJ6LJ9qP6vfYb/bUtOoSp/lh7fdv3o3tv42amByUccwug= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600815927; 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=l3x3AUz7WLfxRHGZeDnU/ESkJN7YaCJue5eyT91QAPQ=; b=i9sn5kwVnE07Q7yddVTsUew8zQ6IPQF8DtcSpMjc4eu1aMY7i2yxpfZo1cwUcZ/+vOEcBR+Mb+vPY9d97B7c/mllKw674LyfiXN17dsyN8f5nAwVtkjpzujUZRL2Ur4qMSUtJVgIrXY2w51qhh7EzPAye6e/uEy3QrPD5H8plrE= 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 1600815926774205.59016377969886; Tue, 22 Sep 2020 16:05:26 -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-72-SdQ14qt5OCydSH0_yCWDgQ-1; Tue, 22 Sep 2020 19:05:22 -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 76801873079; Tue, 22 Sep 2020 23:05:17 +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 4F8947367E; Tue, 22 Sep 2020 23:05:17 +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 BEC468C7AA; Tue, 22 Sep 2020 23:05:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 08MN4PZb032476 for ; Tue, 22 Sep 2020 19:04:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id D79BC73670; Tue, 22 Sep 2020 23:04:25 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5DC5E614F5 for ; Tue, 22 Sep 2020 23:04:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600815925; 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=l3x3AUz7WLfxRHGZeDnU/ESkJN7YaCJue5eyT91QAPQ=; b=azDJ9FxTGvzvi7uZkGWxySloOUaX9kJ1pb/G0w/YrQ9ZGLrVcCEE9QYfUwTndfgRAOvaVx Iqa7YM/Kswl114dEEEYKq2G0bgzzv7pTjb5QnBoeZ6LmR+enTZ9HPiehqFXMYu0K2dWcFD 7NNzP8ltIZkfio7mfNjI1G0GxOD1xNY= X-MC-Unique: SdQ14qt5OCydSH0_yCWDgQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/4] tests: cpuTestLoadMultiXML: use g_new0 instead of VIR_ALLOC_N Date: Wed, 23 Sep 2020 01:04:16 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: J=C3=A1n Tomko Reviewed-by: Peter Krempa --- tests/cputest.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/cputest.c b/tests/cputest.c index 83d63bf495..383da94938 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -111,11 +111,13 @@ cpuTestLoadMultiXML(virArch arch, goto cleanup; =20 n =3D virXPathNodeSet("/cpuTest/cpu", ctxt, &nodes); - if (n <=3D 0 || (VIR_ALLOC_N(cpus, n) < 0)) { + if (n <=3D 0) { fprintf(stderr, "\nNo /cpuTest/cpu elements found in %s\n", xml); goto cleanup; } =20 + cpus =3D g_new0(virCPUDefPtr, n); + for (i =3D 0; i < n; i++) { ctxt->node =3D nodes[i]; if (virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_HOST, &cpus[i]) < 0) --=20 2.26.2 From nobody Sat Apr 27 18:03:57 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=1600815949; cv=none; d=zohomail.com; s=zohoarc; b=COF876bPYa2z3ATu/lfX7tD01qKH59WhlEKAg9JOe/cOb1n7oOHpYFPTTxcjSxJr2z9qXd4W0Hcd/NlFVth4iHJDNLATcAjjG/U9pkDGuWqcmWwGcqms01/Ru8/GwsjMXMPGB1Yh70gwR5vrhmD39ybT1qEcGYcLt8SxzFNSOLQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600815949; 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=KnTH/XGTQDnYALourdrIM6TbsmJ85q3cZslhi0x96J0=; b=QViQQc++tl3YatamMY8BRAqotNx/zF41bqLKNqiGPnNy0uo+bwrBCjC/KHScily4Mqorp0S17CygWUHfkvG4btb7H9kOu6280B6+37+5kIxpwppA8WErND67XIArbOKU1o6SYyLX+jfdyaxxBzfiO2JSznexcVOFrJeqGFQcRlU= 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 1600815949264726.6240801475939; Tue, 22 Sep 2020 16:05:49 -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-173-StQZWCDlNv6R3xRGYr0_2g-1; Tue, 22 Sep 2020 19:05:44 -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 60B9B81F010; Tue, 22 Sep 2020 23:05:38 +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 3498E19C4F; Tue, 22 Sep 2020 23:05:38 +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 F2E3F8C7D1; Tue, 22 Sep 2020 23:05:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 08MN4Q62032501 for ; Tue, 22 Sep 2020 19:04:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id D33E273670; Tue, 22 Sep 2020 23:04:26 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 32721614F5 for ; Tue, 22 Sep 2020 23:04:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600815948; 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=KnTH/XGTQDnYALourdrIM6TbsmJ85q3cZslhi0x96J0=; b=ZV8RqcBjQcS6pYIVrtjGVo9odfTa2aD6KUp2RqmnYP4wBWHJMwbZmsNs/zdAD8r6V3Hxhn A2Wh30ObXolxWyrQNTfARmq15MZAkfq9IAJDmYTCDNy0vhZ7MjxtCNgyV7Hq1f/TEvr0Yj bbA1FYqrI4vtaG087tTx3rsUR0Q5YNk= X-MC-Unique: StQZWCDlNv6R3xRGYr0_2g-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 3/4] tests: use g_new0 instead of VIR_ALLOC_N Date: Wed, 23 Sep 2020 01:04:17 +0200 Message-Id: <0ef073fa8f2a166572a809aa93e331ae528fdb51.1600815811.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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 --- tests/commandtest.c | 7 +++---- tests/domaincapstest.c | 3 +-- tests/fdstreamtest.c | 10 ++++------ tests/qemuxml2argvtest.c | 3 +-- tests/securityselinuxlabeltest.c | 3 +-- tests/securityselinuxtest.c | 3 +-- tests/testutils.c | 8 ++------ tests/testutilsqemu.c | 6 ++---- tests/vircgrouptest.c | 3 +-- tests/vircryptotest.c | 5 ++--- tests/virhostcputest.c | 3 +-- tests/virnetmessagetest.c | 6 ++---- tests/virnetsockettest.c | 6 +----- tests/virnettlshelpers.c | 3 +-- tests/virstringtest.c | 3 +-- tests/xlconfigtest.c | 3 +-- tests/xmconfigtest.c | 3 +-- 17 files changed, 26 insertions(+), 52 deletions(-) diff --git a/tests/commandtest.c b/tests/commandtest.c index cbbcda4e5f..df86725f0e 100644 --- a/tests/commandtest.c +++ b/tests/commandtest.c @@ -1057,10 +1057,9 @@ static int test27(const void *unused G_GNUC_UNUSED) "%s%s%s" \ "END STDERR\n" =20 - if (VIR_ALLOC_N(buffer0, buflen) < 0 || - VIR_ALLOC_N(buffer1, buflen) < 0 || - VIR_ALLOC_N(buffer2, buflen) < 0) - goto cleanup; + buffer0 =3D g_new0(char, buflen); + buffer1 =3D g_new0(char, buflen); + buffer2 =3D g_new0(char, buflen); =20 memset(buffer0, 'H', buflen - 2); buffer0[buflen - 2] =3D '\n'; diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index d2ed820cf9..b3d36f55fc 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -147,8 +147,7 @@ fillXenCaps(virDomainCapsPtr domCaps) virFirmwarePtr *firmwares; int ret =3D -1; =20 - if (VIR_ALLOC_N(firmwares, 2) < 0) - return ret; + firmwares =3D g_new0(virFirmwarePtr, 2); =20 if (VIR_ALLOC(firmwares[0]) < 0 || VIR_ALLOC(firmwares[1]) < 0) goto cleanup; diff --git a/tests/fdstreamtest.c b/tests/fdstreamtest.c index 83973137e7..7a2fe27477 100644 --- a/tests/fdstreamtest.c +++ b/tests/fdstreamtest.c @@ -54,9 +54,8 @@ static int testFDStreamReadCommon(const char *scratchdir,= bool blocking) if (!(conn =3D virConnectOpen("test:///default"))) goto cleanup; =20 - if (VIR_ALLOC_N(pattern, PATTERN_LEN) < 0 || - VIR_ALLOC_N(buf, PATTERN_LEN) < 0) - goto cleanup; + pattern =3D g_new0(char, PATTERN_LEN); + buf =3D g_new0(char, PATTERN_LEN); =20 for (i =3D 0; i < PATTERN_LEN; i++) pattern[i] =3D i; @@ -185,9 +184,8 @@ static int testFDStreamWriteCommon(const char *scratchd= ir, bool blocking) if (!(conn =3D virConnectOpen("test:///default"))) goto cleanup; =20 - if (VIR_ALLOC_N(pattern, PATTERN_LEN) < 0 || - VIR_ALLOC_N(buf, PATTERN_LEN) < 0) - goto cleanup; + pattern =3D g_new0(char, PATTERN_LEN); + buf =3D g_new0(char, PATTERN_LEN); =20 for (i =3D 0; i < PATTERN_LEN; i++) pattern[i] =3D i; diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index e93948e3fc..463e4c003d 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -753,8 +753,7 @@ mymain(void) driver.config->nbdTLSx509certdir =3D g_strdup("/etc/pki/libvirt-nbd/du= mmy,path"); =20 VIR_FREE(driver.config->hugetlbfs); - if (VIR_ALLOC_N(driver.config->hugetlbfs, 2) < 0) - return EXIT_FAILURE; + driver.config->hugetlbfs =3D g_new0(virHugeTLBFS, 2); driver.config->nhugetlbfs =3D 2; driver.config->hugetlbfs[0].mnt_dir =3D g_strdup("/dev/hugepages2M"); driver.config->hugetlbfs[1].mnt_dir =3D g_strdup("/dev/hugepages1G"); diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabelt= est.c index 2989a668b7..168acc2bdf 100644 --- a/tests/securityselinuxlabeltest.c +++ b/tests/securityselinuxlabeltest.c @@ -114,8 +114,7 @@ testSELinuxLoadFileList(const char *testname, if (!(fp =3D fopen(path, "r"))) goto cleanup; =20 - if (VIR_ALLOC_N(line, 1024) < 0) - goto cleanup; + line =3D g_new0(char, 1024); =20 while (!feof(fp)) { char *file =3D NULL, *context =3D NULL, *tmp; diff --git a/tests/securityselinuxtest.c b/tests/securityselinuxtest.c index ae4b08b9d8..fd746d1ca1 100644 --- a/tests/securityselinuxtest.c +++ b/tests/securityselinuxtest.c @@ -71,8 +71,7 @@ testBuildDomainDef(bool dynamic, goto error; =20 def->virtType =3D VIR_DOMAIN_VIRT_KVM; - if (VIR_ALLOC_N(def->seclabels, 1) < 0) - goto error; + def->seclabels =3D g_new0(char, 1); =20 if (VIR_ALLOC(secdef) < 0) goto error; diff --git a/tests/testutils.c b/tests/testutils.c index 3f53f635fc..b747f65eea 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -211,10 +211,7 @@ virTestLoadFile(const char *file, char **buf) =20 tmplen =3D buflen =3D st.st_size + 1; =20 - if (VIR_ALLOC_N(*buf, buflen) < 0) { - VIR_FORCE_FCLOSE(fp); - return -1; - } + *buf =3D g_new0(char, buflen); =20 tmp =3D *buf; (*buf)[0] =3D '\0'; @@ -977,8 +974,7 @@ virTestCapsBuildNUMATopology(int seq) =20 id =3D 0; for (cell_id =3D 0; cell_id < MAX_CELLS; cell_id++) { - if (VIR_ALLOC_N(cell_cpus, MAX_CPUS_IN_CELL) < 0) - goto error; + cell_cpus =3D g_new0(virCapsHostNUMACellCPU, MAX_CPUS_IN_CELL); =20 for (core_id =3D 0; core_id < MAX_CPUS_IN_CELL; core_id++) { cell_cpus[core_id].id =3D id + core_id; diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index 51ac59bade..eb37bbfdad 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -204,8 +204,7 @@ virCapsPtr testQemuCapsInit(void) =20 /* Add dummy 'none' security_driver. This is equal to setting * security_driver =3D "none" in qemu.conf. */ - if (VIR_ALLOC_N(caps->host.secModels, 1) < 0) - goto cleanup; + caps->host.secModels =3D g_new0(virCapsHostSecModel, 1); caps->host.nsecModels =3D 1; =20 caps->host.secModels[0].model =3D g_strdup("none"); @@ -459,8 +458,7 @@ testQemuCapsSetGIC(virQEMUCapsPtr qemuCaps, virGICCapability *gicCapabilities =3D NULL; size_t ngicCapabilities =3D 0; =20 - if (VIR_ALLOC_N(gicCapabilities, 2) < 0) - return -1; + gicCapabilities =3D g_new0(virGICCapability, 2); =20 # define IMPL_BOTH \ VIR_GIC_IMPLEMENTATION_KERNEL|VIR_GIC_IMPLEMENTATION_EMULATED diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c index 44e72cbfa9..e5be556104 100644 --- a/tests/vircgrouptest.c +++ b/tests/vircgrouptest.c @@ -708,8 +708,7 @@ static int testCgroupGetPercpuStats(const void *args G_= GNUC_UNUSED) 635751356ULL, 0, 0, 0, 0, 0, 0, 0, }; =20 - if (VIR_ALLOC_N(params, EXPECTED_NCPUS) < 0) - goto cleanup; + params =3D g_new0(virTypedParameter, EXPECTED_NCPUS); =20 if ((rv =3D virCgroupNewPartition("/virtualmachines", true, (1 << VIR_CGROUP_CONTROLLER_CPU) | diff --git a/tests/vircryptotest.c b/tests/vircryptotest.c index 42ef0b8900..90140077cf 100644 --- a/tests/vircryptotest.c +++ b/tests/vircryptotest.c @@ -83,9 +83,8 @@ testCryptoEncrypt(const void *opaque) return EXIT_AM_SKIP; } =20 - if (VIR_ALLOC_N(enckey, enckeylen) < 0 || - VIR_ALLOC_N(iv, ivlen) < 0) - goto cleanup; + enckey =3D g_new0(uint8_t, enckeylen); + iv =3D g_new0(uint8_t, ivlen); =20 if (virRandomBytes(enckey, enckeylen) < 0 || virRandomBytes(iv, ivlen) < 0) { diff --git a/tests/virhostcputest.c b/tests/virhostcputest.c index 7b83c7ae5d..786a363e48 100644 --- a/tests/virhostcputest.c +++ b/tests/virhostcputest.c @@ -124,8 +124,7 @@ linuxCPUStatsCompareFiles(const char *cpustatfile, if (virHostCPUGetStatsLinux(NULL, 0, NULL, &nparams) < 0) goto fail; =20 - if (VIR_ALLOC_N(params, nparams) < 0) - goto fail; + params =3D g_new0(virNodeCPUStats, nparams); =20 if (virHostCPUGetStatsLinux(cpustat, VIR_NODE_CPU_STATS_ALL_CPUS, para= ms, &nparams) < 0) diff --git a/tests/virnetmessagetest.c b/tests/virnetmessagetest.c index a207f2d85f..89fadc346a 100644 --- a/tests/virnetmessagetest.c +++ b/tests/virnetmessagetest.c @@ -102,8 +102,7 @@ static int testMessageHeaderDecode(const void *args G_G= NUC_UNUSED) return -1; =20 msg->bufferLength =3D 4; - if (VIR_ALLOC_N(msg->buffer, msg->bufferLength) < 0) - goto cleanup; + msg->buffer =3D g_new0(char, msg->bufferLength); memcpy(msg->buffer, input_buf, msg->bufferLength); =20 msg->header.prog =3D 0x11223344; @@ -333,8 +332,7 @@ static int testMessagePayloadDecode(const void *args G_= GNUC_UNUSED) return -1; =20 msg->bufferLength =3D 4; - if (VIR_ALLOC_N(msg->buffer, msg->bufferLength) < 0) - goto cleanup; + msg->buffer =3D g_new0(char, msg->bufferLength); memcpy(msg->buffer, input_buffer, msg->bufferLength); =20 if (virNetMessageDecodeLength(msg) < 0) { diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c index d6b461cbc8..5216b98424 100644 --- a/tests/virnetsockettest.c +++ b/tests/virnetsockettest.c @@ -206,11 +206,7 @@ testSocketAccept(const void *opaque) if (virNetSocketNewListenUNIX(path, 0700, -1, getegid(), &usock) <= 0) goto cleanup; =20 - if (VIR_ALLOC_N(lsock, 1) < 0) { - virObjectUnref(usock); - goto cleanup; - } - + lsock =3D g_new0(virNetSocketPtr, 1); lsock[0] =3D usock; nlsock =3D 1; =20 diff --git a/tests/virnettlshelpers.c b/tests/virnettlshelpers.c index e0a4771894..ce38571b0a 100644 --- a/tests/virnettlshelpers.c +++ b/tests/virnettlshelpers.c @@ -117,8 +117,7 @@ static void testTLSDerEncode(ASN1_TYPE src, size =3D 0; asn1_der_coding(src, src_name, NULL, &size, NULL); =20 - if (VIR_ALLOC_N(data, size) < 0) - abort(); + data =3D g_new0(char, size); =20 asn1_der_coding(src, src_name, data, &size, NULL); =20 diff --git a/tests/virstringtest.c b/tests/virstringtest.c index 704686ac10..e48e4057fd 100644 --- a/tests/virstringtest.c +++ b/tests/virstringtest.c @@ -556,8 +556,7 @@ testVirStringListFreeCount(const void *opaque G_GNUC_UN= USED) { char **list; =20 - if (VIR_ALLOC_N(list, 4) < 0) - return -1; + list =3D g_new0(char *, 4); =20 list[0] =3D g_strdup("test1"); list[2] =3D g_strdup("test2"); diff --git a/tests/xlconfigtest.c b/tests/xlconfigtest.c index 3ad66ccfa1..ab1a834f1b 100644 --- a/tests/xlconfigtest.c +++ b/tests/xlconfigtest.c @@ -73,8 +73,7 @@ testCompareParseXML(const char *xlcfg, const char *xml, b= ool replaceVars) virDomainDefPtr def =3D NULL; char *replacedXML =3D NULL; =20 - if (VIR_ALLOC_N(gotxlcfgData, wrote) < 0) - goto fail; + gotxlcfgData =3D g_new0(char, wrote); =20 conn =3D virGetConnect(); if (!conn) goto fail; diff --git a/tests/xmconfigtest.c b/tests/xmconfigtest.c index 43949fe3b5..8d6b2378fd 100644 --- a/tests/xmconfigtest.c +++ b/tests/xmconfigtest.c @@ -46,8 +46,7 @@ testCompareParseXML(const char *xmcfg, const char *xml) int wrote =3D 4096; virDomainDefPtr def =3D NULL; =20 - if (VIR_ALLOC_N(gotxmcfgData, wrote) < 0) - goto fail; + gotxmcfgData =3D g_new0(char, wrote); =20 conn =3D virGetConnect(); if (!conn) goto fail; --=20 2.26.2 From nobody Sat Apr 27 18:03:57 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=1600815970; cv=none; d=zohomail.com; s=zohoarc; b=bInD8tIS1JSCq0NXN8YSW1siWIzEiuwCEMRSnhWkzgJOPESIpFYZFDPzp2jXGCzL2jcQY+2QvRCpPvGI6EyhtJrpt3Q8Ot6Cuyx4axIvVW3HxOoEmAXdTArntW6EguIcaPqcZ+GG53dmNuvdFg2df+9YjVIgs0i2zJhJDdlD4n8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600815970; 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=26z16tSMaeTIlPx+TJSsX4boXDlVXKygTc4jXrTOzIQ=; b=eUK8MlkLr14duJkOI+ET7TzesjfuTs72bHgZTmfrYP+v0zM4fOVZP45T9NUb6nd2qd7r/chmu4iuu19bOg0xPJb3cTDy0TBj6+auh1H7hYO4sASOJtAswr3f5jVR0RJI2+fUqtu7OyDUx/z72j61bmrgup1Ud0RSlA8q1aOw0Po= 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 1600815970800333.76720944485453; Tue, 22 Sep 2020 16:06:10 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-167-DKs5laY1PgeF7G6BaYaIfw-1; Tue, 22 Sep 2020 19:06:05 -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 813A21007B1D; Tue, 22 Sep 2020 23:05:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5E76F5DA7B; Tue, 22 Sep 2020 23:05:59 +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 04B838C7D1; Tue, 22 Sep 2020 23:05:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 08MN4Ra0032508 for ; Tue, 22 Sep 2020 19:04:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id A7B8773670; Tue, 22 Sep 2020 23:04:27 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2DF5E614F5 for ; Tue, 22 Sep 2020 23:04:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600815969; 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=26z16tSMaeTIlPx+TJSsX4boXDlVXKygTc4jXrTOzIQ=; b=B9J2icdhe+04pZGbEH8pTNzjarAyHuQj2NXpO2BJMBzGy+lFh0rZYuu/+fv92gBUGYY1re Rnyx7/NAMCQsGOLIRprJR3Rk2nk2zyhTrcC7ZFgKC8HmCfmsoAhVy4nUV0cFPQ+XLic2jQ OEPF7bTy4pDmANXkJUiLB4IdW93/p8s= X-MC-Unique: DKs5laY1PgeF7G6BaYaIfw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 4/4] tests: use g_new0 instead of VIR_ALLOC Date: Wed, 23 Sep 2020 01:04:18 +0200 Message-Id: <17061c06899a5d92284b0b4c50b3eb58bf8fd369.1600815811.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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: Peter Krempa --- tests/domaincapstest.c | 7 +++---- tests/nodedevmdevctltest.c | 16 +++++----------- tests/nwfilterxml2firewalltest.c | 3 +-- tests/qemublocktest.c | 9 +++------ tests/qemuhotplugtest.c | 3 +-- tests/qemumonitorjsontest.c | 12 ++++-------- tests/qemumonitortestutils.c | 22 ++++++---------------- tests/qemusecuritymock.c | 3 +-- tests/securityselinuxhelper.c | 3 +-- tests/securityselinuxtest.c | 3 +-- tests/virhostdevtest.c | 3 +-- tests/virnetdaemontest.c | 3 +-- tests/virnetmessagetest.c | 9 ++++----- tests/virnetserverclienttest.c | 3 +-- tests/virstringtest.c | 5 ++--- 15 files changed, 35 insertions(+), 69 deletions(-) diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index b3d36f55fc..9b0a0c5758 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -148,9 +148,9 @@ fillXenCaps(virDomainCapsPtr domCaps) int ret =3D -1; =20 firmwares =3D g_new0(virFirmwarePtr, 2); + firmwares[0] =3D g_new0(virFirmware, 1); + firmwares[1] =3D g_new0(virFirmware, 1); =20 - if (VIR_ALLOC(firmwares[0]) < 0 || VIR_ALLOC(firmwares[1]) < 0) - goto cleanup; firmwares[0]->name =3D g_strdup("/usr/lib/xen/boot/hvmloader"); firmwares[1]->name =3D g_strdup("/usr/lib/xen/boot/ovmf.bin"); =20 @@ -174,8 +174,7 @@ fillBhyveCaps(virDomainCapsPtr domCaps, unsigned int *b= hyve_caps) virDomainCapsStringValuesPtr firmwares =3D NULL; int ret =3D -1; =20 - if (VIR_ALLOC(firmwares) < 0) - return -1; + firmwares =3D g_new0(virDomainCapsStringValues, 1); =20 if (fillStringValues(firmwares, "/foo/bar", "/foo/baz", NULL) < 0) goto cleanup; diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c index 57c1ad4f46..dab4b487b9 100644 --- a/tests/nodedevmdevctltest.c +++ b/tests/nodedevmdevctltest.c @@ -162,11 +162,8 @@ fakeRootDevice(void) { virNodeDeviceDefPtr def =3D NULL; =20 - if (VIR_ALLOC(def) !=3D 0 || VIR_ALLOC(def->caps) !=3D 0) { - virNodeDeviceDefFree(def); - return NULL; - } - + def =3D g_new0(virNodeDeviceDef, 1); + def->caps =3D g_new0(virNodeDevCapsDef, 1); def->name =3D g_strdup("computer"); =20 return def; @@ -182,10 +179,8 @@ fakeParentDevice(void) virNodeDeviceDefPtr def =3D NULL; virNodeDevCapPCIDevPtr pci_dev; =20 - if (VIR_ALLOC(def) !=3D 0 || VIR_ALLOC(def->caps) !=3D 0) { - virNodeDeviceDefFree(def); - return NULL; - } + def =3D g_new0(virNodeDeviceDef, 1); + def->caps =3D g_new0(virNodeDevCapsDef, 1); =20 def->name =3D g_strdup("pci_0000_00_02_0"); def->parent =3D g_strdup("computer"); @@ -233,8 +228,7 @@ static int nodedevTestDriverInit(void) { int ret =3D -1; - if (VIR_ALLOC(driver) < 0) - return -1; + driver =3D g_new0(virNodeDeviceDriverState, 1); =20 driver->lockFD =3D -1; if (virMutexInit(&driver->lock) < 0 || diff --git a/tests/nwfilterxml2firewalltest.c b/tests/nwfilterxml2firewallt= est.c index dff2b62028..755732487a 100644 --- a/tests/nwfilterxml2firewalltest.c +++ b/tests/nwfilterxml2firewalltest.c @@ -209,8 +209,7 @@ virNWFilterRuleDefToRuleInst(virNWFilterDefPtr def, virNWFilterRuleInstPtr ruleinst; int ret =3D -1; =20 - if (VIR_ALLOC(ruleinst) < 0) - goto cleanup; + ruleinst =3D g_new0(virNWFilterRuleInst, 1); =20 ruleinst->chainSuffix =3D def->chainsuffix; ruleinst->chainPriority =3D def->chainPriority; diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index 0685b703a1..2489b883ff 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -234,8 +234,7 @@ testQemuDiskXMLToJSONFakeSecrets(virStorageSourcePtr sr= c) srcpriv =3D QEMU_DOMAIN_STORAGE_SOURCE_PRIVATE(src); =20 if (src->auth) { - if (VIR_ALLOC(srcpriv->secinfo) < 0) - return -1; + srcpriv->secinfo =3D g_new0(qemuDomainSecretInfo, 1); =20 srcpriv->secinfo->type =3D VIR_DOMAIN_SECRET_INFO_TYPE_AES; srcpriv->secinfo->s.aes.username =3D g_strdup(src->auth->username); @@ -245,8 +244,7 @@ testQemuDiskXMLToJSONFakeSecrets(virStorageSourcePtr sr= c) } =20 if (src->encryption) { - if (VIR_ALLOC(srcpriv->encinfo) < 0) - return -1; + srcpriv->encinfo =3D g_new0(qemuDomainSecretInfo, 1); =20 srcpriv->encinfo->type =3D VIR_DOMAIN_SECRET_INFO_TYPE_AES; srcpriv->encinfo->s.aes.alias =3D g_strdup_printf("%s-encalias", @@ -493,8 +491,7 @@ testQemuImageCreateLoadDiskXML(const char *name, return NULL; } =20 - if (VIR_ALLOC(diskdef) < 0) - return NULL; + diskdef =3D g_new0(virDomainSnapshotDiskDef, 1); =20 if (virDomainSnapshotDiskDefParseXML(node, ctxt, diskdef, VIR_DOMAIN_DEF_PARSE_STATUS, diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index b023c49a69..2d12cacf28 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -413,8 +413,7 @@ testQemuHotplugCpuPrepare(const char *test, =20 prefix =3D g_strdup_printf("%s/qemuhotplugtestcpus/%s", abs_srcdir, te= st); =20 - if (VIR_ALLOC(data) < 0) - goto error; + data =3D g_new0(struct testQemuHotplugCpuData, 1); =20 data->modern =3D modern; =20 diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index bc25958e70..a0dcbba07b 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1653,8 +1653,7 @@ testQemuMonitorJSONqemuMonitorJSONGetBlockInfo(const = void *opaque) !(expectedBlockDevices =3D virHashCreate(32, virHashValueFree))) goto cleanup; =20 - if (VIR_ALLOC(info) < 0) - goto cleanup; + info =3D g_new0(struct qemuDomainDiskInfo, 1); =20 if (virHashAddEntry(expectedBlockDevices, "virtio-disk0", info) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -1662,8 +1661,7 @@ testQemuMonitorJSONqemuMonitorJSONGetBlockInfo(const = void *opaque) goto cleanup; } =20 - if (VIR_ALLOC(info) < 0) - goto cleanup; + info =3D g_new0(struct qemuDomainDiskInfo, 1); =20 if (virHashAddEntry(expectedBlockDevices, "virtio-disk1", info) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -1671,8 +1669,7 @@ testQemuMonitorJSONqemuMonitorJSONGetBlockInfo(const = void *opaque) goto cleanup; } =20 - if (VIR_ALLOC(info) < 0) - goto cleanup; + info =3D g_new0(struct qemuDomainDiskInfo, 1); =20 info->removable =3D true; info->tray =3D true; @@ -1683,8 +1680,7 @@ testQemuMonitorJSONqemuMonitorJSONGetBlockInfo(const = void *opaque) goto cleanup; } =20 - if (VIR_ALLOC(info) < 0) - goto cleanup; + info =3D g_new0(struct qemuDomainDiskInfo, 1); =20 info->removable =3D true; info->tray =3D true; diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index d74df15966..2fc26577a7 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -461,8 +461,7 @@ qemuMonitorTestAddHandler(qemuMonitorTestPtr test, { qemuMonitorTestItemPtr item; =20 - if (VIR_ALLOC(item) < 0) - goto error; + item =3D g_new0(qemuMonitorTestItem, 1); =20 item->identifier =3D g_strdup(identifier); item->cb =3D cb; @@ -619,8 +618,7 @@ qemuMonitorTestAddItem(qemuMonitorTestPtr test, { struct qemuMonitorTestHandlerData *data; =20 - if (VIR_ALLOC(data) < 0) - return -1; + data =3D g_new0(struct qemuMonitorTestHandlerData, 1); =20 data->command_name =3D g_strdup(command_name); data->response =3D g_strdup(response); @@ -694,8 +692,7 @@ qemuMonitorTestAddItemVerbatim(qemuMonitorTestPtr test, { struct qemuMonitorTestHandlerData *data; =20 - if (VIR_ALLOC(data) < 0) - return -1; + data =3D g_new0(struct qemuMonitorTestHandlerData, 1); =20 data->response =3D g_strdup(response); data->cmderr =3D g_strdup(cmderr); @@ -856,8 +853,7 @@ qemuMonitorTestAddItemParams(qemuMonitorTestPtr test, =20 va_start(args, response); =20 - if (VIR_ALLOC(data) < 0) - goto error; + data =3D g_new0(struct qemuMonitorTestHandlerData, 1); =20 data->command_name =3D g_strdup(cmdname); data->response =3D g_strdup(response); @@ -962,8 +958,7 @@ qemuMonitorTestAddItemExpect(qemuMonitorTestPtr test, { struct qemuMonitorTestHandlerData *data; =20 - if (VIR_ALLOC(data) < 0) - goto error; + data =3D g_new0(struct qemuMonitorTestHandlerData, 1); =20 data->command_name =3D g_strdup(cmdname); data->response =3D g_strdup(response); @@ -984,10 +979,6 @@ qemuMonitorTestAddItemExpect(qemuMonitorTestPtr test, cmdname, qemuMonitorTestProcessCommandWithArgS= tr, data, qemuMonitorTestHandlerDataFree); - - error: - qemuMonitorTestHandlerDataFree(data); - return -1; } =20 =20 @@ -1036,8 +1027,7 @@ qemuMonitorCommonTestNew(virDomainXMLOptionPtr xmlopt, char *path =3D NULL; char *tmpdir_template =3D NULL; =20 - if (VIR_ALLOC(test) < 0) - goto error; + test =3D g_new0(qemuMonitorTest, 1); =20 if (virMutexInit(&test->lock) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", diff --git a/tests/qemusecuritymock.c b/tests/qemusecuritymock.c index 6da8a91a9e..2eb714cc2e 100644 --- a/tests/qemusecuritymock.c +++ b/tests/qemusecuritymock.c @@ -270,8 +270,7 @@ mock_chown(const char *path, abort(); } =20 - if (VIR_ALLOC(val) < 0) - return -1; + val =3D g_new0(uint32_t, 1); =20 *val =3D (gid << 16) + uid; =20 diff --git a/tests/securityselinuxhelper.c b/tests/securityselinuxhelper.c index 14355d2166..b308ef5095 100644 --- a/tests/securityselinuxhelper.c +++ b/tests/securityselinuxhelper.c @@ -292,8 +292,7 @@ selabel_open(unsigned int backend, return real_selabel_open(backend, opts, nopts); =20 /* struct selabel_handle is opaque; fake it */ - if (VIR_ALLOC(fake_handle) < 0) - return NULL; + fake_handle =3D g_new0(char, 1); return (struct selabel_handle *)fake_handle; } =20 diff --git a/tests/securityselinuxtest.c b/tests/securityselinuxtest.c index fd746d1ca1..976c737cc2 100644 --- a/tests/securityselinuxtest.c +++ b/tests/securityselinuxtest.c @@ -73,8 +73,7 @@ testBuildDomainDef(bool dynamic, def->virtType =3D VIR_DOMAIN_VIRT_KVM; def->seclabels =3D g_new0(char, 1); =20 - if (VIR_ALLOC(secdef) < 0) - goto error; + secdef =3D g_new0(virSecurityLabelDef, 1); =20 secdef->model =3D g_strdup("selinux"); =20 diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c index b0bad683a8..385db0849a 100644 --- a/tests/virhostdevtest.c +++ b/tests/virhostdevtest.c @@ -149,8 +149,7 @@ myInit(void) goto cleanup; } =20 - if (VIR_ALLOC(mgr) < 0) - goto cleanup; + mgr =3D g_new0(virHostdevManager, 1); if ((mgr->activePCIHostdevs =3D virPCIDeviceListNew()) =3D=3D NULL) goto cleanup; if ((mgr->activeUSBHostdevs =3D virUSBDeviceListNew()) =3D=3D NULL) diff --git a/tests/virnetdaemontest.c b/tests/virnetdaemontest.c index 09d268627c..a20f351f93 100644 --- a/tests/virnetdaemontest.c +++ b/tests/virnetdaemontest.c @@ -38,8 +38,7 @@ testClientNew(virNetServerClientPtr client G_GNUC_UNUSED, { struct testClientPriv *priv; =20 - if (VIR_ALLOC(priv) < 0) - return NULL; + priv =3D g_new0(struct testClientPriv, 1); =20 priv->magic =3D 1729; =20 diff --git a/tests/virnetmessagetest.c b/tests/virnetmessagetest.c index 89fadc346a..9f6115f226 100644 --- a/tests/virnetmessagetest.c +++ b/tests/virnetmessagetest.c @@ -226,11 +226,10 @@ static int testMessagePayloadEncode(const void *args = G_GNUC_UNUSED) err.domain =3D VIR_FROM_RPC; err.level =3D VIR_ERR_ERROR; =20 - if (VIR_ALLOC(err.message) < 0 || - VIR_ALLOC(err.str1) < 0 || - VIR_ALLOC(err.str2) < 0 || - VIR_ALLOC(err.str3) < 0) - goto cleanup; + err.message =3D g_new0(char *, 1); + err.str1 =3D g_new0(char *, 1); + err.str2 =3D g_new0(char *, 1); + err.str3 =3D g_new0(char *, 1); =20 *err.message =3D g_strdup("Hello World"); *err.str1 =3D g_strdup("One"); diff --git a/tests/virnetserverclienttest.c b/tests/virnetserverclienttest.c index 668fd02a1e..a4341c1641 100644 --- a/tests/virnetserverclienttest.c +++ b/tests/virnetserverclienttest.c @@ -32,8 +32,7 @@ testClientNew(virNetServerClientPtr client G_GNUC_UNUSED, { char *dummy; =20 - if (VIR_ALLOC(dummy) < 0) - return NULL; + dummy =3D g_new0(char, 1); =20 return dummy; } diff --git a/tests/virstringtest.c b/tests/virstringtest.c index e48e4057fd..7305190691 100644 --- a/tests/virstringtest.c +++ b/tests/virstringtest.c @@ -176,9 +176,8 @@ static int testAdd(const void *args) goto cleanup; } =20 - if (!list && - VIR_ALLOC(list) < 0) - goto cleanup; + if (!list) + list =3D g_new0(char *, 1); =20 if (!(got =3D virStringListJoin((const char **)list, data->delim))) { VIR_DEBUG("Got no result"); --=20 2.26.2