From nobody Wed May 8 20:51:32 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=1600892071; cv=none; d=zohomail.com; s=zohoarc; b=UrRutLEduOOTErm7FDinRR9xPMakycB3xh4obEcO5f1lUlbmJRjuHxjQTw0QTxctSirQD/1LXY7QMG3hXyLHB+aDYPxMiC67jma1D2op4+Ze8GnNieIhRNooZFtUvsbIxbrjvx4rRpMgxtZ9eBYWGUdRK/hOak19U3bBCfUuI50= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600892071; 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=2i3JprzdpX9vNGEmoebzcYbwhePzfJK+p2SgO85A1Vg=; b=VWcyfSY4/ijxbeHdQTbuzfN5a+VRpyO3+rAUkgyXMPAYxhgR0uGQ2ek5hU11UVKYvo2GBDmVt1DAo6Btdxa4E9glz18v5JsGkjKJWenzVwHfmbq8IHeR29B8htQSw7o2n2k50DckriesJo2a6fq1xY2iQds2Z8W8G/jA1ii98LQ= 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 1600892071547183.42604934708356; Wed, 23 Sep 2020 13:14:31 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-486-lRYezTYfN7G33hXjC-gWcA-1; Wed, 23 Sep 2020 16:14:27 -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 BE5BC81F00A; Wed, 23 Sep 2020 20:14:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 97AE960CCC; Wed, 23 Sep 2020 20:14:22 +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 55942183D043; Wed, 23 Sep 2020 20:14:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 08NKBIgh028434 for ; Wed, 23 Sep 2020 16:11:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 79B2E5D990; Wed, 23 Sep 2020 20:11:18 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 018255D98D for ; Wed, 23 Sep 2020 20:11:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600892070; 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=2i3JprzdpX9vNGEmoebzcYbwhePzfJK+p2SgO85A1Vg=; b=B6Y2EqIpm7+zpImQaONiNFqa9iBKyGR3e0h/3fuiqK61u4mSxD+bZ16nYIs2ThLwf0vII3 mDPd8lngbsKp5en1Be5XBCa36VAWzpJqU6venwTnAHUucgnyWdFWsHqTLZyxYuwqzSRwLU nSbEN08g8PjQEEngW8XlwoJGRQHmHNs= X-MC-Unique: lRYezTYfN7G33hXjC-gWcA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 1/5] node_device: use g_new0 instead of VIR_ALLOC* Date: Wed, 23 Sep 2020 22:11:04 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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: Daniel Henrique Barboza --- src/node_device/node_device_udev.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_devi= ce_udev.c index 12e3f30bad..2d0ca27fc6 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -413,13 +413,11 @@ udevProcessPCI(struct udev_device *device, goto cleanup; =20 if (virPCIDeviceIsPCIExpress(pciDev) > 0) { - if (VIR_ALLOC(pci_express) < 0) - goto cleanup; + pci_express =3D g_new0(virPCIEDeviceInfo, 1); =20 if (virPCIDeviceHasPCIExpressLink(pciDev) > 0) { - if (VIR_ALLOC(pci_express->link_cap) < 0 || - VIR_ALLOC(pci_express->link_sta) < 0) - goto cleanup; + pci_express->link_cap =3D g_new0(virPCIELink, 1); + pci_express->link_sta =3D g_new0(virPCIELink, 1); =20 if (virPCIDeviceGetLinkCapSta(pciDev, &pci_express->link_cap->port, @@ -1159,8 +1157,7 @@ udevGetDeviceNodes(struct udev_device *device, udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entr= y(device)) n++; =20 - if (VIR_ALLOC_N(def->devlinks, n + 1) < 0) - return -1; + def->devlinks =3D g_new0(char *, n + 1); =20 n =3D 0; udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entr= y(device)) { @@ -1371,16 +1368,14 @@ udevAddOneDevice(struct udev_device *device) bool new_device =3D true; int ret =3D -1; =20 - if (VIR_ALLOC(def) !=3D 0) - goto cleanup; + def =3D g_new0(virNodeDeviceDef, 1); =20 def->sysfs_path =3D g_strdup(udev_device_get_syspath(device)); =20 if (udevGetStringProperty(device, "DRIVER", &def->driver) < 0) goto cleanup; =20 - if (VIR_ALLOC(def->caps) !=3D 0) - goto cleanup; + def->caps =3D g_new0(virNodeDevCapsDef, 1); =20 if (udevGetDeviceType(device, &def->caps->data.type) !=3D 0) goto cleanup; @@ -1788,13 +1783,10 @@ udevSetupSystemDev(void) virNodeDeviceObjPtr obj =3D NULL; int ret =3D -1; =20 - if (VIR_ALLOC(def) < 0) - return -1; + def =3D g_new0(virNodeDeviceDef, 1); =20 def->name =3D g_strdup("computer"); - - if (VIR_ALLOC(def->caps) !=3D 0) - goto cleanup; + def->caps =3D g_new0(virNodeDevCapsDef, 1); =20 #if defined(__x86_64__) || defined(__i386__) || defined(__amd64__) udevGetDMIData(&def->caps->data.system); @@ -1882,8 +1874,7 @@ nodeStateInitialize(bool privileged, return -1; } =20 - if (VIR_ALLOC(driver) < 0) - return VIR_DRV_STATE_INIT_ERROR; + driver =3D g_new0(virNodeDeviceDriverState, 1); =20 driver->lockFD =3D -1; if (virMutexInit(&driver->lock) < 0) { --=20 2.26.2 From nobody Wed May 8 20:51:32 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=1600892079; cv=none; d=zohomail.com; s=zohoarc; b=UsOKDzIn2WVe+sd5I1OMCQG4a/f2nXh6X/Dlgrk1plLc6STGJ11p6pU7C1PDMGfGL7lSB/rzMMVSDW0LhOjanDC2YZzwiPvnUeX495L/P90ehuLJd83gsczlRJa66deqV1P5TZbX8kMVyERbUMIuvY29O2JvenKHqquGaE7Pqdo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600892079; 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=97gxE0iNVw4Y+gsRizRZA7tKCZcZ2b/hBtK6yX+EbPM=; b=JPxjCWYMrn6fY98ZrTTKq6mXOyBuQLnSC7CK2fA6r6qiqyiMon4aZ1/e4ijJ/4CfI5dJCmHifP4LAw6S9gZC10eOs4pxHB41boEV8lrZa0+nju5ObvySC6IhnXNZhbbFLaLfbL5f6audYXKPLyfmldzrNdYUvhVHpiua6mO+BGs= 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 1600892079047375.1856163189964; Wed, 23 Sep 2020 13:14:39 -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-160-gezHnUpUOlWyEnn_cFmAKw-1; Wed, 23 Sep 2020 16:14:35 -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 908D39CC17; Wed, 23 Sep 2020 20:14:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7071860CCC; Wed, 23 Sep 2020 20:14:26 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 3C69779DBA; Wed, 23 Sep 2020 20:14:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 08NKBJWo028439 for ; Wed, 23 Sep 2020 16:11:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4E1D55D98D; Wed, 23 Sep 2020 20:11:19 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6F435D990 for ; Wed, 23 Sep 2020 20:11:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600892077; 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=97gxE0iNVw4Y+gsRizRZA7tKCZcZ2b/hBtK6yX+EbPM=; b=AbuHnOcg9TYZhtrUERh05YAAFVicXAQbgYbXDIjusxq+lMCXBsFf+qwGFSAFPYQJ4hLcOM medWLHJJmD0aztLCKp83ionulcgYzxDUe22KTihqPily/vxECa+kJDhupq/5LPNnVB8IWF CgSxQXqp2KWebnmQfl6aEgfBeDSgslo= X-MC-Unique: gezHnUpUOlWyEnn_cFmAKw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 2/5] openvz: use g_new0 instead of VIR_ALLOC* Date: Wed, 23 Sep 2020 22:11:05 +0200 Message-Id: <1a3924245aac54f15a48a72c0e34f71857748179.1600891692.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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: Daniel Henrique Barboza --- src/openvz/openvz_conf.c | 12 ++++-------- src/openvz/openvz_driver.c | 3 +-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 6d54123a35..8f1740863c 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -205,8 +205,7 @@ openvzReadNetworkConf(virDomainDefPtr def, } else if (ret > 0) { token =3D strtok_r(temp, " ", &saveptr); while (token !=3D NULL) { - if (VIR_ALLOC(net) < 0) - goto error; + net =3D g_new0(virDomainNetDef, 1); =20 net->type =3D VIR_DOMAIN_NET_TYPE_ETHERNET; if (virDomainNetAppendIPAddress(net, token, AF_UNSPEC, 0) < 0) @@ -238,8 +237,7 @@ openvzReadNetworkConf(virDomainDefPtr def, int len; =20 /* add new device to list */ - if (VIR_ALLOC(net) < 0) - goto error; + net =3D g_new0(virDomainNetDef, 1); =20 net->type =3D VIR_DOMAIN_NET_TYPE_BRIDGE; =20 @@ -259,8 +257,7 @@ openvzReadNetworkConf(virDomainDefPtr def, goto error; } =20 - if (VIR_ALLOC_N(net->ifname, len+1) < 0) - goto error; + net->ifname =3D g_new0(char, len+1); =20 if (virStrncpy(net->ifname, p, len, len+1) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -276,8 +273,7 @@ openvzReadNetworkConf(virDomainDefPtr def, goto error; } =20 - if (VIR_ALLOC_N(net->data.bridge.brname, len+1) < 0) - goto error; + net->data.bridge.brname =3D g_new0(char, len+1); =20 if (virStrncpy(net->data.bridge.brname, p, len, len+1)= < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index 71e270ea09..f90ae4fe69 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -1287,8 +1287,7 @@ static virDrvOpenStatus openvzConnectOpen(virConnectP= tr conn, /* We now know the URI is definitely for this driver, so beyond * here, don't return DECLINED, always use ERROR */ =20 - if (VIR_ALLOC(driver) < 0) - return VIR_DRV_OPEN_ERROR; + driver =3D g_new0(struct openvz_driver, 1); =20 if (!(driver->domains =3D virDomainObjListNew())) goto cleanup; --=20 2.26.2 From nobody Wed May 8 20:51:32 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=1600892076; cv=none; d=zohomail.com; s=zohoarc; b=Dx6Sq8quecx2cyoL14cMWLB9+P5acy64vkIV/p2AW6O3FB5Iwm8MPkJei6zu7mOCwrywCTATawdaBS1/E8Sgz/mqobQhSF1nMOAFXC65+1P9L4h/xVbo2+AuB67jEpPt7NwDVvvSXYps5CmCPH0nID2KukTG9lVS1U9i6FRmfMo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600892076; 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=WMHhcpqpbSnHCmCrQLSD6BTgY8MjZKOZ69078V+KVYU=; b=O59YsAd++x9XGzlp0ueyOtbC7qPgjwh93BrsJ+vxS68Zfv75qAgQbr11uLPzw0/FP/FOkga86ipK0xDABh52ZNVuJnNwC0DMDT55XfXVIQGIjRIcA7pzrcaxlrCSIbv7EYHi6fzm2iKjjciqsgmQog4heQWiCjsbDAzZ23bg0oM= 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 1600892076096620.086638286667; Wed, 23 Sep 2020 13:14:36 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-370-SKrwYXpxPvi8dinj1jE4gw-1; Wed, 23 Sep 2020 16:14:32 -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 E4CD7800135; Wed, 23 Sep 2020 20:14:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C54607368D; Wed, 23 Sep 2020 20:14:26 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8F06779DBA; Wed, 23 Sep 2020 20:14:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 08NKBKg0028449 for ; Wed, 23 Sep 2020 16:11:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1D0085D990; Wed, 23 Sep 2020 20:11:20 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A7295D98D for ; Wed, 23 Sep 2020 20:11:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600892074; 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=WMHhcpqpbSnHCmCrQLSD6BTgY8MjZKOZ69078V+KVYU=; b=AOpowhooLavpvxeTJO2UsJc/gdS5lbr6+Z59hX2muIuVeITr+nSzYDfxfbX+i8pdAp78Wo w+asz4Oy/a73GhHt3Se/Cl6OdPUfbUs55P/zi9IrAUDEevUwibpIs9eFdcoWTqWqA12/gp miig2eXCV4DG947u+yP29Ddd58MPZnc= X-MC-Unique: SKrwYXpxPvi8dinj1jE4gw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 3/5] secret: use g_new0 instead of VIR_ALLOC* Date: Wed, 23 Sep 2020 22:11:06 +0200 Message-Id: <1e8d151e8dc110d9fdf35c25b4f8509e1240d078.1600891692.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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: Daniel Henrique Barboza --- src/secret/secret_driver.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/secret/secret_driver.c b/src/secret/secret_driver.c index 1cb342878f..45da09322b 100644 --- a/src/secret/secret_driver.c +++ b/src/secret/secret_driver.c @@ -459,8 +459,7 @@ secretStateInitialize(bool privileged, virStateInhibitCallback callback G_GNUC_UNUSED, void *opaque G_GNUC_UNUSED) { - if (VIR_ALLOC(driver) < 0) - return VIR_DRV_STATE_INIT_ERROR; + driver =3D g_new0(virSecretDriverState, 1); =20 driver->lockFD =3D -1; if (virMutexInit(&driver->lock) < 0) { --=20 2.26.2 From nobody Wed May 8 20:51:32 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=1600892082; cv=none; d=zohomail.com; s=zohoarc; b=im5SZo5jY120kkHG/rsaRvkEjIhzuimgOSIHeANwKM4Fs8sNKvRJWoaAYqxYQ0GlDNcgfyKHFFUedrGtcC4wh4Tw/Hx98wCvFCno923BQLLGVHyQQZJnjyDUHFHkhvxEy50Uqv979SR6XJjGyrliTekJn/pNXb8vEoaLENFEIoA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600892082; 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=HJCo1KB31MkOkzxPstZCeboAUc70CLY9J5vFb/SWX8E=; b=PdvZTXciVi5eaROQ+/y/ys76vMyvUoM4U86GYvTyLx80G6LrJV6wFOD29G7dBWiPeB9bko6bhDa/o+OmPsC2TqBEmqj2MZsjZ1p1EeTZj1x6LRcvzHSortTeCZBwW/1dxYU1wXHJLqnANPkWZdY3j96IdOpJxlsyMolEpPu82Cg= 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 1600892082021194.62769052924477; Wed, 23 Sep 2020 13:14:42 -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-269-Ch96HC9YPB6RIK7SkRpMmw-1; Wed, 23 Sep 2020 16:14:36 -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 1E2631891E8D; Wed, 23 Sep 2020 20:14:29 +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 F3E6478822; Wed, 23 Sep 2020 20:14:28 +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 BE450183D046; Wed, 23 Sep 2020 20:14:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 08NKBKm0028461 for ; Wed, 23 Sep 2020 16:11:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id E17815D990; Wed, 23 Sep 2020 20:11:20 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A4335D98D for ; Wed, 23 Sep 2020 20:11:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600892080; 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=HJCo1KB31MkOkzxPstZCeboAUc70CLY9J5vFb/SWX8E=; b=YPzcx5DbrVXlEv+ky0GaxxOysB9QdskZ2LWVgHXQ9rIT2haxpsPQSpL84zSFHFvaPzH7co uj53hLxVfoZF4z4O2psS2PzVuXgWRKb51Rt0yjx2tOCh0/k3nZVNmztzwc/+rz2nyTCsmu gyPRRH90MPuCCBfgQ7bsgeC6OXDy8TE= X-MC-Unique: Ch96HC9YPB6RIK7SkRpMmw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 4/5] security: use g_new0 instead of VIR_ALLOC* Date: Wed, 23 Sep 2020 22:11:07 +0200 Message-Id: <8bf956247a0b152e110f138061705a6f8977117f.1600891692.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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: Daniel Henrique Barboza --- src/security/security_apparmor.c | 3 +-- src/security/security_dac.c | 9 +++------ src/security/security_manager.c | 14 +++++--------- src/security/security_selinux.c | 9 +++------ src/security/security_stack.c | 6 ++---- 5 files changed, 14 insertions(+), 27 deletions(-) diff --git a/src/security/security_apparmor.c b/src/security/security_appar= mor.c index eea37dca83..c2d86c6940 100644 --- a/src/security/security_apparmor.c +++ b/src/security/security_apparmor.c @@ -867,8 +867,7 @@ AppArmorSetSecurityHostdevLabel(virSecurityManagerPtr m= gr, if (profile_loaded(secdef->imagelabel) < 0) return 0; =20 - if (VIR_ALLOC(ptr) < 0) - return -1; + ptr =3D g_new0(struct SDPDOP, 1); ptr->mgr =3D mgr; ptr->def =3D def; =20 diff --git a/src/security/security_dac.c b/src/security/security_dac.c index d9d4cda159..258d246659 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -108,8 +108,7 @@ virSecurityDACChownListAppend(virSecurityDACChownListPt= r list, char *tmp =3D NULL; virSecurityDACChownItemPtr item =3D NULL; =20 - if (VIR_ALLOC(item) < 0) - return -1; + item =3D g_new0(virSecurityDACChownItem, 1); =20 tmp =3D g_strdup(path); =20 @@ -227,8 +226,7 @@ virSecurityDACTransactionRun(pid_t pid G_GNUC_UNUSED, int ret =3D -1; =20 if (list->lock) { - if (VIR_ALLOC_N(paths, list->nItems) < 0) - return -1; + paths =3D g_new0(const char *, list->nItems); =20 for (i =3D 0; i < list->nItems; i++) { virSecurityDACChownItemPtr item =3D list->items[i]; @@ -580,8 +578,7 @@ virSecurityDACTransactionStart(virSecurityManagerPtr mg= r) return -1; } =20 - if (VIR_ALLOC(list) < 0) - return -1; + list =3D g_new0(virSecurityDACChownList, 1); =20 list->manager =3D virObjectRef(mgr); =20 diff --git a/src/security/security_manager.c b/src/security/security_manage= r.c index 17b565cc12..be81ee5e44 100644 --- a/src/security/security_manager.c +++ b/src/security/security_manager.c @@ -87,8 +87,7 @@ virSecurityManagerNewDriver(virSecurityDriverPtr drv, =20 virCheckFlags(VIR_SECURITY_MANAGER_NEW_MASK, NULL); =20 - if (VIR_ALLOC_N(privateData, drv->privateDataLen) < 0) - return NULL; + privateData =3D g_new0(char, drv->privateDataLen); =20 if (!(mgr =3D virObjectLockableNew(virSecurityManagerClass))) goto error; @@ -1034,8 +1033,7 @@ virSecurityManagerGetNested(virSecurityManagerPtr mgr) if (STREQ("stack", mgr->drv->name)) return virSecurityStackGetNested(mgr); =20 - if (VIR_ALLOC_N(list, 2) < 0) - return NULL; + list =3D g_new0(virSecurityManagerPtr, 2); =20 list[0] =3D mgr; list[1] =3D NULL; @@ -1346,9 +1344,8 @@ virSecurityManagerMetadataLock(virSecurityManagerPtr = mgr G_GNUC_UNUSED, const char **locked_paths =3D NULL; virSecurityManagerMetadataLockStatePtr ret =3D NULL; =20 - if (VIR_ALLOC_N(fds, npaths) < 0 || - VIR_ALLOC_N(locked_paths, npaths) < 0) - return NULL; + fds =3D g_new0(int, npaths); + locked_paths =3D g_new0(const char *, npaths); =20 /* Sort paths to lock in order to avoid deadlocks with other * processes. For instance, if one process wants to lock @@ -1441,8 +1438,7 @@ virSecurityManagerMetadataLock(virSecurityManagerPtr = mgr G_GNUC_UNUSED, VIR_APPEND_ELEMENT_COPY_INPLACE(fds, nfds, fd); } =20 - if (VIR_ALLOC(ret) < 0) - goto cleanup; + ret =3D g_new0(virSecurityManagerMetadataLockState, 1); =20 ret->paths =3D g_steal_pointer(&locked_paths); ret->fds =3D g_steal_pointer(&fds); diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index 87741d6dad..e40d670e97 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -123,8 +123,7 @@ virSecuritySELinuxContextListAppend(virSecuritySELinuxC= ontextListPtr list, int ret =3D -1; virSecuritySELinuxContextItemPtr item =3D NULL; =20 - if (VIR_ALLOC(item) < 0) - return -1; + item =3D g_new0(virSecuritySELinuxContextItem, 1); =20 item->path =3D g_strdup(path); item->tcon =3D g_strdup(tcon); @@ -258,8 +257,7 @@ virSecuritySELinuxTransactionRun(pid_t pid G_GNUC_UNUSE= D, int ret =3D -1; =20 if (list->lock) { - if (VIR_ALLOC_N(paths, list->nItems) < 0) - return -1; + paths =3D g_new0(const char *, list->nItems); =20 for (i =3D 0; i < list->nItems; i++) { virSecuritySELinuxContextItemPtr item =3D list->items[i]; @@ -1088,8 +1086,7 @@ virSecuritySELinuxTransactionStart(virSecurityManager= Ptr mgr) return -1; } =20 - if (VIR_ALLOC(list) < 0) - return -1; + list =3D g_new0(virSecuritySELinuxContextList, 1); =20 list->manager =3D virObjectRef(mgr); =20 diff --git a/src/security/security_stack.c b/src/security/security_stack.c index 2480c47f70..3bfcb1e2f7 100644 --- a/src/security/security_stack.c +++ b/src/security/security_stack.c @@ -56,8 +56,7 @@ virSecurityStackAddNested(virSecurityManagerPtr mgr, while (tmp && tmp->next) tmp =3D tmp->next; =20 - if (VIR_ALLOC(item) < 0) - return -1; + item =3D g_new0(virSecurityStackItem, 1); item->securityManager =3D nested; item->prev =3D tmp; if (tmp) @@ -620,8 +619,7 @@ virSecurityStackGetNested(virSecurityManagerPtr mgr) for (item =3D priv->itemsHead; item; item =3D item->next) len++; =20 - if (VIR_ALLOC_N(list, len + 1) < 0) - return NULL; + list =3D g_new0(virSecurityManagerPtr, len + 1); =20 for (i =3D 0, item =3D priv->itemsHead; item; item =3D item->next, i++) list[i] =3D item->securityManager; --=20 2.26.2 From nobody Wed May 8 20:51:32 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=1600892081; cv=none; d=zohomail.com; s=zohoarc; b=kRd4fMcwJMUSCCJZVaQ7mg0t2qiQEiWSW3rV3VqR/V1pQ0RYHqWlnwxMlFaIKjaBIjBBjG2dXKL3V8fSQQakVv3gOx0CHRs0yojTI+i7LAoxH6n9rCXJQ0ZN01Gb3iBmAxmsZSqkcPvFzAKSXn7wejhztAfXd1grKJZUBiSlpKA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600892081; 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=XafskzOTuE98lCdZ45PcR9uug5dLT1CJ4MUoo457DmM=; b=Vmsozj79bshuC+nNKQkXP/4H7lYtAXYGXOE1s6GLK6xYfkeojCOdXhXmzV7Dz5UZy+iTHSOG5b3oUtlszU3acDZYKmJ0RrykIbZJRNcJxroUa/r8Z+xGDQoLaRMFBn0pUt67n63qpA+jzhQBc/rmqAwEfSYbr1v8jJ21uFaywHo= 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 1600892081665470.69857646357957; Wed, 23 Sep 2020 13:14: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-413-1Ak41HqtMeysGWwUhCXofg-1; Wed, 23 Sep 2020 16:14:37 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 58580805EE8; Wed, 23 Sep 2020 20:14:31 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 36F051002C03; Wed, 23 Sep 2020 20:14:31 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 03CF18C7C9; Wed, 23 Sep 2020 20:14:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 08NKBLXM028471 for ; Wed, 23 Sep 2020 16:11:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id B35F05D990; Wed, 23 Sep 2020 20:11:21 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A61D5D98D for ; Wed, 23 Sep 2020 20:11:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600892080; 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=XafskzOTuE98lCdZ45PcR9uug5dLT1CJ4MUoo457DmM=; b=KFIJq04DY7mv16AEXfT23R7Dm+AgfgYrM062rjttpRnGvYYQtgtind0K/TNJo5NB6++QFy M4jRm3GJskpdd1oOFRSAe5vh8UaLriA+8taru8FV8vm1Q3IlMV5DpQwLVwyO6+8hd6Bo62 Dxcm85ebxKlugWMwFZVhpWChLwKjGJI= X-MC-Unique: 1Ak41HqtMeysGWwUhCXofg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 5/5] tools: use g_new0 instead of VIR_ALLOC* Date: Wed, 23 Sep 2020 22:11:08 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) With the exception of vsh*alloc. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Daniel Henrique Barboza --- tools/virsh-domain-monitor.c | 11 +++-------- tools/virsh-domain.c | 26 ++++++++------------------ tools/virt-admin-completer.c | 12 +----------- tools/virt-login-shell-helper.c | 13 ++++--------- tools/vsh-table.c | 21 +++++++-------------- tools/vsh.c | 5 +---- 6 files changed, 24 insertions(+), 64 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 848efc8aa3..c8a7c0f1b7 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -1234,8 +1234,7 @@ cmdDomBlkError(vshControl *ctl, const vshCmd *cmd) ndisks =3D count; =20 if (ndisks) { - if (VIR_ALLOC_N(disks, ndisks) < 0) - goto cleanup; + disks =3D g_new0(virDomainDiskError, ndisks); =20 if ((count =3D virDomainGetDiskErrors(dom, disks, ndisks, 0)) =3D= =3D -1) goto cleanup; @@ -1378,10 +1377,7 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd) vshPrint(ctl, "%-15s %s\n", _("Security DOI:"), secmodel.doi); =20 /* Security labels are only valid for active domains */ - if (VIR_ALLOC(seclabel) < 0) { - virshDomainFree(dom); - return false; - } + seclabel =3D g_new0(virSecurityLabel, 1); =20 if (virDomainGetSecurityLabel(dom, seclabel) =3D=3D -1) { virshDomainFree(dom); @@ -2280,8 +2276,7 @@ cmdDomstats(vshControl *ctl, const vshCmd *cmd) flags |=3D VIR_CONNECT_GET_ALL_DOMAINS_STATS_NOWAIT; =20 if (vshCommandOptBool(cmd, "domain")) { - if (VIR_ALLOC_N(domlist, 1) < 0) - goto cleanup; + domlist =3D g_new0(virDomainPtr, 1); ndoms =3D 1; =20 while ((opt =3D vshCommandOptArgv(ctl, cmd, opt))) { diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 32edfc0398..dfcba04682 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -1762,8 +1762,7 @@ virshBlockJobWaitInit(vshControl *ctl, virshBlockJobWaitDataPtr ret; virshControlPtr priv =3D ctl->privData; =20 - if (VIR_ALLOC(ret) < 0) - return NULL; + ret =3D g_new0(virshBlockJobWaitData, 1); =20 ret->ctl =3D ctl; ret->dom =3D dom; @@ -8177,8 +8176,7 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd) goto cleanup; } =20 - if (VIR_ALLOC_N(params, nparams * MIN(show_count, 128)) < 0) - goto cleanup; + params =3D g_new0(virTypedParameter, nparams * MIN(show_count, 128)); =20 while (show_count) { int ncpus =3D MIN(show_count, 128); @@ -8215,8 +8213,7 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd) goto cleanup; } =20 - if (VIR_ALLOC_N(params, nparams) < 0) - goto cleanup; + params =3D g_new0(virTypedParameter, nparams); =20 /* passing start_cpu =3D=3D -1 gives us domain's total status */ if ((stats_per_cpu =3D virDomainGetCPUStats(dom, params, nparams, @@ -10086,14 +10083,9 @@ cmdLxcEnterNamespace(vshControl *ctl, const vshCmd= *cmd) goto cleanup; =20 if (setlabel) { - if (VIR_ALLOC(secmodel) < 0) { - vshError(ctl, "%s", _("Failed to allocate security model")); - goto cleanup; - } - if (VIR_ALLOC(seclabel) < 0) { - vshError(ctl, "%s", _("Failed to allocate security label")); - goto cleanup; - } + secmodel =3D g_new0(virSecurityModel, 1); + seclabel =3D g_new0(virSecurityLabel, 1); + if (virNodeGetSecurityModel(priv->conn, secmodel) < 0) goto cleanup; if (virDomainGetSecurityLabel(dom, seclabel) < 0) @@ -13737,8 +13729,7 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd) } =20 if (all) { - if (VIR_ALLOC_N(data, VIR_DOMAIN_EVENT_ID_LAST) < 0) - goto cleanup; + data =3D g_new0(virshDomEventData, VIR_DOMAIN_EVENT_ID_LAST); for (i =3D 0; i < VIR_DOMAIN_EVENT_ID_LAST; i++) { data[i].ctl =3D ctl; data[i].loop =3D loop; @@ -13748,8 +13739,7 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd) data[i].id =3D -1; } } else { - if (VIR_ALLOC_N(data, 1) < 0) - goto cleanup; + data =3D g_new0(virshDomEventData, 1); data[0].ctl =3D ctl; data[0].loop =3D vshCommandOptBool(cmd, "loop"); data[0].count =3D &count; diff --git a/tools/virt-admin-completer.c b/tools/virt-admin-completer.c index 7201bb71eb..61004beeb5 100644 --- a/tools/virt-admin-completer.c +++ b/tools/virt-admin-completer.c @@ -46,8 +46,7 @@ vshAdmServerCompleter(vshControl *ctl, if ((nsrvs =3D virAdmConnectListServers(priv->conn, &srvs, 0)) < 0) return NULL; =20 - if (VIR_ALLOC_N(ret, nsrvs + 1) < 0) - goto error; + ret =3D g_new0(char *, nsrvs + 1); =20 for (i =3D 0; i < nsrvs; i++) { const char *name =3D virAdmServerGetName(srvs[i]); @@ -59,13 +58,4 @@ vshAdmServerCompleter(vshControl *ctl, VIR_FREE(srvs); =20 return ret; - - error: - for (; i < nsrvs; i++) - virAdmServerFree(srvs[i]); - VIR_FREE(srvs); - for (i =3D 0; i < nsrvs; i++) - VIR_FREE(ret[i]); - VIR_FREE(ret); - return ret; } diff --git a/tools/virt-login-shell-helper.c b/tools/virt-login-shell-helpe= r.c index cc6836382a..0e7987bf82 100644 --- a/tools/virt-login-shell-helper.c +++ b/tools/virt-login-shell-helper.c @@ -99,7 +99,7 @@ static int virLoginShellGetShellArgv(virConfPtr conf, return -1; =20 if (rv =3D=3D 0) { - if (VIR_ALLOC_N(*shargv, 2) < 0) + *shargv =3D g_new0(char *, 2); return -1; (*shargv)[0] =3D g_strdup("/bin/sh"); *shargvlen =3D 1; @@ -302,10 +302,8 @@ main(int argc, char **argv) =20 if ((nfdlist =3D virDomainLxcOpenNamespace(dom, &fdlist, 0)) < 0) goto cleanup; - if (VIR_ALLOC(secmodel) < 0) - goto cleanup; - if (VIR_ALLOC(seclabel) < 0) - goto cleanup; + secmodel =3D g_new0(virSecurityModel, 1); + seclabel =3D g_new0(virSecurityLabel, 1); if (virNodeGetSecurityModel(conn, secmodel) < 0) goto cleanup; if (virDomainGetSecurityLabel(dom, seclabel) < 0) @@ -331,10 +329,7 @@ main(int argc, char **argv) if (tmp) { g_strfreev(shargv); shargvlen =3D 1; - if (VIR_ALLOC_N(shargv[0], shargvlen + 1) < 0) { - VIR_FREE(tmp); - goto cleanup; - } + shargv =3D g_new0(char *, shargvlen + 1); shargv[0] =3D tmp; shargv[1] =3D NULL; } diff --git a/tools/vsh-table.c b/tools/vsh-table.c index a727ac17b5..4471368687 100644 --- a/tools/vsh-table.c +++ b/tools/vsh-table.c @@ -95,8 +95,7 @@ vshTableRowNew(const char *arg, va_list ap) goto error; } =20 - if (VIR_ALLOC(row) < 0) - goto error; + row =3D g_new0(vshTableRow, 1); =20 while (arg) { char *tmp =3D NULL; @@ -134,8 +133,7 @@ vshTableNew(const char *arg, ...) vshTableRowPtr header =3D NULL; va_list ap; =20 - if (VIR_ALLOC(table) < 0) - goto error; + table =3D g_new0(vshTable, 1); =20 va_start(ap, arg); header =3D vshTableRowNew(arg, ap); @@ -215,8 +213,7 @@ vshTableSafeEncode(const char *s, size_t *width) =20 memset(&st, 0, sizeof(st)); =20 - if (VIR_ALLOC_N(buf, (sz * HEX_ENCODE_LENGTH) + 1) < 0) - return NULL; + buf =3D g_new0(char, (sz * HEX_ENCODE_LENGTH) + 1); =20 ret =3D buf; *width =3D 0; @@ -369,17 +366,13 @@ vshTablePrint(vshTablePtr table, bool header) g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; char *ret =3D NULL; =20 - if (VIR_ALLOC_N(maxwidths, table->rows[0]->ncells)) - goto cleanup; + maxwidths =3D g_new0(size_t, table->rows[0]->ncells); =20 - if (VIR_ALLOC_N(widths, table->nrows)) - goto cleanup; + widths =3D g_new0(size_t *, table->nrows); =20 /* retrieve widths of columns */ - for (i =3D 0; i < table->nrows; i++) { - if (VIR_ALLOC_N(widths[i], table->rows[0]->ncells)) - goto cleanup; - } + for (i =3D 0; i < table->nrows; i++) + widths[i] =3D g_new0(size_t, table->rows[0]->ncells); =20 if (vshTableGetColumnsWidths(table, maxwidths, widths, header) < 0) goto cleanup; diff --git a/tools/vsh.c b/tools/vsh.c index 87c409e4aa..0eddd5349d 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -162,10 +162,7 @@ vshStringToArray(const char *str, } =20 /* reserve the NULL element at the end */ - if (VIR_ALLOC_N(arr, nstr_tokens + 1) < 0) { - VIR_FREE(str_copied); - return -1; - } + arr =3D g_new0(char *, nstr_tokens + 1); =20 /* tokenize the input string, while treating ,, as a literal comma */ nstr_tokens =3D 0; --=20 2.26.2