From nobody Fri May 3 22:11:44 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=1602159179; cv=none; d=zohomail.com; s=zohoarc; b=oLaZKDj19xdHtyjD9en31rTqK1OBpKZrbyJVq53T0vioQCV5pu2geMOGPBs1yEfBcSQ/ujSH89nuoTh6fOETGUxSW2CxyLKGDdDnYFIl/5TxSXyDPOw6XofqrQ+Jtn16OHLa6T2jezFZ2bTq8BzIfCSrhRk/16XLjLyJwDjd/1M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602159179; 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=UR4Hask1cmpa+G2ZleMR04Pi32hY1FYSkjR7OZ9v3Y8=; b=BvB7AtshH6ULGt20SwA4i/TUJzDWBjvoO6Ai4aGK1Ty7D2IrH3/KuPlb4Hv6zAzftUHzjlGKilm2XMSkgU13PbVhouvHbe7/JwiCzB45BSsUIgyzGNQsLwIWRrZaERXBN4n0IH8Yt4agBBBPB35pbrZCLBM1ms9zbwX/LOYEJ0A= 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 1602159179264373.6313751154282; Thu, 8 Oct 2020 05:12:59 -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-105-wlPtU5hwMbCdPJ3KVNSr0w-1; Thu, 08 Oct 2020 08:12:55 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C4EB89CC26; Thu, 8 Oct 2020 12:12:37 +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 9CD7B1EA; Thu, 8 Oct 2020 12:12:37 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 69F551832FC2; Thu, 8 Oct 2020 12:12:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 098CCJQ0001266 for ; Thu, 8 Oct 2020 08:12:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3CC377DFFB; Thu, 8 Oct 2020 12:12:19 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 38B8175146 for ; Thu, 8 Oct 2020 12:12:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602159178; 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=UR4Hask1cmpa+G2ZleMR04Pi32hY1FYSkjR7OZ9v3Y8=; b=G5LofNl6OOl7d+wsO/DYLoTitAsihwyvv0zU58xDjr9gaRaITj4dfe0K687DChBUHmKC1U xnRfHFzxWnOCknZbP5i5C6fqhuYMnYkkf2rJrVN1mPeAJv/5wWKHR+AChToDVkfaqCypSN w+UxmsxGpuoOWhLS/83+p2WsSQmgKrU= X-MC-Unique: wlPtU5hwMbCdPJ3KVNSr0w-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/8] remote: refactor remoteSerializeDHCPLease Date: Thu, 8 Oct 2020 14:12:07 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.12 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) Use g_new0 for allocation and remove all the temporary variables. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Pavel Hrdina --- src/remote/remote_daemon_dispatch.c | 47 +++++------------------------ 1 file changed, 8 insertions(+), 39 deletions(-) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index c187932a3c..a659737bc7 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -6684,11 +6684,6 @@ remoteDispatchNodeGetFreePages(virNetServerPtr serve= r G_GNUC_UNUSED, static int remoteSerializeDHCPLease(remote_network_dhcp_lease *lease_dst, virNetworkD= HCPLeasePtr lease_src) { - char **mac_tmp =3D NULL; - char **iaid_tmp =3D NULL; - char **hostname_tmp =3D NULL; - char **clientid_tmp =3D NULL; - lease_dst->expirytime =3D lease_src->expirytime; lease_dst->type =3D lease_src->type; lease_dst->prefix =3D lease_src->prefix; @@ -6697,49 +6692,23 @@ remoteSerializeDHCPLease(remote_network_dhcp_lease = *lease_dst, virNetworkDHCPLea lease_dst->ipaddr =3D g_strdup(lease_src->ipaddr); =20 if (lease_src->mac) { - if (VIR_ALLOC(mac_tmp) < 0) - goto error; - *mac_tmp =3D g_strdup(lease_src->mac); + lease_dst->mac =3D g_new0(char *, 1); + *lease_dst->mac =3D g_strdup(lease_src->mac); } if (lease_src->iaid) { - if (VIR_ALLOC(iaid_tmp) < 0) - goto error; - *iaid_tmp =3D g_strdup(lease_src->iaid); + lease_dst->iaid =3D g_new0(char *, 1); + *lease_dst->iaid =3D g_strdup(lease_src->iaid); } if (lease_src->hostname) { - if (VIR_ALLOC(hostname_tmp) < 0) - goto error; - *hostname_tmp =3D g_strdup(lease_src->hostname); + lease_dst->hostname =3D g_new0(char *, 1); + *lease_dst->hostname =3D g_strdup(lease_src->hostname); } if (lease_src->clientid) { - if (VIR_ALLOC(clientid_tmp) < 0) - goto error; - *clientid_tmp =3D g_strdup(lease_src->clientid); + lease_dst->clientid =3D g_new0(char *, 1); + *lease_dst->clientid =3D g_strdup(lease_src->clientid); } =20 - lease_dst->mac =3D mac_tmp; - lease_dst->iaid =3D iaid_tmp; - lease_dst->hostname =3D hostname_tmp; - lease_dst->clientid =3D clientid_tmp; - return 0; - - error: - if (mac_tmp) - VIR_FREE(*mac_tmp); - if (iaid_tmp) - VIR_FREE(*iaid_tmp); - if (hostname_tmp) - VIR_FREE(*hostname_tmp); - if (clientid_tmp) - VIR_FREE(*clientid_tmp); - VIR_FREE(mac_tmp); - VIR_FREE(iaid_tmp); - VIR_FREE(hostname_tmp); - VIR_FREE(clientid_tmp); - VIR_FREE(lease_dst->ipaddr); - VIR_FREE(lease_dst->iface); - return -1; } =20 =20 --=20 2.26.2 From nobody Fri May 3 22:11:44 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=1602159161; cv=none; d=zohomail.com; s=zohoarc; b=I+hPI8wPmlnUM3vwcXWF44dv8mgbpI6ICn62uOTMX2Pk1NlKvSN0cwMi3Nvx6PgFv/NNXRTr6Ov2VEPD4fvdBX+d847lhG7VV/HTvxMNOC26vAztwqUL+zuo9hGS2afKjpi5BE+w2Q3YU+RysiyIjnSiTPY4VDr6Sac6L1mTItA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602159161; 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=ZmtB42rT/LwLA0jg9OR+5HgtwFfV5gpGBA5Db7g5Zdc=; b=kHdCFfut2dTvz+k/PUYmUHZAXD3KJw6aeN5ZEIjYBwbuUyPEDHezQKDGKkPTw6hcovTukAO7Peo9s/R9yC5jFlNqaI+Uq2Y+rqtWaq2icx+x+x7tMMbwnZn5nv10pOn+1zoynN1xWfdG6WYupxEPl2IAZOwhLy+wgzHYkd8lS4o= 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 1602159161611339.7687666678437; Thu, 8 Oct 2020 05:12: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-287-FKS_PXLIM-OsZLwlKVvMQA-1; Thu, 08 Oct 2020 08:12:36 -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 C8A23107B7E4; Thu, 8 Oct 2020 12:12:24 +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 5D34E190B1; Thu, 8 Oct 2020 12:12: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 354DB1832FC4; Thu, 8 Oct 2020 12:12:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 098CCK67001271 for ; Thu, 8 Oct 2020 08:12:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id F341B8246F; Thu, 8 Oct 2020 12:12:19 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E654811BF for ; Thu, 8 Oct 2020 12:12:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602159160; 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=ZmtB42rT/LwLA0jg9OR+5HgtwFfV5gpGBA5Db7g5Zdc=; b=B5Agp4w8/RvTTh7MxoRm88TbemnYLFvBw5bmJrRZfc0hxcbXLiUcIZFy3juEbj/2TWlUCo yx08EUUr/5zEriALlwKzHXv3N6yUMribvqTUnthL7TPFKkdL70KW+d/MEhphQ/6amqDL+Z Jip4Ua7j18ZxPoAetWWIJjLiXLv/Ze8= X-MC-Unique: FKS_PXLIM-OsZLwlKVvMQA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/8] libxl: xenParseXMOS: separate VIR_ALLOC call Date: Thu, 8 Oct 2020 14:12:08 +0200 Message-Id: <19b2b56f1ffa7692d787fa151927d2e8852989cc.1602158901.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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) To reduce churn in the following patches. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Pavel Hrdina --- src/libxl/xen_xm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libxl/xen_xm.c b/src/libxl/xen_xm.c index 8ade5aec1c..6d00f47544 100644 --- a/src/libxl/xen_xm.c +++ b/src/libxl/xen_xm.c @@ -42,8 +42,10 @@ xenParseXMOS(virConfPtr conf, virDomainDefPtr def) if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM) { g_autofree char *boot =3D NULL; =20 - if (VIR_ALLOC(def->os.loader) < 0 || - xenConfigCopyString(conf, "kernel", &def->os.loader->path) < 0) + if (VIR_ALLOC(def->os.loader) < 0) + return -1; + + if (xenConfigCopyString(conf, "kernel", &def->os.loader->path) < 0) return -1; =20 if (xenConfigGetString(conf, "boot", &boot, "c") < 0) --=20 2.26.2 From nobody Fri May 3 22:11:44 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=1602159183; cv=none; d=zohomail.com; s=zohoarc; b=dqXTVzlgi+1zspOMSxxkLxokiJaHu944RimxTAh5yHg+3+H9qzzXY1CKxFm07WVEc8bAL1Fe0vGi43mJh4RkiRgSVyCqea7L23mjn0ZJt/9XiHR7S66LuGwILgUhSQhrR93M3RBBKnVgYmF3NHek/PYrzu6WnbQkFxGGlXZsny0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602159183; 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=0IBu0dz4ZTS4KUomAiXscSjeIvcpjsvzB3iV6yRRGGc=; b=IjJK6/GwcPCy/7uE3m/4sBpVUZw7rekrYwq8ASU7R7hVDFxydvFlEA9uukdLWWotUmTctMaIGTkVUnGnd1lrc/lPzQR7xX08uAYAZPPCYzFrCwUHHEsB5xbFC7aPvWlVJ2YzoIxaR/y4eXQMNDyMZR+oEEjZJXtuR//1nb5aXLQ= 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 1602159183932538.0586829952279; Thu, 8 Oct 2020 05:13:03 -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-517-6e8x4XOZNbyZmAOkc2XMBg-1; Thu, 08 Oct 2020 08:12:59 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 926F8ADC4E; Thu, 8 Oct 2020 12:12:40 +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 6D04D61176; Thu, 8 Oct 2020 12:12:40 +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 318798C7BC; Thu, 8 Oct 2020 12:12:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 098CCLnS001283 for ; Thu, 8 Oct 2020 08:12:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 61BA55577D; Thu, 8 Oct 2020 12:12:21 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F04C8246F for ; Thu, 8 Oct 2020 12:12:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602159182; 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=0IBu0dz4ZTS4KUomAiXscSjeIvcpjsvzB3iV6yRRGGc=; b=QulVBdzlCf1Txe/qyiZ8q0BA9bknPC3KoX1PdHZOFWWvJOeyE6CTIIh/7omzi8xNL1Xjef ATgFx8vBHGSg9pmUTcN1CX4qVf+91B0I+57UTHAz8jyHmRioE9/OSswMvBPBEwL7kCRQlj ndAVPsBCc2M16dRQL7NDNlVixujFhhI= X-MC-Unique: 6e8x4XOZNbyZmAOkc2XMBg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 3/8] remote: use g_new0 instead of VIR_ALLOC Date: Thu, 8 Oct 2020 14:12:09 +0200 Message-Id: <575abee8056db1a3c28927d3c23962ae777943b0.1602158901.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.12 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: Pavel Hrdina --- src/remote/remote_daemon_config.c | 3 +- src/remote/remote_daemon_dispatch.c | 225 ++++++++++------------------ src/remote/remote_daemon_stream.c | 6 +- src/remote/remote_driver.c | 102 ++++--------- 4 files changed, 108 insertions(+), 228 deletions(-) diff --git a/src/remote/remote_daemon_config.c b/src/remote/remote_daemon_c= onfig.c index a09f287656..f0cca42925 100644 --- a/src/remote/remote_daemon_config.c +++ b/src/remote/remote_daemon_config.c @@ -94,8 +94,7 @@ daemonConfigNew(bool privileged G_GNUC_UNUSED) { struct daemonConfig *data; =20 - if (VIR_ALLOC(data) < 0) - return NULL; + data =3D g_new0(struct daemonConfig, 1); =20 #ifdef WITH_IP # ifdef LIBVIRTD diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index a659737bc7..90115167fb 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -1597,8 +1597,7 @@ remoteRelayDomainQemuMonitorEvent(virConnectPtr conn, data.seconds =3D seconds; data.micros =3D micros; if (details) { - if (VIR_ALLOC(data.details) < 0) - goto error; + data.details =3D g_new0(char *, 1); *(data.details) =3D g_strdup(details); } make_nonnull_domain(&data.dom, dom); @@ -1608,11 +1607,6 @@ remoteRelayDomainQemuMonitorEvent(virConnectPtr conn, (xdrproc_t)xdr_qemu_domain_monitor_event= _msg, &data); return; - - error: - xdr_free((xdrproc_t)xdr_qemu_domain_monitor_event_msg, - (char *) &data); - return; } =20 static @@ -1907,8 +1901,7 @@ void *remoteClientNew(virNetServerClientPtr client, { struct daemonClientPrivate *priv; =20 - if (VIR_ALLOC(priv) < 0) - return NULL; + priv =3D g_new0(struct daemonClientPrivate, 1); =20 if (virMutexInit(&priv->lock) < 0) { VIR_FREE(priv); @@ -2309,8 +2302,8 @@ remoteDispatchDomainGetSchedulerParameters(virNetServ= erPtr server G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"= )); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params =3D g_new0(virTypedParameter, args->nparams); nparams =3D args->nparams; =20 if (!(dom =3D get_nonnull_domain(conn, args->dom))) @@ -2357,8 +2350,8 @@ remoteDispatchDomainGetSchedulerParametersFlags(virNe= tServerPtr server G_GNUC_UN virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"= )); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params =3D g_new0(virTypedParameter, args->nparams); nparams =3D args->nparams; =20 if (!(dom =3D get_nonnull_domain(conn, args->dom))) @@ -2413,16 +2406,14 @@ remoteDispatchDomainMemoryStats(virNetServerPtr ser= ver G_GNUC_UNUSED, goto cleanup; =20 /* Allocate stats array for making dispatch call */ - if (VIR_ALLOC_N(stats, args->maxStats) < 0) - goto cleanup; + stats =3D g_new0(struct _virDomainMemoryStat, args->maxStats); =20 nr_stats =3D virDomainMemoryStats(dom, stats, args->maxStats, args->fl= ags); if (nr_stats < 0) goto cleanup; =20 /* Allocate return buffer */ - if (VIR_ALLOC_N(ret->stats.stats_val, args->maxStats) < 0) - goto cleanup; + ret->stats.stats_val =3D g_new0(remote_domain_memory_stat, args->maxSt= ats); =20 /* Copy the stats into the xdr return structure */ for (i =3D 0; i < nr_stats; i++) { @@ -2473,8 +2464,7 @@ remoteDispatchDomainBlockPeek(virNetServerPtr server = G_GNUC_UNUSED, } =20 ret->buffer.buffer_len =3D size; - if (VIR_ALLOC_N(ret->buffer.buffer_val, size) < 0) - goto cleanup; + ret->buffer.buffer_val =3D g_new0(char, size); =20 if (virDomainBlockPeek(dom, path, offset, size, ret->buffer.buffer_val, flags) < 0) @@ -2518,8 +2508,8 @@ remoteDispatchDomainBlockStatsFlags(virNetServerPtr s= erver G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"= )); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params =3D g_new0(virTypedParameter, args->nparams); nparams =3D args->nparams; =20 if (virDomainBlockStatsFlags(dom, path, params, &nparams, flags) < 0) @@ -2583,8 +2573,7 @@ remoteDispatchDomainMemoryPeek(virNetServerPtr server= G_GNUC_UNUSED, } =20 ret->buffer.buffer_len =3D size; - if (VIR_ALLOC_N(ret->buffer.buffer_val, size) < 0) - goto cleanup; + ret->buffer.buffer_val =3D g_new0(char, size); =20 if (virDomainMemoryPeek(dom, offset, size, ret->buffer.buffer_val, flags) < 0) @@ -2620,15 +2609,13 @@ remoteDispatchDomainGetSecurityLabel(virNetServerPt= r server G_GNUC_UNUSED, if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; =20 - if (VIR_ALLOC(seclabel) < 0) - goto cleanup; + seclabel =3D g_new0(virSecurityLabel, 1); =20 if (virDomainGetSecurityLabel(dom, seclabel) < 0) goto cleanup; =20 ret->label.label_len =3D strlen(seclabel->label) + 1; - if (VIR_ALLOC_N(ret->label.label_val, ret->label.label_len) < 0) - goto cleanup; + ret->label.label_val =3D g_new0(char, ret->label.label_len); strcpy(ret->label.label_val, seclabel->label); ret->enforcing =3D seclabel->enforcing; =20 @@ -2669,8 +2656,7 @@ remoteDispatchDomainGetSecurityLabelList(virNetServer= Ptr server G_GNUC_UNUSED, goto done; } =20 - if (VIR_ALLOC_N(ret->labels.labels_val, len) < 0) - goto cleanup; + ret->labels.labels_val =3D g_new0(remote_domain_get_security_label_ret= , len); =20 for (i =3D 0; i < len; i++) { size_t label_len =3D strlen(seclabels[i].label) + 1; @@ -2711,13 +2697,11 @@ remoteDispatchNodeGetSecurityModel(virNetServerPtr = server G_GNUC_UNUSED, goto cleanup; =20 ret->model.model_len =3D strlen(secmodel.model) + 1; - if (VIR_ALLOC_N(ret->model.model_val, ret->model.model_len) < 0) - goto cleanup; + ret->model.model_val =3D g_new0(char, ret->model.model_len); strcpy(ret->model.model_val, secmodel.model); =20 ret->doi.doi_len =3D strlen(secmodel.doi) + 1; - if (VIR_ALLOC_N(ret->doi.doi_val, ret->doi.doi_len) < 0) - goto cleanup; + ret->doi.doi_val =3D g_new0(char, ret->doi.doi_len); strcpy(ret->doi.doi_val, secmodel.doi); =20 rv =3D 0; @@ -2760,9 +2744,8 @@ remoteDispatchDomainGetVcpuPinInfo(virNetServerPtr se= rver G_GNUC_UNUSED, } =20 /* Allocate buffers to take the results. */ - if (args->maplen > 0 && - VIR_ALLOC_N(cpumaps, args->ncpumaps * args->maplen) < 0) - goto cleanup; + if (args->maplen > 0) + cpumaps =3D g_new0(unsigned char, args->ncpumaps * args->maplen); =20 if ((num =3D virDomainGetVcpuPinInfo(dom, args->ncpumaps, @@ -2844,9 +2827,8 @@ remoteDispatchDomainGetEmulatorPinInfo(virNetServerPt= r server G_GNUC_UNUSED, goto cleanup; =20 /* Allocate buffers to take the results */ - if (args->maplen > 0 && - VIR_ALLOC_N(cpumaps, args->maplen) < 0) - goto cleanup; + if (args->maplen > 0) + cpumaps =3D g_new0(unsigned char, args->maplen); =20 if ((r =3D virDomainGetEmulatorPinInfo(dom, cpumaps, @@ -2903,11 +2885,9 @@ remoteDispatchDomainGetVcpus(virNetServerPtr server = G_GNUC_UNUSED, } =20 /* Allocate buffers to take the results. */ - if (VIR_ALLOC_N(info, args->maxinfo) < 0) - goto cleanup; - if (args->maplen > 0 && - VIR_ALLOC_N(cpumaps, args->maxinfo * args->maplen) < 0) - goto cleanup; + info =3D g_new0(virVcpuInfo, args->maxinfo); + if (args->maplen > 0) + cpumaps =3D g_new0(unsigned char, args->maxinfo * args->maplen); =20 if ((info_len =3D virDomainGetVcpus(dom, info, args->maxinfo, @@ -2916,8 +2896,7 @@ remoteDispatchDomainGetVcpus(virNetServerPtr server G= _GNUC_UNUSED, =20 /* Allocate the return buffer for info. */ ret->info.info_len =3D info_len; - if (VIR_ALLOC_N(ret->info.info_val, info_len) < 0) - goto cleanup; + ret->info.info_val =3D g_new0(remote_vcpu_info, info_len); =20 for (i =3D 0; i < info_len; ++i) { ret->info.info_val[i].number =3D info[i].number; @@ -2980,9 +2959,7 @@ remoteDispatchDomainGetIOThreadInfo(virNetServerPtr s= erver G_GNUC_UNUSED, } =20 if (ninfo) { - if (VIR_ALLOC_N(ret->info.info_val, ninfo) < 0) - goto cleanup; - + ret->info.info_val =3D g_new0(remote_domain_iothread_info, ninfo); ret->info.info_len =3D ninfo; =20 for (i =3D 0; i < ninfo; i++) { @@ -3040,8 +3017,7 @@ remoteDispatchDomainMigratePrepare(virNetServerPtr se= rver G_GNUC_UNUSED, dname =3D args->dname =3D=3D NULL ? NULL : *args->dname; =20 /* Wacky world of XDR ... */ - if (VIR_ALLOC(uri_out) < 0) - goto cleanup; + uri_out =3D g_new0(char *, 1); =20 if (virDomainMigratePrepare(conn, &cookie, &cookielen, uri_in, uri_out, @@ -3092,8 +3068,7 @@ remoteDispatchDomainMigratePrepare2(virNetServerPtr s= erver G_GNUC_UNUSED, dname =3D args->dname =3D=3D NULL ? NULL : *args->dname; =20 /* Wacky world of XDR ... */ - if (VIR_ALLOC(uri_out) < 0) - goto cleanup; + uri_out =3D g_new0(char *, 1); =20 if (virDomainMigratePrepare2(conn, &cookie, &cookielen, uri_in, uri_out, @@ -3142,8 +3117,8 @@ remoteDispatchDomainGetMemoryParameters(virNetServerP= tr server G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"= )); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params =3D g_new0(virTypedParameter, args->nparams); nparams =3D args->nparams; =20 if (!(dom =3D get_nonnull_domain(conn, args->dom))) @@ -3202,8 +3177,8 @@ remoteDispatchDomainGetNumaParameters(virNetServerPtr= server G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"= )); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params =3D g_new0(virTypedParameter, args->nparams); nparams =3D args->nparams; =20 if (!(dom =3D get_nonnull_domain(conn, args->dom))) @@ -3262,8 +3237,8 @@ remoteDispatchDomainGetBlkioParameters(virNetServerPt= r server G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"= )); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params =3D g_new0(virTypedParameter, args->nparams); nparams =3D args->nparams; =20 if (!(dom =3D get_nonnull_domain(conn, args->dom))) @@ -3323,8 +3298,8 @@ remoteDispatchNodeGetCPUStats(virNetServerPtr server = G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"= )); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params =3D g_new0(virNodeCPUStats, args->nparams); nparams =3D args->nparams; =20 if (virNodeGetCPUStats(conn, cpuNum, params, &nparams, flags) < 0) @@ -3340,8 +3315,7 @@ remoteDispatchNodeGetCPUStats(virNetServerPtr server = G_GNUC_UNUSED, =20 /* Serialise the memory parameters. */ ret->params.params_len =3D nparams; - if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0) - goto cleanup; + ret->params.params_val =3D g_new0(remote_node_get_cpu_stats, nparams); =20 for (i =3D 0; i < nparams; ++i) { /* remoteDispatchClientRequest will free this: */ @@ -3391,8 +3365,8 @@ remoteDispatchNodeGetMemoryStats(virNetServerPtr serv= er G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"= )); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params =3D g_new0(virNodeMemoryStats, args->nparams); nparams =3D args->nparams; =20 if (virNodeGetMemoryStats(conn, cellNum, params, &nparams, flags) < 0) @@ -3408,8 +3382,7 @@ remoteDispatchNodeGetMemoryStats(virNetServerPtr serv= er G_GNUC_UNUSED, =20 /* Serialise the memory parameters. */ ret->params.params_len =3D nparams; - if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0) - goto cleanup; + ret->params.params_val =3D g_new0(remote_node_get_memory_stats, nparam= s); =20 for (i =3D 0; i < nparams; ++i) { /* remoteDispatchClientRequest will free this: */ @@ -3573,8 +3546,8 @@ remoteDispatchDomainGetBlockIoTune(virNetServerPtr se= rver G_GNUC_UNUSED, goto cleanup; } =20 - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params =3D g_new0(virTypedParameter, args->nparams); nparams =3D args->nparams; =20 if (!(dom =3D get_nonnull_domain(conn, args->dom))) @@ -3649,8 +3622,7 @@ remoteDispatchAuthList(virNetServerPtr server, } =20 ret->types.types_len =3D 1; - if (VIR_ALLOC_N(ret->types.types_val, ret->types.types_len) < 0) - goto cleanup; + ret->types.types_val =3D g_new0(remote_auth_type, ret->types.types_len= ); =20 switch ((virNetServerServiceAuthMethods) auth) { case VIR_NET_SERVER_SERVICE_AUTH_NONE: @@ -3666,7 +3638,6 @@ remoteDispatchAuthList(virNetServerPtr server, =20 rv =3D 0; =20 - cleanup: if (rv < 0) virNetMessageSaveError(rerr); return rv; @@ -3846,8 +3817,7 @@ remoteDispatchAuthSaslStart(virNetServerPtr server, =20 /* NB, distinction of NULL vs "" is *critical* in SASL */ if (serverout) { - if (VIR_ALLOC_N(ret->data.data_val, serveroutlen) < 0) - goto authfail; + ret->data.data_val =3D g_new0(char, serveroutlen); memcpy(ret->data.data_val, serverout, serveroutlen); } else { ret->data.data_val =3D NULL; @@ -3942,8 +3912,7 @@ remoteDispatchAuthSaslStep(virNetServerPtr server, =20 /* NB, distinction of NULL vs "" is *critical* in SASL */ if (serverout) { - if (VIR_ALLOC_N(ret->data.data_val, serveroutlen) < 0) - goto authfail; + ret->data.data_val =3D g_new0(char, serveroutlen); memcpy(ret->data.data_val, serverout, serveroutlen); } else { ret->data.data_val =3D NULL; @@ -4147,8 +4116,7 @@ remoteDispatchNodeDeviceGetParent(virNetServerPtr ser= ver G_GNUC_UNUSED, ret->parentName =3D NULL; } else { /* remoteDispatchClientRequest will free this. */ - if (VIR_ALLOC(ret->parentName) < 0) - goto cleanup; + ret->parentName =3D g_new0(char *, 1); *(ret->parentName) =3D g_strdup(parent); } =20 @@ -4250,8 +4218,7 @@ remoteDispatchConnectDomainEventRegister(virNetServer= Ptr server G_GNUC_UNUSED, * clearing 'callback' and having to juggle the pointer * between 'ref' and 'callback'. */ - if (VIR_ALLOC(callback) < 0) - goto cleanup; + callback =3D g_new0(daemonClientEventCallback, 1); callback->client =3D virObjectRef(client); callback->program =3D virObjectRef(remoteProgram); callback->eventID =3D VIR_DOMAIN_EVENT_ID_LIFECYCLE; @@ -4479,8 +4446,7 @@ remoteDispatchConnectDomainEventRegisterAny(virNetSer= verPtr server G_GNUC_UNUSED * incomplete callback to our array, then register, then fix up * our callback; but since VIR_APPEND_ELEMENT clears 'callback' on * success, we use 'ref' to save a copy of the pointer. */ - if (VIR_ALLOC(callback) < 0) - goto cleanup; + callback =3D g_new0(daemonClientEventCallback, 1); callback->client =3D virObjectRef(client); callback->program =3D virObjectRef(remoteProgram); callback->eventID =3D args->eventID; @@ -4555,8 +4521,7 @@ remoteDispatchConnectDomainEventCallbackRegisterAny(v= irNetServerPtr server G_GNU * incomplete callback to our array, then register, then fix up * our callback; but since VIR_APPEND_ELEMENT clears 'callback' on * success, we use 'ref' to save a copy of the pointer. */ - if (VIR_ALLOC(callback) < 0) - goto cleanup; + callback =3D g_new0(daemonClientEventCallback, 1); callback->client =3D virObjectRef(client); callback->program =3D virObjectRef(remoteProgram); callback->eventID =3D args->eventID; @@ -4799,8 +4764,7 @@ remoteDispatchDomainMigratePrepare3(virNetServerPtr s= erver G_GNUC_UNUSED, dname =3D args->dname =3D=3D NULL ? NULL : *args->dname; =20 /* Wacky world of XDR ... */ - if (VIR_ALLOC(uri_out) < 0) - goto cleanup; + uri_out =3D g_new0(char *, 1); =20 if (virDomainMigratePrepare3(conn, args->cookie_in.cookie_in_val, @@ -5130,8 +5094,8 @@ remoteDispatchDomainGetInterfaceParameters(virNetServ= erPtr server G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"= )); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params =3D g_new0(virTypedParameter, args->nparams); nparams =3D args->nparams; =20 if (!(dom =3D get_nonnull_domain(conn, args->dom))) @@ -5192,9 +5156,8 @@ remoteDispatchDomainGetCPUStats(virNetServerPtr serve= r G_GNUC_UNUSED, goto cleanup; } =20 - if (args->nparams > 0 && - VIR_ALLOC_N(params, args->ncpus * args->nparams) < 0) - goto cleanup; + if (args->nparams > 0) + params =3D g_new0(virTypedParameter, args->ncpus * args->nparams); =20 if (!(dom =3D get_nonnull_domain(conn, args->dom))) goto cleanup; @@ -5261,9 +5224,8 @@ remoteDispatchDomainGetDiskErrors(virNetServerPtr ser= ver G_GNUC_UNUSED, goto cleanup; } =20 - if (args->maxerrors && - VIR_ALLOC_N(errors, args->maxerrors) < 0) - goto cleanup; + if (args->maxerrors) + errors =3D g_new0(virDomainDiskError, args->maxerrors); =20 if ((len =3D virDomainGetDiskErrors(dom, errors, args->maxerrors, @@ -5352,8 +5314,8 @@ remoteDispatchNodeGetMemoryParameters(virNetServerPtr= server G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"= )); goto cleanup; } - if (args->nparams && VIR_ALLOC_N(params, args->nparams) < 0) - goto cleanup; + if (args->nparams) + params =3D g_new0(virTypedParameter, args->nparams); nparams =3D args->nparams; =20 if (virNodeGetMemoryParameters(conn, params, &nparams, flags) < 0) @@ -5602,8 +5564,7 @@ remoteDispatchDomainMigratePrepare3Params(virNetServe= rPtr server G_GNUC_UNUSED, goto cleanup; =20 /* Wacky world of XDR ... */ - if (VIR_ALLOC(uri_out) < 0) - goto cleanup; + uri_out =3D g_new0(char *, 1); =20 if (virDomainMigratePrepare3Params(conn, params, nparams, args->cookie_in.cookie_in_val, @@ -5924,8 +5885,7 @@ remoteDispatchDomainCreateXMLWithFiles(virNetServerPt= r server G_GNUC_UNUSED, if (!conn) goto cleanup; =20 - if (VIR_ALLOC_N(files, msg->nfds) < 0) - goto cleanup; + files =3D g_new0(int, msg->nfds); for (i =3D 0; i < msg->nfds; i++) { if ((files[i] =3D virNetMessageDupFD(msg, i)) < 0) goto cleanup; @@ -5969,8 +5929,7 @@ static int remoteDispatchDomainCreateWithFiles(virNet= ServerPtr server G_GNUC_UNU if (!conn) goto cleanup; =20 - if (VIR_ALLOC_N(files, msg->nfds) < 0) - goto cleanup; + files =3D g_new0(int, msg->nfds); for (i =3D 0; i < msg->nfds; i++) { if ((files[i] =3D virNetMessageDupFD(msg, i)) < 0) goto cleanup; @@ -6038,8 +5997,7 @@ remoteDispatchConnectNetworkEventRegisterAny(virNetSe= rverPtr server G_GNUC_UNUSE * incomplete callback to our array, then register, then fix up * our callback; but since VIR_APPEND_ELEMENT clears 'callback' on * success, we use 'ref' to save a copy of the pointer. */ - if (VIR_ALLOC(callback) < 0) - goto cleanup; + callback =3D g_new0(daemonClientEventCallback, 1); callback->client =3D virObjectRef(client); callback->program =3D virObjectRef(remoteProgram); callback->eventID =3D args->eventID; @@ -6159,8 +6117,7 @@ remoteDispatchConnectStoragePoolEventRegisterAny(virN= etServerPtr server G_GNUC_U * incomplete callback to our array, then register, then fix up * our callback; but since VIR_APPEND_ELEMENT clears 'callback' on * success, we use 'ref' to save a copy of the pointer. */ - if (VIR_ALLOC(callback) < 0) - goto cleanup; + callback =3D g_new0(daemonClientEventCallback, 1); callback->client =3D virObjectRef(client); callback->program =3D virObjectRef(remoteProgram); callback->eventID =3D args->eventID; @@ -6279,8 +6236,7 @@ remoteDispatchConnectNodeDeviceEventRegisterAny(virNe= tServerPtr server G_GNUC_UN * incomplete callback to our array, then register, then fix up * our callback; but since VIR_APPEND_ELEMENT clears 'callback' on * success, we use 'ref' to save a copy of the pointer. */ - if (VIR_ALLOC(callback) < 0) - goto cleanup; + callback =3D g_new0(daemonClientEventCallback, 1); callback->client =3D virObjectRef(client); callback->program =3D virObjectRef(remoteProgram); callback->eventID =3D args->eventID; @@ -6399,8 +6355,7 @@ remoteDispatchConnectSecretEventRegisterAny(virNetSer= verPtr server G_GNUC_UNUSED * incomplete callback to our array, then register, then fix up * our callback; but since VIR_APPEND_ELEMENT clears 'callback' on * success, we use 'ref' to save a copy of the pointer. */ - if (VIR_ALLOC(callback) < 0) - goto cleanup; + callback =3D g_new0(daemonClientEventCallback, 1); callback->client =3D virObjectRef(client); callback->program =3D virObjectRef(remoteProgram); callback->eventID =3D args->eventID; @@ -6514,8 +6469,7 @@ qemuDispatchConnectDomainMonitorEventRegister(virNetS= erverPtr server G_GNUC_UNUS * incomplete callback to our array, then register, then fix up * our callback; but since VIR_APPEND_ELEMENT clears 'callback' on * success, we use 'ref' to save a copy of the pointer. */ - if (VIR_ALLOC(callback) < 0) - goto cleanup; + callback =3D g_new0(daemonClientEventCallback, 1); callback->client =3D virObjectRef(client); callback->program =3D virObjectRef(qemuProgram); callback->eventID =3D -1; @@ -6656,9 +6610,8 @@ remoteDispatchNodeGetFreePages(virNetServerPtr server= G_GNUC_UNUSED, } =20 /* Allocate return buffer. */ - if (VIR_ALLOC_N(ret->counts.counts_val, - args->pages.pages_len * args->cellCount) < 0) - goto cleanup; + ret->counts.counts_val =3D g_new0(uint64_t, + args->pages.pages_len * args->cellCoun= t); =20 if ((len =3D virNodeGetFreePages(conn, args->pages.pages_len, @@ -6747,9 +6700,7 @@ remoteDispatchNetworkGetDHCPLeases(virNetServerPtr se= rver G_GNUC_UNUSED, } =20 if (leases && nleases) { - if (VIR_ALLOC_N(ret->leases.leases_val, nleases) < 0) - goto cleanup; - + ret->leases.leases_val =3D g_new0(remote_network_dhcp_lease, nleas= es); ret->leases.leases_len =3D nleases; =20 for (i =3D 0; i < nleases; i++) { @@ -6797,8 +6748,7 @@ remoteDispatchConnectGetAllDomainStats(virNetServerPt= r server G_GNUC_UNUSED, goto cleanup; =20 if (args->doms.doms_len) { - if (VIR_ALLOC_N(doms, args->doms.doms_len + 1) < 0) - goto cleanup; + doms =3D g_new0(virDomainPtr, args->doms.doms_len + 1); =20 for (i =3D 0; i < args->doms.doms_len; i++) { if (!(doms[i] =3D get_nonnull_domain(conn, args->doms.doms_val= [i]))) @@ -6827,9 +6777,7 @@ remoteDispatchConnectGetAllDomainStats(virNetServerPt= r server G_GNUC_UNUSED, goto cleanup; } =20 - if (VIR_ALLOC_N(ret->retStats.retStats_val, nrecords) < 0) - goto cleanup; - + ret->retStats.retStats_val =3D g_new0(remote_domain_stats_record, = nrecords); ret->retStats.retStats_len =3D nrecords; =20 for (i =3D 0; i < nrecords; i++) { @@ -6934,9 +6882,7 @@ remoteDispatchDomainGetFSInfo(virNetServerPtr server = G_GNUC_UNUSED, } =20 if (ninfo) { - if (VIR_ALLOC_N(ret->info.info_val, ninfo) < 0) - goto cleanup; - + ret->info.info_val =3D g_new0(remote_domain_fsinfo, ninfo); ret->info.info_len =3D ninfo; =20 for (i =3D 0; i < ninfo; i++) { @@ -6956,8 +6902,7 @@ remoteDispatchDomainGetFSInfo(virNetServerPtr server = G_GNUC_UNUSED, } =20 if (ndisk > 0) { - if (VIR_ALLOC_N(dst->dev_aliases.dev_aliases_val, ndisk) <= 0) - goto cleanup; + dst->dev_aliases.dev_aliases_val =3D g_new0(char *, ndisk); =20 for (j =3D 0; j < ndisk; j++) dst->dev_aliases.dev_aliases_val[j] =3D g_strdup(info[= i]->devAlias[j]); @@ -7019,9 +6964,7 @@ remoteSerializeDomainInterface(virDomainInterfacePtr = *ifaces, return -1; } =20 - if (VIR_ALLOC_N(ret->ifaces.ifaces_val, ifaces_count) < 0) - return -1; - + ret->ifaces.ifaces_val =3D g_new0(remote_domain_interface, ifaces_coun= t); ret->ifaces.ifaces_len =3D ifaces_count; =20 for (i =3D 0; i < ifaces_count; i++) { @@ -7031,8 +6974,7 @@ remoteSerializeDomainInterface(virDomainInterfacePtr = *ifaces, iface_ret->name =3D g_strdup(iface->name); =20 if (iface->hwaddr) { - if (VIR_ALLOC(iface_ret->hwaddr) < 0) - goto cleanup; + iface_ret->hwaddr =3D g_new0(char *, 1); *iface_ret->hwaddr =3D g_strdup(iface->hwaddr); } =20 @@ -7043,10 +6985,7 @@ remoteSerializeDomainInterface(virDomainInterfacePtr= *ifaces, goto cleanup; } =20 - if (VIR_ALLOC_N(iface_ret->addrs.addrs_val, - iface->naddrs) < 0) - goto cleanup; - + iface_ret->addrs.addrs_val =3D g_new0(remote_domain_ip_addr, iface= ->naddrs); iface_ret->addrs.addrs_len =3D iface->naddrs; =20 for (j =3D 0; j < iface->naddrs; j++) { @@ -7362,8 +7301,7 @@ remoteSerializeDomainDiskErrors(virDomainDiskErrorPtr= errors, remote_domain_disk_error *val =3D NULL; size_t i =3D 0; =20 - if (VIR_ALLOC_N(val, nerrors) < 0) - goto error; + val =3D g_new0(remote_domain_disk_error, nerrors); =20 for (i =3D 0; i < nerrors; i++) { val[i].disk =3D g_strdup(errors[i].disk); @@ -7374,15 +7312,6 @@ remoteSerializeDomainDiskErrors(virDomainDiskErrorPt= r errors, *ret_errors_val =3D val; =20 return 0; - - error: - if (val) { - size_t j; - for (j =3D 0; j < i; j++) - VIR_FREE(val[j].disk); - VIR_FREE(val); - } - return -1; } =20 static int diff --git a/src/remote/remote_daemon_stream.c b/src/remote/remote_daemon_s= tream.c index 9a62189cd6..b4a3cb6741 100644 --- a/src/remote/remote_daemon_stream.c +++ b/src/remote/remote_daemon_stream.c @@ -362,8 +362,7 @@ daemonCreateClientStream(virNetServerClientPtr client, VIR_DEBUG("client=3D%p, proc=3D%d, serial=3D%u, st=3D%p", client, header->proc, header->serial, st); =20 - if (VIR_ALLOC(stream) < 0) - return NULL; + stream =3D g_new0(daemonClientStream, 1); =20 stream->refs =3D 1; stream->priv =3D priv; @@ -853,8 +852,7 @@ daemonStreamHandleRead(virNetServerClientPtr client, =20 memset(&rerr, 0, sizeof(rerr)); =20 - if (VIR_ALLOC_N(buffer, bufferLen) < 0) - return -1; + buffer =3D g_new0(char, bufferLen); =20 if (!(msg =3D virNetMessageNew(false))) goto cleanup; diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 6e0c04f168..49769ac04d 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -1207,8 +1207,7 @@ static struct private_data * remoteAllocPrivateData(void) { struct private_data *priv; - if (VIR_ALLOC(priv) < 0) - return NULL; + priv =3D g_new0(struct private_data, 1); =20 if (virMutexInit(&priv->lock) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -2271,18 +2270,15 @@ remoteDomainGetIOThreadInfo(virDomainPtr dom, goto cleanup; } =20 - if (VIR_ALLOC_N(info_ret, ret.info.info_len) < 0) - goto cleanup; + info_ret =3D g_new0(virDomainIOThreadInfoPtr, ret.info.info_len); =20 for (i =3D 0; i < ret.info.info_len; i++) { src =3D &ret.info.info_val[i]; =20 - if (VIR_ALLOC(info_ret[i]) < 0) - goto cleanup; + info_ret[i] =3D g_new0(virDomainIOThreadInfo, 1); =20 info_ret[i]->iothread_id =3D src->iothread_id; - if (VIR_ALLOC_N(info_ret[i]->cpumap, src->cpumap.cpumap_len) <= 0) - goto cleanup; + info_ret[i]->cpumap =3D g_new0(unsigned char, src->cpumap.cpum= ap_len); memcpy(info_ret[i]->cpumap, src->cpumap.cpumap_val, src->cpumap.cpumap_len); info_ret[i]->cpumaplen =3D src->cpumap.cpumap_len; @@ -2367,8 +2363,7 @@ remoteDomainGetSecurityLabelList(virDomainPtr domain,= virSecurityLabelPtr* secla goto done; } =20 - if (VIR_ALLOC_N(*seclabels, ret.labels.labels_len) < 0) - goto cleanup; + *seclabels =3D g_new0(virSecurityLabel, ret.labels.labels_len); =20 for (i =3D 0; i < ret.labels.labels_len; i++) { remote_domain_get_security_label_ret *cur =3D &ret.labels.labels_v= al[i]; @@ -3766,8 +3761,7 @@ static sasl_callback_t *remoteAuthMakeCallbacks(int *= credtype, int ncredtype) sasl_callback_t *cbs; size_t i; int n; - if (VIR_ALLOC_N(cbs, ncredtype+1) < 0) - return NULL; + cbs =3D g_new0(sasl_callback_t, ncredtype + 1); =20 for (i =3D 0, n =3D 0; i < ncredtype; i++) { int id =3D remoteAuthCredVir2SASL(credtype[i]); @@ -3804,8 +3798,7 @@ static int remoteAuthMakeCredentials(sasl_interact_t = *interact, (*ncred)++; } =20 - if (VIR_ALLOC_N(*cred, *ncred) < 0) - return -1; + *cred =3D g_new0(virConnectCredential, *ncred); =20 for (ninteract =3D 0, *ncred =3D 0; interact[ninteract].id !=3D 0; nin= teract++) { if (interact[ninteract].result) @@ -4665,22 +4658,18 @@ remoteDomainBuildEventGraphicsHelper(virConnectPtr = conn, if (!dom) return; =20 - if (VIR_ALLOC(localAddr) < 0) - goto error; + localAddr =3D g_new0(virDomainEventGraphicsAddress, 1); localAddr->family =3D msg->local.family; localAddr->service =3D g_strdup(msg->local.service); localAddr->node =3D g_strdup(msg->local.node); =20 - if (VIR_ALLOC(remoteAddr) < 0) - goto error; + remoteAddr =3D g_new0(virDomainEventGraphicsAddress, 1); remoteAddr->family =3D msg->remote.family; remoteAddr->service =3D g_strdup(msg->remote.service); remoteAddr->node =3D g_strdup(msg->remote.node); =20 - if (VIR_ALLOC(subject) < 0) - goto error; - if (VIR_ALLOC_N(subject->identities, msg->subject.subject_len) < 0) - goto error; + subject =3D g_new0(virDomainEventGraphicsSubject, 1); + subject->identities =3D g_new0(virDomainEventGraphicsSubjectIdentity, = msg->subject.subject_len); subject->nidentity =3D msg->subject.subject_len; for (i =3D 0; i < subject->nidentity; i++) { subject->identities[i].type =3D g_strdup(msg->subject.subject_val[= i].type); @@ -4698,28 +4687,6 @@ remoteDomainBuildEventGraphicsHelper(virConnectPtr c= onn, =20 virObjectEventStateQueueRemote(priv->eventState, event, callbackID); return; - - error: - if (localAddr) { - VIR_FREE(localAddr->service); - VIR_FREE(localAddr->node); - VIR_FREE(localAddr); - } - if (remoteAddr) { - VIR_FREE(remoteAddr->service); - VIR_FREE(remoteAddr->node); - VIR_FREE(remoteAddr); - } - if (subject) { - for (i =3D 0; i < subject->nidentity; i++) { - VIR_FREE(subject->identities[i].type); - VIR_FREE(subject->identities[i].name); - } - VIR_FREE(subject->identities); - VIR_FREE(subject); - } - virObjectUnref(dom); - return; } static void remoteDomainBuildEventGraphics(virNetClientProgramPtr prog G_GNUC_UNUSED, @@ -5640,8 +5607,7 @@ remoteStreamEventAddCallback(virStreamPtr st, int ret =3D -1; struct remoteStreamCallbackData *cbdata; =20 - if (VIR_ALLOC(cbdata) < 0) - return -1; + cbdata =3D g_new0(struct remoteStreamCallbackData, 1); cbdata->cb =3D cb; cbdata->opaque =3D opaque; cbdata->ff =3D ff; @@ -6304,8 +6270,7 @@ remoteConnectGetCPUModelNames(virConnectPtr conn, } =20 if (models) { - if (VIR_ALLOC_N(retmodels, ret.models.models_len + 1) < 0) - goto cleanup; + retmodels =3D g_new0(char *, ret.models.models_len + 1); =20 for (i =3D 0; i < ret.models.models_len; i++) { retmodels[i] =3D ret.models.models_val[i]; @@ -6738,8 +6703,7 @@ remoteNodeGetCPUMap(virConnectPtr conn, goto cleanup; =20 if (cpumap) { - if (VIR_ALLOC_N(*cpumap, ret.cpumap.cpumap_len) < 0) - goto cleanup; + *cpumap =3D g_new0(unsigned char, ret.cpumap.cpumap_len); memcpy(*cpumap, ret.cpumap.cpumap_val, ret.cpumap.cpumap_len); } =20 @@ -7467,13 +7431,11 @@ remoteNetworkGetDHCPLeases(virNetworkPtr net, } =20 if (leases) { - if (ret.leases.leases_len && - VIR_ALLOC_N(leases_ret, ret.leases.leases_len + 1) < 0) - goto cleanup; + if (ret.leases.leases_len) + leases_ret =3D g_new0(virNetworkDHCPLeasePtr, ret.leases.lease= s_len + 1); =20 for (i =3D 0; i < ret.leases.leases_len; i++) { - if (VIR_ALLOC(leases_ret[i]) < 0) - goto cleanup; + leases_ret[i] =3D g_new0(virNetworkDHCPLease, 1); =20 if (remoteSerializeDHCPLease(leases_ret[i], &ret.leases.leases= _val[i]) < 0) goto cleanup; @@ -7519,8 +7481,7 @@ remoteConnectGetAllDomainStats(virConnectPtr conn, memset(&args, 0, sizeof(args)); =20 if (ndoms) { - if (VIR_ALLOC_N(args.doms.doms_val, ndoms) < 0) - goto cleanup; + args.doms.doms_val =3D g_new0(remote_nonnull_domain, ndoms); =20 for (i =3D 0; i < ndoms; i++) make_nonnull_domain(args.doms.doms_val + i, doms[i]); @@ -7550,14 +7511,12 @@ remoteConnectGetAllDomainStats(virConnectPtr conn, =20 *retStats =3D NULL; =20 - if (VIR_ALLOC_N(tmpret, ret.retStats.retStats_len + 1) < 0) - goto cleanup; + tmpret =3D g_new0(virDomainStatsRecordPtr, ret.retStats.retStats_len += 1); =20 for (i =3D 0; i < ret.retStats.retStats_len; i++) { remote_domain_stats_record *rec =3D ret.retStats.retStats_val + i; =20 - if (VIR_ALLOC(elem) < 0) - goto cleanup; + elem =3D g_new0(virDomainStatsRecord, 1); =20 if (!(elem->dom =3D get_nonnull_domain(conn, rec->dom))) goto cleanup; @@ -7676,14 +7635,13 @@ remoteDomainGetFSInfo(virDomainPtr dom, goto cleanup; } =20 - if (VIR_ALLOC_N(info_ret, ret.info.info_len) < 0) + info_ret =3D g_new0(virDomainFSInfoPtr, ret.info.info_len); goto cleanup; =20 for (i =3D 0; i < ret.info.info_len; i++) { src =3D &ret.info.info_val[i]; =20 - if (VIR_ALLOC(info_ret[i]) < 0) - goto cleanup; + info_ret[i] =3D g_new0(virDomainFSInfo, 1); =20 info_ret[i]->mountpoint =3D g_strdup(src->mountpoint); =20 @@ -7693,9 +7651,8 @@ remoteDomainGetFSInfo(virDomainPtr dom, =20 len =3D src->dev_aliases.dev_aliases_len; info_ret[i]->ndevAlias =3D len; - if (len && - VIR_ALLOC_N(info_ret[i]->devAlias, len) < 0) - goto cleanup; + if (len) + info_ret[i]->devAlias =3D g_new0(char *, len); =20 for (j =3D 0; j < len; j++) info_ret[i]->devAlias[j] =3D g_strdup(src->dev_aliases.dev= _aliases_val[j]); @@ -7760,16 +7717,14 @@ remoteDomainInterfaceAddresses(virDomainPtr dom, goto cleanup; } =20 - if (ret.ifaces.ifaces_len && - VIR_ALLOC_N(ifaces_ret, ret.ifaces.ifaces_len) < 0) - goto cleanup; + if (ret.ifaces.ifaces_len) + ifaces_ret =3D g_new0(virDomainInterfacePtr, ret.ifaces.ifaces_len= ); =20 for (i =3D 0; i < ret.ifaces.ifaces_len; i++) { virDomainInterfacePtr iface; remote_domain_interface *iface_ret =3D &(ret.ifaces.ifaces_val[i]); =20 - if (VIR_ALLOC(ifaces_ret[i]) < 0) - goto cleanup; + ifaces_ret[i] =3D g_new0(virDomainInterface, 1); =20 iface =3D ifaces_ret[i]; =20 @@ -7788,8 +7743,7 @@ remoteDomainInterfaceAddresses(virDomainPtr dom, iface->naddrs =3D iface_ret->addrs.addrs_len; =20 if (iface->naddrs) { - if (VIR_ALLOC_N(iface->addrs, iface->naddrs) < 0) - goto cleanup; + iface->addrs =3D g_new0(virDomainIPAddress, iface->naddrs); =20 for (j =3D 0; j < iface->naddrs; j++) { virDomainIPAddressPtr ip_addr =3D &(iface->addrs[j]); --=20 2.26.2 From nobody Fri May 3 22:11:44 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=1602159164; cv=none; d=zohomail.com; s=zohoarc; b=n/sjokiomYFXwYim45TJFSnFMHgKzDLXPR/OVMTeDRX4HYWBLVeZHfQJQnVtCqLy+KW1vTRdZ82l/xXzElqdC1Y2oaQHVA3nPTnC0YSNJOB712MyXki3NgsALLJSwM/UesV2uunINCg37kJPXpBe/ERJvU9ctgaa238xBNNpMuA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602159164; 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=DoeiykO8JJiw4w5B9ue1iRZjXLxn7H2SREYM8B7QWVY=; b=ObgCSxwpIrETiTxAugTQiZMBVZeoS4HdXSRv1hXrlHec1BcFWZGycIAEzRmgqLECztAyPpX/mMp3WRUZEzC1zwkhxwvdpvBSDLQCDQU4l1WpCZOQuDxLEpG9QbLEl99Vtp6lcmjwmIncR0UzkM5IPQZ8ChK4ua+9IMJGwHvamu0= 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 1602159164374375.2644091637403; Thu, 8 Oct 2020 05:12:44 -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-31-sKSWf0rvMR6hiQltAnyQew-1; Thu, 08 Oct 2020 08:12:39 -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 328FB879528; Thu, 8 Oct 2020 12:12:25 +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 9500229678; Thu, 8 Oct 2020 12:12: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 E8A1E8C7BB; Thu, 8 Oct 2020 12:12:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 098CCM6d001293 for ; Thu, 8 Oct 2020 08:12:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6ACB255764; Thu, 8 Oct 2020 12:12:22 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7ED15577D for ; Thu, 8 Oct 2020 12:12:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602159163; 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=DoeiykO8JJiw4w5B9ue1iRZjXLxn7H2SREYM8B7QWVY=; b=UM+nyepnGaAjFzNQ8RwgQtVZmTMVEb/oPdUSOm4e8/ZoPxozD5RDd9e8FACRuJTAW7VcrQ QufHHCtdv0BhFlaHDa94nevxkwHM8Gf2I1z337laExM7tpxXSfjoPTOmMUvJ8MC7ygBx4R G/FxyYHLxAbHonKaPK0uxJycHb5mrnY= X-MC-Unique: sKSWf0rvMR6hiQltAnyQew-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 4/8] remote: remoteDispatchAuthList: remove useless 'rv' Date: Thu, 8 Oct 2020 14:12:10 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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: Pavel Hrdina --- src/remote/remote_daemon_dispatch.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index 90115167fb..b8813611c8 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -3593,7 +3593,6 @@ remoteDispatchAuthList(virNetServerPtr server, virNetMessageErrorPtr rerr, remote_auth_list_ret *ret) { - int rv =3D -1; int auth =3D virNetServerClientGetAuth(client); uid_t callerUid; gid_t callerGid; @@ -3636,11 +3635,7 @@ remoteDispatchAuthList(virNetServerPtr server, break; } =20 - rv =3D 0; - - if (rv < 0) - virNetMessageSaveError(rerr); - return rv; + return 0; } =20 =20 --=20 2.26.2 From nobody Fri May 3 22:11:44 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=1602159308; cv=none; d=zohomail.com; s=zohoarc; b=QMwBpIbp+gX0yh2sTF0JjC4LnPItxvuZowT8DN3cje+vabz1lmkcIOps18b9s7iZy2AqTyNctjL6hPCpaKlDGzlCfa45TXhKDLDTAM5HLVEAnaqpGG7hTBgX0HgqxU3TaMlgATpS+2MRPvENFnX2M/vxDXFXkp8Ghr1war20sIA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602159308; 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=hXlRvCcprvEl2nm9DwqrYji3tXiBRwJZTWQ3A/M5ilY=; b=eDJbGOvSV76e8oigHesqjMFh+X3qtoCxykNfsmTB0CPDIdwC4WepYfGgjZC54WK3ZUQHcfd31LSF1s2QbwpGj/YA41YKywkbiKRN69yRzF4PphRYZaNaT/0XFY7kDBVfODdEAcYzjcNQPXBwQHpBKhjpWV7wZfGljJyM0Uq5c+U= 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 1602159308469249.96300618891144; Thu, 8 Oct 2020 05:15:08 -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-271-tik9FR-8Mt20F4spTukH2A-1; Thu, 08 Oct 2020 08:12:57 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3024C1017DC5; Thu, 8 Oct 2020 12:12:40 +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 0B20350B44; Thu, 8 Oct 2020 12:12:40 +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 CBF8D8C7BC; Thu, 8 Oct 2020 12:12:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 098CCNga001302 for ; Thu, 8 Oct 2020 08:12:23 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6D7E25576D; Thu, 8 Oct 2020 12:12:23 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id CC01155764 for ; Thu, 8 Oct 2020 12:12:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602159307; 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=hXlRvCcprvEl2nm9DwqrYji3tXiBRwJZTWQ3A/M5ilY=; b=EkPKYljuv+GSUVYy9W8XnR1FgkN0yuV9bc2oHvaLvqXxEwwJVF6136apU90qx9IRn0pY15 87ZQ1G9ug0lr0FC1rtBUkv/h8BBm39v5H5IO2PWZkNJf71tp6sWB15H6CfBIamwATWTPC1 tyeUp1ZWLPtOLMHSVbLbNCi0qPKL+cA= X-MC-Unique: tik9FR-8Mt20F4spTukH2A-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 5/8] src: use g_new0 instead of VIR_ALLOC Date: Thu, 8 Oct 2020 14:12:11 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.11 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: Pavel Hrdina --- src/access/viraccessmanager.c | 3 +- src/admin/admin_server_dispatch.c | 6 +-- src/hypervisor/domain_driver.c | 3 +- src/hypervisor/virclosecallbacks.c | 7 +--- src/libxl/xen_xm.c | 7 +--- src/test/test_driver.c | 66 +++++++++++------------------- 6 files changed, 32 insertions(+), 60 deletions(-) diff --git a/src/access/viraccessmanager.c b/src/access/viraccessmanager.c index e2ceeca57f..02e4464ef5 100644 --- a/src/access/viraccessmanager.c +++ b/src/access/viraccessmanager.c @@ -91,8 +91,7 @@ static virAccessManagerPtr virAccessManagerNewDriver(virA= ccessDriverPtr drv) if (virAccessManagerInitialize() < 0) return NULL; =20 - if (VIR_ALLOC_N(privateData, drv->privateDataLen) < 0) - return NULL; + privateData =3D g_new0(char, drv->privateDataLen); =20 if (!(mgr =3D virObjectLockableNew(virAccessManagerClass))) { VIR_FREE(privateData); diff --git a/src/admin/admin_server_dispatch.c b/src/admin/admin_server_dis= patch.c index b3da577995..0efb4485d4 100644 --- a/src/admin/admin_server_dispatch.c +++ b/src/admin/admin_server_dispatch.c @@ -88,8 +88,7 @@ remoteAdmClientNew(virNetServerClientPtr client G_GNUC_UN= USED, return NULL; } =20 - if (VIR_ALLOC(priv) < 0) - return NULL; + priv =3D g_new0(struct daemonAdmClientPrivate, 1); =20 if (virMutexInit(&priv->lock) < 0) { VIR_FREE(priv); @@ -511,8 +510,7 @@ adminDispatchConnectGetLoggingFilters(virNetServerPtr s= erver G_GNUC_UNUSED, ret->filters =3D NULL; } else { char **ret_filters =3D NULL; - if (VIR_ALLOC(ret_filters) < 0) - return -1; + ret_filters =3D g_new0(char *, 1); =20 *ret_filters =3D filters; ret->filters =3D ret_filters; diff --git a/src/hypervisor/domain_driver.c b/src/hypervisor/domain_driver.c index f5f0f6e2e9..8dc5870a61 100644 --- a/src/hypervisor/domain_driver.c +++ b/src/hypervisor/domain_driver.c @@ -219,8 +219,7 @@ virDomainDriverParseBlkioDeviceStr(char *blkioDeviceStr= , const char *type, =20 ndevices =3D (nsep + 1) / 2; =20 - if (VIR_ALLOC_N(result, ndevices) < 0) - return -1; + result =3D g_new0(virBlkioDevice, ndevices); =20 i =3D 0; temp =3D blkioDeviceStr; diff --git a/src/hypervisor/virclosecallbacks.c b/src/hypervisor/vircloseca= llbacks.c index 200577e18e..403af047fb 100644 --- a/src/hypervisor/virclosecallbacks.c +++ b/src/hypervisor/virclosecallbacks.c @@ -120,9 +120,7 @@ virCloseCallbacksSet(virCloseCallbacksPtr closeCallback= s, =20 closeDef->cb =3D cb; } else { - if (VIR_ALLOC(closeDef) < 0) - goto cleanup; - + closeDef =3D g_new0(virDriverCloseDef, 1); closeDef->conn =3D conn; closeDef->cb =3D cb; if (virHashAddEntry(closeCallbacks->list, uuidstr, closeDef) < 0) { @@ -284,8 +282,7 @@ virCloseCallbacksGetForConn(virCloseCallbacksPtr closeC= allbacks, virCloseCallbacksListPtr list =3D NULL; struct virCloseCallbacksData data; =20 - if (VIR_ALLOC(list) < 0) - return NULL; + list =3D g_new0(virCloseCallbacksList, 1); =20 data.conn =3D conn; data.list =3D list; diff --git a/src/libxl/xen_xm.c b/src/libxl/xen_xm.c index 6d00f47544..9063a43135 100644 --- a/src/libxl/xen_xm.c +++ b/src/libxl/xen_xm.c @@ -42,8 +42,7 @@ xenParseXMOS(virConfPtr conf, virDomainDefPtr def) if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM) { g_autofree char *boot =3D NULL; =20 - if (VIR_ALLOC(def->os.loader) < 0) - return -1; + def->os.loader =3D g_new0(virDomainLoaderDef, 1); =20 if (xenConfigCopyString(conf, "kernel", &def->os.loader->path) < 0) return -1; @@ -346,9 +345,7 @@ xenFormatXMDisk(virConfValuePtr list, return -1; } =20 - if (VIR_ALLOC(val) < 0) - return -1; - + val =3D g_new0(virConfValue, 1); val->type =3D VIR_CONF_STRING; val->str =3D virBufferContentAndReset(&buf); tmp =3D list->list; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 7824e44ed9..bb26fc247c 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -212,15 +212,14 @@ testDomainDefNamespaceParse(xmlXPathContextPtr ctxt, unsigned int tmpuint; g_autofree xmlNodePtr *nodes =3D NULL; =20 - if (VIR_ALLOC(nsdata) < 0) - return -1; + nsdata =3D g_new0(testDomainNamespaceDef, 1); =20 n =3D virXPathNodeSet("./test:domainsnapshot", ctxt, &nodes); if (n < 0) goto error; =20 - if (n && VIR_ALLOC_N(nsdata->snap_nodes, n) < 0) - goto error; + if (n) + nsdata->snap_nodes =3D g_new0(xmlNodePtr, n); =20 for (i =3D 0; i < n; i++) { xmlNodePtr newnode =3D xmlCopyNode(nodes[i], 1); @@ -302,8 +301,7 @@ testBuildCapabilities(virConnectPtr conn) =20 virCapabilitiesHostInitIOMMU(caps); =20 - if (VIR_ALLOC_N(caps->host.pagesSize, 4) < 0) - goto error; + caps->host.pagesSize =3D g_new0(unsigned int, 4); =20 caps->host.pagesSize[caps->host.nPagesSize++] =3D 4; caps->host.pagesSize[caps->host.nPagesSize++] =3D 8; @@ -316,11 +314,8 @@ testBuildCapabilities(virConnectPtr conn) virCapsHostNUMACellPageInfoPtr pages; size_t nPages =3D caps->host.nPagesSize - 1; =20 - if (VIR_ALLOC_N(cpu_cells, privconn->cells[i].numCpus) < 0 || - VIR_ALLOC_N(pages, nPages) < 0) { - VIR_FREE(cpu_cells); - goto error; - } + cpu_cells =3D g_new0(virCapsHostNUMACellCPU, privconn->cells[i].nu= mCpus); + pages =3D g_new0(virCapsHostNUMACellPageInfo, nPages); =20 memcpy(cpu_cells, privconn->cells[i].cpus, sizeof(*cpu_cells) * privconn->cells[i].numCpus); @@ -364,8 +359,7 @@ testBuildCapabilities(virConnectPtr conn) } =20 caps->host.nsecModels =3D 1; - if (VIR_ALLOC_N(caps->host.secModels, caps->host.nsecModels) < 0) - goto error; + caps->host.secModels =3D g_new0(virCapsHostSecModel, caps->host.nsecMo= dels); caps->host.secModels[0].model =3D g_strdup("testSecurity"); =20 caps->host.secModels[0].doi =3D g_strdup(""); @@ -396,8 +390,7 @@ testDomainObjPrivateAlloc(void *opaque) { testDomainObjPrivatePtr priv; =20 - if (VIR_ALLOC(priv) < 0) - return NULL; + priv =3D g_new0(testDomainObjPrivate, 1); =20 priv->driver =3D opaque; priv->frozen[0] =3D priv->frozen[1] =3D false; @@ -760,8 +753,7 @@ static char *testBuildFilename(const char *relativeTo, if ((baseLen =3D (offset-relativeTo+1))) { char *absFile; int totalLen =3D baseLen + strlen(filename) + 1; - if (VIR_ALLOC_N(absFile, totalLen) < 0) - return NULL; + absFile =3D g_new0(char, totalLen); if (virStrncpy(absFile, relativeTo, baseLen, totalLen) < 0) { VIR_FREE(absFile); return NULL; @@ -1233,8 +1225,8 @@ testParseAuthUsers(testDriverPtr privconn, return -1; =20 privconn->numAuths =3D num; - if (num && VIR_ALLOC_N(privconn->auths, num) < 0) - return -1; + if (num) + privconn->auths =3D g_new0(testAuth, num); =20 for (i =3D 0; i < num; i++) { g_autofree char *username =3D NULL; @@ -2298,8 +2290,7 @@ testDomainSaveImageOpen(testDriverPtr driver, goto error; } =20 - if (VIR_ALLOC_N(xml, len+1) < 0) - goto error; + xml =3D g_new0(char, len + 1); =20 if (saferead(fd, xml, len) !=3D len) { virReportSystemError(errno, _("incomplete metadata in '%s'"), path= ); @@ -3491,10 +3482,9 @@ testDomainSetInterfaceParameters(virDomainPtr dom, if (!(net =3D virDomainNetFind(def, device))) goto cleanup; =20 - if ((VIR_ALLOC(bandwidth) < 0) || - (VIR_ALLOC(bandwidth->in) < 0) || - (VIR_ALLOC(bandwidth->out) < 0)) - goto cleanup; + 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]; @@ -4726,21 +4716,17 @@ testDomainGetFSInfo(virDomainPtr dom, if (vm->def->disks[i]->device =3D=3D VIR_DOMAIN_DISK_DEVICE_DISK) { char *name =3D vm->def->disks[i]->dst; =20 - if (VIR_ALLOC_N(info_ret, 2) < 0) - goto cleanup; - - if (VIR_ALLOC(info_ret[0]) < 0 || - VIR_ALLOC(info_ret[0]->devAlias) < 0) - goto cleanup; + info_ret =3D g_new0(virDomainFSInfo *, 2); + info_ret[0] =3D g_new0(virDomainFSInfo, 1); + info_ret[0]->devAlias =3D g_new0(char *, 1); =20 info_ret[0]->mountpoint =3D g_strdup("/"); info_ret[0]->fstype =3D g_strdup("ext4"); info_ret[0]->devAlias[0] =3D g_strdup(name); info_ret[0]->name =3D g_strdup_printf("%s1", name); =20 - if (VIR_ALLOC(info_ret[1]) < 0 || - VIR_ALLOC(info_ret[1]->devAlias) < 0) - goto cleanup; + info_ret[1] =3D g_new0(virDomainFSInfo, 1); + info_ret[1]->devAlias =3D g_new0(char *, 1); =20 info_ret[1]->mountpoint =3D g_strdup("/boot"); info_ret[1]->fstype =3D g_strdup("ext4"); @@ -5076,22 +5062,19 @@ testDomainInterfaceAddresses(virDomainPtr dom, if (virDomainObjCheckActive(vm) < 0) goto cleanup; =20 - if (VIR_ALLOC_N(ifaces_ret, vm->def->nnets) < 0) - goto cleanup; + ifaces_ret =3D g_new0(virDomainInterfacePtr, vm->def->nnets); =20 for (i =3D 0; i < vm->def->nnets; i++) { const virDomainNetDef *net =3D vm->def->nets[i]; =20 - if (VIR_ALLOC(iface) < 0) - goto cleanup; + iface =3D g_new0(virDomainInterface, 1); =20 iface->name =3D g_strdup(net->ifname); =20 virMacAddrFormat(&net->mac, macaddr); iface->hwaddr =3D g_strdup(macaddr); =20 - if (VIR_ALLOC(iface->addrs) < 0) - goto cleanup; + iface->addrs =3D g_new0(virDomainIPAddress, 1); iface->naddrs =3D 1; =20 if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { @@ -7741,8 +7724,7 @@ testNodeGetCPUMap(virConnectPtr conn G_GNUC_UNUSED, virCheckFlags(0, -1); =20 if (cpumap) { - if (VIR_ALLOC_N(*cpumap, 1) < 0) - return -1; + *cpumap =3D g_new0(unsigned char, 1); *cpumap[0] =3D 0x15; } =20 --=20 2.26.2 From nobody Fri May 3 22:11:44 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=1602159244; cv=none; d=zohomail.com; s=zohoarc; b=I8oa7CYPD5ab0c5lGrO1y2NuuVB3RPpn3NDcNzOvdMrw/qAkrZ1GHBPC9KosenyzpLZqddDB3JADXA3fNO6k2Wwnu7DfVpcGqB3deAnxJrWZS10gNts4767EbqVfFRph/zOF21Y6tMRQ6RFiEIWi37K2IJ9Emh7WP+2YyO1naoA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602159244; 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=9dKOhUHjw1b5HHY2pJKnaHDf+pVYXf3cFGTR7ggjPE0=; b=e/0JPN5SRio8pbobQX192+4rE5ItWe7ZFb043+LMssw0audTcbCeJZ0ZPNRLCgmib7EsvhODjAVLUPBKFwUD0Z/ySqXQQM99K5vMMaW6qVNYPaNPrEXZ8mWGupJ8SjMkXuYLGIwtdz51xNmDRetDjBeXgOYNqoRLO3boa2ICfBE= 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 1602159244062499.2355697911772; Thu, 8 Oct 2020 05:14:04 -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-409-qvy7MnnhO1GP-Pbxf-dp1A-1; Thu, 08 Oct 2020 08:13:02 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9426DAFD30; Thu, 8 Oct 2020 12:12:43 +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 4885C756A7; Thu, 8 Oct 2020 12:12:43 +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 0CFC31832FC2; Thu, 8 Oct 2020 12:12:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 098CCO1n001317 for ; Thu, 8 Oct 2020 08:12:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 70F845576E; Thu, 8 Oct 2020 12:12:24 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF42655770 for ; Thu, 8 Oct 2020 12:12:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602159242; 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=9dKOhUHjw1b5HHY2pJKnaHDf+pVYXf3cFGTR7ggjPE0=; b=BRT2XMfVHfJSV4xB3TU7WUzYASgs2clQQ6DlkNOMyYUh6i5mx3+7ZKHlla8LU71ty1ab0U DTzWoR+LkMYqvFH2HbqEE6O17B79tr9O3NAO0EvVG/dkDZTX3QrrHcdFFSxKoRS0p57LyP uklqFpLWydm6EH0eouy4W7JBwwMjfr4= X-MC-Unique: qvy7MnnhO1GP-Pbxf-dp1A-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 6/8] tests: use g_new0 instead of VIR_ALLOC Date: Thu, 8 Oct 2020 14:12:12 +0200 Message-Id: <56eb5e9373b4804d14007c6f40953853449e3f90.1602158901.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.12 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: Pavel Hrdina --- tests/viralloctest.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/tests/viralloctest.c b/tests/viralloctest.c index c52483998b..785728d6f9 100644 --- a/tests/viralloctest.c +++ b/tests/viralloctest.c @@ -117,8 +117,7 @@ testReallocArray(const void *opaque G_GNUC_UNUSED) size_t nt =3D 10, i; int ret =3D -1; =20 - if (VIR_ALLOC_N(t, nt) < 0) - return -1; + t =3D g_new0(testDummyStruct, nt); =20 if (testCheckNonNull(t) < 0) goto cleanup; @@ -191,8 +190,7 @@ testExpandArray(const void *opaque G_GNUC_UNUSED) size_t nt =3D 10, i; int ret =3D -1; =20 - if (VIR_ALLOC_N(t, nt) < 0) - return -1; + t =3D g_new0(testDummyStruct, nt); =20 if (testCheckNonNull(t) < 0) goto cleanup; @@ -271,8 +269,7 @@ testResizeArray(const void *opaque G_GNUC_UNUSED) size_t nt =3D 10, at, i; int ret =3D -1; =20 - if (VIR_ALLOC_N(t, nt) < 0) - return -1; + t =3D g_new0(testDummyStruct, nt); =20 at =3D nt; =20 @@ -333,8 +330,7 @@ testInsertArray(const void *opaque G_GNUC_UNUSED) int ret =3D -1; testDummyStruct *n =3D (void *)0xff; =20 - if (VIR_ALLOC_N(t, nt) < 0) - return -1; + t =3D g_new0(testDummyStruct, nt); =20 if (testCheckNonNull(t) < 0) goto cleanup; @@ -398,14 +394,12 @@ testDispose(const void *opaque G_GNUC_UNUSED) nnums =3D 10; VIR_DISPOSE_N(nums, nnums); =20 - if (VIR_ALLOC(num) < 0) - return -1; + num =3D g_new0(int, 1); =20 VIR_DISPOSE(num); =20 nnums =3D 10; - if (VIR_ALLOC_N(nums, nnums) < 0) - return -1; + nums =3D g_new0(int, nnums); =20 VIR_DISPOSE_N(nums, nnums); =20 --=20 2.26.2 From nobody Fri May 3 22:11:44 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=1602159315; cv=none; d=zohomail.com; s=zohoarc; b=DhCvVzDJo+t03OdixxQTg+7ykycFUa9abwuxAKewm+Acz0V4p/4JP90nI626ztdpAlJl+6nh9+cXQ2vO2suZl1IXVZ2Xox8gSRJLssiMTetPDTT1A6yr9LIjgrQC6vMIdwyazrYviXs2Wy/+sPcKTcYk+E2XFqipj7OfQ1ULr6A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602159315; 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=in/7hNQXbj65HZwsztT7E0H9ADmLqcSIFkj+AxTr3Bs=; b=F16fU2oI+3jJxKvqEz6QhwoW18pwUV2VN8F2Tu9RAbQ3Fp1ycv+Nk2xldXStpTmjmXmoolkAQPFMVZRslKs28av6buDWh/BNgTxvO9L2qVRK+YOT2M4ako2+NRu8uN5t2n+fVG1tE+QcK+NgYtBDsbMypgc6mbecNH1pP6Y2q8Q= 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 1602159315956762.6167754715763; Thu, 8 Oct 2020 05:15:15 -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-556-NjvnRtChPyqpm4mYHJYj4Q-1; Thu, 08 Oct 2020 08:13:04 -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 11EE6104D3EA; Thu, 8 Oct 2020 12:12:46 +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 E199655785; Thu, 8 Oct 2020 12:12:45 +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 A95018C7BF; Thu, 8 Oct 2020 12:12:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 098CCPIY001324 for ; Thu, 8 Oct 2020 08:12:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7690555764; Thu, 8 Oct 2020 12:12:25 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id D49EC55761 for ; Thu, 8 Oct 2020 12:12:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602159314; 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=in/7hNQXbj65HZwsztT7E0H9ADmLqcSIFkj+AxTr3Bs=; b=Ttt3HAz4DBXokrIxMDmla1X4+AqvGcRcqQZ+b1oBbYUCsS2TPY8f/6kKGhI9wZ6B0xYbz7 aXs16KHBpDCkRTHeGM0T3x4B0LKxp1irgw4PWi+JkUx2e9O55iKOHKqePtzDA5pWRuKvEQ 9vLK4lpgPEFJv1faJ56r4IF0kP/qpFM= X-MC-Unique: NjvnRtChPyqpm4mYHJYj4Q-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 7/8] tests: delete VIR_ALLOC tests cases Date: Thu, 8 Oct 2020 14:12:13 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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) There are no more users of VIR_ALLOC or VIR_ALLOC_N. Delete their test cases. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Pavel Hrdina --- tests/viralloctest.c | 71 -------------------------------------------- 1 file changed, 71 deletions(-) diff --git a/tests/viralloctest.c b/tests/viralloctest.c index 785728d6f9..bc7bb114c1 100644 --- a/tests/viralloctest.c +++ b/tests/viralloctest.c @@ -43,73 +43,6 @@ testCheckNonNull(void *t) return 0; } =20 -static int -testAllocScalar(const void *opaque G_GNUC_UNUSED) -{ - testDummyStruct *t; - int ret =3D -1; - - if (VIR_ALLOC(t) < 0) - return -1; - - if (testCheckNonNull(t) < 0) - goto cleanup; - - if (t->a !=3D 0 || - t->b !=3D 0) { - fprintf(stderr, "Allocated ram was not zerod\n"); - goto cleanup; - } - - VIR_FREE(t); - - if (t !=3D NULL) { - fprintf(stderr, "Pointer is still set after free\n"); - goto cleanup; - } - - ret =3D 0; - cleanup: - VIR_FREE(t); - return ret; -} - - -static int -testAllocArray(const void *opaque G_GNUC_UNUSED) -{ - testDummyStruct *t; - size_t nt =3D 10, i; - int ret =3D -1; - - if (VIR_ALLOC_N(t, nt) < 0) - return -1; - - if (testCheckNonNull(t) < 0) - goto cleanup; - - for (i =3D 0; i < nt; i++) { - if (t[i].a !=3D 0 || - t[i].b !=3D 0) { - fprintf(stderr, "Allocated ram block %zu was not zerod\n", i); - goto cleanup; - } - } - - VIR_FREE(t); - - if (t !=3D NULL) { - fprintf(stderr, "Pointer is still set after free\n"); - goto cleanup; - } - - ret =3D 0; - cleanup: - VIR_FREE(t); - return ret; -} - - static int testReallocArray(const void *opaque G_GNUC_UNUSED) { @@ -416,10 +349,6 @@ mymain(void) { int ret =3D 0; =20 - if (virTestRun("alloc scalar", testAllocScalar, NULL) < 0) - ret =3D -1; - if (virTestRun("alloc array", testAllocArray, NULL) < 0) - ret =3D -1; if (virTestRun("realloc array", testReallocArray, NULL) < 0) ret =3D -1; if (virTestRun("expand array", testExpandArray, NULL) < 0) --=20 2.26.2 From nobody Fri May 3 22:11:44 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=1602159184; cv=none; d=zohomail.com; s=zohoarc; b=RkrOWMIJnI2oX+B/eRZvOTCDIi9VkKIqx+ZNCV7GLQ0f0QErwUmcLi/ijEbA+TtHb6sqzJPm1PHaFs1/Wf0gRsVArMQYt14+348RDRRxjl7sSdAGAYqN+gKl0RYSlmf0DMI9nIpjsQd8pg8K61mwzAweAFICi52oMWdIu69Im6E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602159184; 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=1RULqST8i7r0190tov89ihntQhr7jU6YNNf9JMfGnTg=; b=X0bPOsKkjrf5QFJZ6JV2u0YwycRAYjSN9SgMoeiOv8M37EWtGelh9o+VHlCgVCWmY/MmR+L2N/G0o6y3rPUAkdueibPcxeilyGYe9PYcGwt3gx0tXpe6Mk5TGvB+qTc3xIjQhXtig9LPqGJFeifTov+CnHp9BLLd9IrI3Cv/6Kw= 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 1602159184900120.13069485448841; Thu, 8 Oct 2020 05:13:04 -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-566-sqb0DerAPEeGOggGB-Gg3Q-1; Thu, 08 Oct 2020 08:12:55 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E0CA7900C2B; Thu, 8 Oct 2020 12:12:42 +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 BA7CF61176; Thu, 8 Oct 2020 12:12:42 +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 8581C1832FC2; Thu, 8 Oct 2020 12:12:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 098CCQAu001336 for ; Thu, 8 Oct 2020 08:12:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id 79E2655764; Thu, 8 Oct 2020 12:12:26 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7AA855761 for ; Thu, 8 Oct 2020 12:12:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602159183; 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=1RULqST8i7r0190tov89ihntQhr7jU6YNNf9JMfGnTg=; b=cJdojlvux7RVulZGI6UyVVOk/G3OQml1Lxm4SQM9nKc62DFBehOkDrPpEdodtEIyZ2EGNB lbLk/n43cmeQareS1qVeDfLnrsdWpxaL/qki9acfBAinQDDtkp1E9ceYfi8tqZk8unpoXt tY60kxMbKAbRJY886noS6L5UAhJpaQY= X-MC-Unique: sqb0DerAPEeGOggGB-Gg3Q-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 8/8] util: delete VIR_ALLOC and VIR_ALLOC_N Date: Thu, 8 Oct 2020 14:12:14 +0200 Message-Id: <8d8c4d7a6ee084ab3512a6588c35f3b67c8c5d2e.1602158901.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.12 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: Pavel Hrdina --- src/libvirt_private.syms | 2 -- src/util/viralloc.c | 39 --------------------------------------- src/util/viralloc.h | 33 --------------------------------- 3 files changed, 74 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 7cf8bea962..152083d220 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1614,8 +1614,6 @@ vir_g_strdup_vprintf; =20 =20 # util/viralloc.h -virAlloc; -virAllocN; virAllocVar; virDeleteElementsN; virDispose; diff --git a/src/util/viralloc.c b/src/util/viralloc.c index e254416cdf..0360b8a8aa 100644 --- a/src/util/viralloc.c +++ b/src/util/viralloc.c @@ -31,45 +31,6 @@ VIR_LOG_INIT("util.alloc"); =20 =20 -/** - * virAlloc: - * @ptrptr: pointer to pointer for address of allocated memory - * @size: number of bytes to allocate - * - * Allocate 'size' bytes of memory. Return the address of the - * allocated memory in 'ptrptr'. The newly allocated memory is - * filled with zeros. - * - * Returns zero on success, aborts on OOM - */ -int virAlloc(void *ptrptr, - size_t size) -{ - *(void **)ptrptr =3D g_malloc0(size); - return 0; -} - -/** - * virAllocN: - * @ptrptr: pointer to pointer for address of allocated memory - * @size: number of bytes to allocate - * @count: number of elements to allocate - * - * Allocate an array of memory 'count' elements long, - * each with 'size' bytes. Return the address of the - * allocated memory in 'ptrptr'. The newly allocated - * memory is filled with zeros. - * - * Returns zero on success, aborts on OOM - */ -int virAllocN(void *ptrptr, - size_t size, - size_t count) -{ - *(void**)ptrptr =3D g_malloc0_n(count, size); - return 0; -} - /** * virReallocN: * @ptrptr: pointer to pointer for address of allocated memory diff --git a/src/util/viralloc.h b/src/util/viralloc.h index a50cd5d632..1abd94fac4 100644 --- a/src/util/viralloc.h +++ b/src/util/viralloc.h @@ -34,10 +34,6 @@ */ =20 /* Don't call these directly - use the macros below */ -int virAlloc(void *ptrptr, size_t size) - G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NONNULL(1); -int virAllocN(void *ptrptr, size_t size, size_t count) - G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NONNULL(1); int virReallocN(void *ptrptr, size_t size, size_t count) G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NONNULL(1); int virExpandN(void *ptrptr, size_t size, size_t *count, size_t add) @@ -61,35 +57,6 @@ void virDispose(void *ptrptr, size_t count, size_t eleme= nt_size, size_t *countpt void virDisposeString(char **strptr) ATTRIBUTE_NONNULL(1); =20 -/** - * VIR_ALLOC: - * @ptr: pointer to hold address of allocated memory - * - * Allocate sizeof(*ptr) bytes of memory and store - * the address of allocated memory in 'ptr'. Fill the - * newly allocated memory with zeros. - * - * This macro is safe to use on arguments with side effects. - * - * Returns 0 on success, aborts on OOM - */ -#define VIR_ALLOC(ptr) virAlloc(&(ptr), sizeof(*(ptr))) - -/** - * VIR_ALLOC_N: - * @ptr: pointer to hold address of allocated memory - * @count: number of elements to allocate - * - * Allocate an array of 'count' elements, each sizeof(*ptr) - * bytes long and store the address of allocated memory in - * 'ptr'. Fill the newly allocated memory with zeros. - * - * This macro is safe to use on arguments with side effects. - * - * Returns 0 on success, aborts on OOM - */ -#define VIR_ALLOC_N(ptr, count) virAllocN(&(ptr), sizeof(*(ptr)), (count)) - /** * VIR_REALLOC_N: * @ptr: pointer to hold address of allocated memory --=20 2.26.2