From nobody Sun May 5 17:07:13 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=1628757548; cv=none; d=zohomail.com; s=zohoarc; b=bGJisRVl0GWbQS5YdiTYm71pHmAM1CzU9aS1jbHHuAerJv4GbUKP54q7cH+8cZpvWmC8J6E7hpvBdZMzdqmCRMO7xGCypgmjPgKC60P5fFlDP/mu/vcVWjwn8MHrHhNbGHzobB+fb+AkdmpvtZCKEJHWugUDBHIYmRyUR5gSMG0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628757548; 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=uqC3A+AGkEdeq7ksnoPbsL1y0tRUkW+/kvj4dFAZMM0=; b=nv0M2F9Q/MKThfwt6vyH78kR1/jIxp0BAYCdf8oIvYdySfq4G6QpNN8nEJBX5nHfxm9y/Kap+VtYsN9dBZjyZ3zNLnqkV4/Wlg0SncDCVbLpMph9NPOkxCn8tJklLgxZeKnTZFXb3HC3peYqTZBAAzL4o2xYHh2cLw1gyJ71AcA= 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) 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 1628757548748654.977134485061; Thu, 12 Aug 2021 01:39: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-593-w7pFhKfrNfi3iyXPA8MJPg-1; Thu, 12 Aug 2021 04:39:06 -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 E8E25801B3C; Thu, 12 Aug 2021 08:39:00 +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 B1A9A620DE; Thu, 12 Aug 2021 08:39:00 +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 4EC124BB7C; Thu, 12 Aug 2021 08:39:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17C8Ww6s003589 for ; Thu, 12 Aug 2021 04:32:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0BDE210016FF; Thu, 12 Aug 2021 08:32:58 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8816110013C1 for ; Thu, 12 Aug 2021 08:32:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628757547; 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=uqC3A+AGkEdeq7ksnoPbsL1y0tRUkW+/kvj4dFAZMM0=; b=jABPWr5oyfiYHkFVDd4eHn7MP7Nf94Xq/K3yvac5Gu4XxAtSm5yITS2r+luAAx4f+FcBdh XU6mvlvSgKBREbNLvHJswtpb9vnhmRHN2t19x4wpfUADsZtlkvf8NLCfe56g8KYz6anQ7y rF8L7YX7yG0qMEO+AHG/QXj1MdzLluU= X-MC-Unique: w7pFhKfrNfi3iyXPA8MJPg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 01/12] util: define cleanup func for xmlXPathObject Date: Thu, 12 Aug 2021 10:32:39 +0200 Message-Id: <214fd2ea326fd75206febb03e4ca4e13de39c5aa.1628756993.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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) X-ZM-MESSAGEID: 1628757549582100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- src/util/virxml.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/virxml.h b/src/util/virxml.h index 0bb0d1c118..c8eb51a65a 100644 --- a/src/util/virxml.h +++ b/src/util/virxml.h @@ -363,6 +363,7 @@ G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(virXPathContextNodeSav= e, virXPathContextNodeRes =20 G_DEFINE_AUTOPTR_CLEANUP_FUNC(xmlDoc, xmlFreeDoc); G_DEFINE_AUTOPTR_CLEANUP_FUNC(xmlXPathContext, xmlXPathFreeContext); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(xmlXPathObject, xmlXPathFreeObject); G_DEFINE_AUTOPTR_CLEANUP_FUNC(xmlBuffer, xmlBufferFree); G_DEFINE_AUTOPTR_CLEANUP_FUNC(xmlNode, xmlFreeNode); G_DEFINE_AUTOPTR_CLEANUP_FUNC(xmlParserCtxt, xmlFreeParserCtxt); --=20 2.31.1 From nobody Sun May 5 17:07:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1628757555; cv=none; d=zohomail.com; s=zohoarc; b=K6macs3yuF0lU9uSbnyqiwOsjFjVKb8arA0Smbvxbnpwb0KNqis0Ry4dqOVzt8Rzbl2oN+I2jkDx3FI7duvuMhFLWHRcfsBu9lg4VILlAeIchx/i4EMor8WR6SmNhHm1ysCjNRIgP5sxJqjOWtrCKITlAREoe5O5oaAQfsdOFcw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628757555; 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=L6FuecCAwcIvVFIAf0CIv3Dqy+L6D1wZFtT4rNyTHjE=; b=BkZQP9LdEnbjzW9IE0dmhfUmTbprEa1spEO9PeyM8L91B3/0JDLQ1jcXqfnhybn6nZoive39NMixo24yVok/DKZaGlVwQ3oznn82EFR0/1N/pEVsBrS0Q2MCrYOA3x4ZRjXQzoKuJF5pCFSb56qtOQZ69C97HRQSqSllW3wTcDA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1628757555259437.64312091924035; Thu, 12 Aug 2021 01:39: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-542-CYCV3BvOOVmhKKtCDDX_Kg-1; Thu, 12 Aug 2021 04:39:12 -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 2939A1082925; Thu, 12 Aug 2021 08:39:07 +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 0B25D60C0F; Thu, 12 Aug 2021 08:39:07 +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 B3C32181A0F2; Thu, 12 Aug 2021 08:39:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17C8WwLU003599 for ; Thu, 12 Aug 2021 04:32:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id D213810016FF; Thu, 12 Aug 2021 08:32:58 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A5EB10013C1 for ; Thu, 12 Aug 2021 08:32:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628757554; 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=L6FuecCAwcIvVFIAf0CIv3Dqy+L6D1wZFtT4rNyTHjE=; b=T8MJ9euHSYkgc/EBfLzHgHV+ng3IVwE3rYhzyXGy7FNCQ9hI8RLti+vicj1R84qfg7EbEu H8NwMepF0PuACuKQ1WO2K78B8eTDCUN8Qdk0bj2FLFLrJktCveNGGsReHcn17LPla4AvJn MBP0GeLL4cDQDPIRoOx/6ihSRTYQW7Q= X-MC-Unique: CYCV3BvOOVmhKKtCDDX_Kg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 02/12] tools: virsh: split variable declarations Date: Thu, 12 Aug 2021 10:32:40 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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) X-ZM-MESSAGEID: 1628757556048100001 One variable per line. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- tools/virsh-domain.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 81f3c82094..ae979ddd49 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -5912,7 +5912,8 @@ cmdShutdown(vshControl *ctl, const vshCmd *cmd) const char *mode =3D NULL; int flags =3D 0; int rv; - char **modes =3D NULL, **tmp; + char **modes =3D NULL; + char **tmp; =20 if (vshCommandOptStringReq(ctl, cmd, "mode", &mode) < 0) return false; @@ -5996,7 +5997,8 @@ cmdReboot(vshControl *ctl, const vshCmd *cmd) const char *name; const char *mode =3D NULL; int flags =3D 0; - char **modes =3D NULL, **tmp; + char **modes =3D NULL; + char **tmp; =20 if (vshCommandOptStringReq(ctl, cmd, "mode", &mode) < 0) return false; @@ -12166,7 +12168,8 @@ virshDomainDetachInterface(char *doc, xmlXPathObjectPtr obj =3D NULL; xmlXPathContextPtr ctxt =3D NULL; xmlNodePtr cur =3D NULL, matchNode =3D NULL; - char *detach_xml =3D NULL, buf[64]; + char *detach_xml =3D NULL; + char buf[64]; int diff_mac, ret =3D -1; size_t i; =20 --=20 2.31.1 From nobody Sun May 5 17:07:13 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=1628757606; cv=none; d=zohomail.com; s=zohoarc; b=IuBWay4RflIuLWB4T8v76LDoX2Wb6mU44kyf+7IEFY6kmnIeXgEggLu/gh1NhCURBYLz3LAw/Sg2wckZo+c2GbImFIGSKCv7sFL6eTZ0oXbNoi6TM0FNzwVUtyYB51cBic5gE7qeqTqbnRtZ5A4xpB8PgYMDzETjP4VfEWfEvC8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628757606; 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=RTwD5pe+NoqF63Ci/mupFQyTIz/tmLH5ZICHeKLFtOI=; b=mGzfoeeEfZt0blGE+DHvjp8JGLaWIPKgao67H9WdSiBjCPeVUt2PRjXiqnXMrqB5EakrqhArVXb7CNAxoiFNc1kqOUMGbJzIEuQTDzfi/BPI3olU35CdX73VUaRpVo3/NtBwty86drrpnSioK+O3brKjIVX3OB2E0Cj0hUUXgI8= 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) 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 1628757606293559.5145020726393; Thu, 12 Aug 2021 01:40:06 -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-603-nNT3ScwDNGqd4Rb7kxRcMg-1; Thu, 12 Aug 2021 04:39:30 -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 4F0D81082923; Thu, 12 Aug 2021 08:39: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 0B9A877708; Thu, 12 Aug 2021 08:39:25 +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 B20EA4A7CA; Thu, 12 Aug 2021 08:39:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17C8X3Wm003633 for ; Thu, 12 Aug 2021 04:33:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6A33B10013C1; Thu, 12 Aug 2021 08:33:03 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5CEA10429FC for ; Thu, 12 Aug 2021 08:32:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628757605; 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=RTwD5pe+NoqF63Ci/mupFQyTIz/tmLH5ZICHeKLFtOI=; b=Xunt+1bUslOeYgTL4giVgSJjRwjjQ06+wDcq6UDm5zNLrQpRZ1E7WFgG5EVMowHYYVYRdq HTSJEmbrmqdxUn3MevgwAcBGG6dAVeutQgAYrPSPMs8lC+rCHoggGVdLPlQcUZwn+y874c 9JBbTu+SojIfhLaLvkATCGuOkYn5iWk= X-MC-Unique: nNT3ScwDNGqd4Rb7kxRcMg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 03/12] tools: virsh: cmdDominfo: rename 'ostype' variable Date: Thu, 12 Aug 2021 10:32:41 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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) X-ZM-MESSAGEID: 1628757607822100001 Use 'ostype' instead of generic 'str', to discourage reuse. Also mark it as autofree. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- tools/virsh-domain-monitor.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index a2bf5c05fc..cf0803dcd3 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -1288,7 +1288,8 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd) bool ret =3D true; int autostart; unsigned int id; - char *str, uuid[VIR_UUID_STRING_BUFLEN]; + char uuid[VIR_UUID_STRING_BUFLEN]; + g_autofree char *ostype =3D NULL; int has_managed_save =3D 0; virshControl *priv =3D ctl->privData; g_auto(GStrv) messages =3D NULL; @@ -1306,10 +1307,8 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd) if (virDomainGetUUIDString(dom, &uuid[0]) =3D=3D 0) vshPrint(ctl, "%-15s %s\n", _("UUID:"), uuid); =20 - if ((str =3D virDomainGetOSType(dom))) { - vshPrint(ctl, "%-15s %s\n", _("OS Type:"), str); - VIR_FREE(str); - } + if ((ostype =3D virDomainGetOSType(dom))) + vshPrint(ctl, "%-15s %s\n", _("OS Type:"), ostype); =20 if (virDomainGetInfo(dom, &info) =3D=3D 0) { vshPrint(ctl, "%-15s %s\n", _("State:"), --=20 2.31.1 From nobody Sun May 5 17:07:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1628757576; cv=none; d=zohomail.com; s=zohoarc; b=DO/5GWyksFtRemNbvt3eQW68Lyd6rMNeWWHA9y/pMVyrN+qlfO73LzcASiToXCCoG2RG3ZPtBweiDU/UjuBfMbM4kYKMBwgyrCQbNWf5AqSTw1dQv6wsd2IaIIOu4Mx9jigiwm0XxZPFh/PeZTW5vzLdZnlUCjJQlmgaJMn5oJE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628757576; 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=7rZSUinwx6cLDYicwyIJBKaBQj8QSJ8wOCY9utcqc48=; b=PdUWJ8qHbnwd8mxseZ99miUNJ0ITukU0BxrrVna+JKhIpmebH9ZY0vFmqRrKOEKHfY7mlfwUAcO3j2E4JnKgEeImrM1AEZfHSPdsLnjTQeDsjC7shO3VXgw7ECeYIQDrQeeN4c4qnRZ3p8296RR2YQrQJ2hFuHoFCbdIi+rbKO8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1628757576851637.007157100834; Thu, 12 Aug 2021 01:39: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-534-pYjL0hXxOcqfSIjXdny4NQ-1; Thu, 12 Aug 2021 04:39:33 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F0D9C190A7A6; Thu, 12 Aug 2021 08:39:27 +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 C50E22855E; Thu, 12 Aug 2021 08:39:27 +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 93F22181A2A6; Thu, 12 Aug 2021 08:39:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17C8X7Q6003646 for ; Thu, 12 Aug 2021 04:33:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id AF60F10013C1; Thu, 12 Aug 2021 08:33:07 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id DDC6610074E1 for ; Thu, 12 Aug 2021 08:33:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628757575; 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=7rZSUinwx6cLDYicwyIJBKaBQj8QSJ8wOCY9utcqc48=; b=cceZ0r1sWbBQLIJh0IQ0+8+lzPXq04fRwSA4nO21ICznWrP9GYppWVeVjcDw8Q6bIwgMtW PS5F+KkpO+ltb52ba2cZ1VCkw32gZbpbFojrv/nq37jKCExxZRiDkHCBWa+dpNLg1U4PqV zfMxxTYR2rtaGzA4ORxQ/R/ZOC5BWVs= X-MC-Unique: pYjL0hXxOcqfSIjXdny4NQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 04/12] tools: virsh: use automatic cleanup for virDomainObj Date: Thu, 12 Aug 2021 10:32:42 +0200 Message-Id: <9ca60ece1cba4deb58bf7c84a2470609e74c97c1.1628756993.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1628757577821100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- tools/virsh-completer-checkpoint.c | 4 +- tools/virsh-completer-domain.c | 15 +- tools/virsh-completer-snapshot.c | 3 +- tools/virsh-domain-monitor.c | 29 +-- tools/virsh-domain.c | 303 ++++++++++------------------- 5 files changed, 116 insertions(+), 238 deletions(-) diff --git a/tools/virsh-completer-checkpoint.c b/tools/virsh-completer-che= ckpoint.c index 1296741061..b6d6c93e85 100644 --- a/tools/virsh-completer-checkpoint.c +++ b/tools/virsh-completer-checkpoint.c @@ -32,7 +32,7 @@ virshCheckpointNameCompleter(vshControl *ctl, unsigned int flags) { virshControl *priv =3D ctl->privData; - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; virDomainCheckpointPtr *checkpoints =3D NULL; int ncheckpoints =3D 0; size_t i =3D 0; @@ -60,7 +60,6 @@ virshCheckpointNameCompleter(vshControl *ctl, virshDomainCheckpointFree(checkpoints[i]); } g_free(checkpoints); - virshDomainFree(dom); =20 return ret; =20 @@ -71,6 +70,5 @@ virshCheckpointNameCompleter(vshControl *ctl, for (i =3D 0; i < ncheckpoints; i++) g_free(ret[i]); g_free(ret); - virshDomainFree(dom); return NULL; } diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index 0df11807e1..d1430c951a 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -442,7 +442,7 @@ virshDomainIOThreadIdCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; size_t niothreads =3D 0; g_autofree virDomainIOThreadInfoPtr *info =3D NULL; size_t i; @@ -468,7 +468,6 @@ virshDomainIOThreadIdCompleter(vshControl *ctl, ret =3D g_steal_pointer(&tmp); =20 cleanup: - virshDomainFree(dom); return ret; } =20 @@ -478,7 +477,7 @@ virshDomainVcpuCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; xmlDocPtr xml =3D NULL; xmlXPathContextPtr ctxt =3D NULL; int nvcpus =3D 0; @@ -509,7 +508,6 @@ virshDomainVcpuCompleter(vshControl *ctl, cleanup: xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); - virshDomainFree(dom); return ret; } =20 @@ -519,7 +517,7 @@ virshDomainVcpulistCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; xmlDocPtr xml =3D NULL; xmlXPathContextPtr ctxt =3D NULL; int nvcpus =3D 0; @@ -554,7 +552,6 @@ virshDomainVcpulistCompleter(vshControl *ctl, cleanup: xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); - virshDomainFree(dom); return ret; } =20 @@ -594,7 +591,7 @@ virshDomainVcpulistViaAgentCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; bool enable =3D vshCommandOptBool(cmd, "enable"); bool disable =3D vshCommandOptBool(cmd, "disable"); virTypedParameterPtr params =3D NULL; @@ -690,7 +687,6 @@ virshDomainVcpulistViaAgentCompleter(vshControl *ctl, =20 cleanup: virTypedParamsFree(params, nparams); - virshDomainFree(dom); return ret; } =20 @@ -908,7 +904,7 @@ virshDomainFSMountpointsCompleter(vshControl *ctl, unsigned int flags) { g_auto(GStrv) tmp =3D NULL; - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; int rc =3D -1; size_t i; virDomainFSInfoPtr *info =3D NULL; @@ -938,7 +934,6 @@ virshDomainFSMountpointsCompleter(vshControl *ctl, virDomainFSInfoFree(info[i]); VIR_FREE(info); } - virshDomainFree(dom); return ret; } =20 diff --git a/tools/virsh-completer-snapshot.c b/tools/virsh-completer-snaps= hot.c index e8109ee1e2..535841cf2e 100644 --- a/tools/virsh-completer-snapshot.c +++ b/tools/virsh-completer-snapshot.c @@ -32,7 +32,7 @@ virshSnapshotNameCompleter(vshControl *ctl, unsigned int flags) { virshControl *priv =3D ctl->privData; - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; virDomainSnapshotPtr *snapshots =3D NULL; int rc; int nsnapshots =3D 0; @@ -63,7 +63,6 @@ virshSnapshotNameCompleter(vshControl *ctl, ret =3D g_steal_pointer(&tmp); =20 cleanup: - virshDomainFree(dom); for (i =3D 0; i < nsnapshots; i++) virshDomainSnapshotFree(snapshots[i]); g_free(snapshots); diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index cf0803dcd3..d79f807d8b 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -296,7 +296,7 @@ static const vshCmdOptDef opts_dommemstat[] =3D { static bool cmdDomMemStat(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; const char *name; virDomainMemoryStatStruct stats[VIR_DOMAIN_MEMORY_STAT_NR]; unsigned int nr_stats; @@ -381,7 +381,6 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd) =20 ret =3D true; cleanup: - virshDomainFree(dom); return ret; } =20 @@ -905,7 +904,7 @@ static const vshCmdOptDef opts_domcontrol[] =3D { static bool cmdDomControl(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D true; virDomainControlInfo info; =20 @@ -932,7 +931,6 @@ cmdDomControl(vshControl *ctl, const vshCmd *cmd) } =20 cleanup: - virshDomainFree(dom); return ret; } =20 @@ -1006,7 +1004,7 @@ static const struct _domblkstat_sequence domblkstat_o= utput[] =3D { static bool cmdDomblkstat(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; const char *name =3D NULL, *device =3D NULL; virDomainBlockStatsStruct stats; virTypedParameterPtr params =3D NULL; @@ -1118,7 +1116,6 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd) =20 cleanup: VIR_FREE(params); - virshDomainFree(dom); return ret; } #undef DOMBLKSTAT_LEGACY_PRINT @@ -1150,7 +1147,7 @@ static const vshCmdOptDef opts_domifstat[] =3D { static bool cmdDomIfstat(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; const char *name =3D NULL, *device =3D NULL; virDomainInterfaceStatsStruct stats; bool ret =3D false; @@ -1193,7 +1190,6 @@ cmdDomIfstat(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - virshDomainFree(dom); return ret; } =20 @@ -1218,7 +1214,7 @@ static const vshCmdOptDef opts_domblkerror[] =3D { static bool cmdDomBlkError(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; virDomainDiskErrorPtr disks =3D NULL; unsigned int ndisks =3D 0; size_t i; @@ -1255,7 +1251,6 @@ cmdDomBlkError(vshControl *ctl, const vshCmd *cmd) for (i =3D 0; i < ndisks; i++) VIR_FREE(disks[i].disk); VIR_FREE(disks); - virshDomainFree(dom); return ret; } =20 @@ -1281,7 +1276,7 @@ static bool cmdDominfo(vshControl *ctl, const vshCmd *cmd) { virDomainInfo info; - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; virSecurityModel secmodel; virSecurityLabelPtr seclabel; int persistent =3D 0; @@ -1364,7 +1359,6 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd) memset(&secmodel, 0, sizeof(secmodel)); if (virNodeGetSecurityModel(priv->conn, &secmodel) =3D=3D -1) { if (last_error->code !=3D VIR_ERR_NO_SUPPORT) { - virshDomainFree(dom); return false; } else { vshResetLibvirtError(); @@ -1379,7 +1373,6 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd) seclabel =3D g_new0(virSecurityLabel, 1); =20 if (virDomainGetSecurityLabel(dom, seclabel) =3D=3D -1) { - virshDomainFree(dom); VIR_FREE(seclabel); return false; } else { @@ -1400,7 +1393,6 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd) } } =20 - virshDomainFree(dom); return ret; } =20 @@ -1429,7 +1421,7 @@ static const vshCmdOptDef opts_domstate[] =3D { static bool cmdDomstate(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D true; bool showReason =3D vshCommandOptBool(cmd, "reason"); int state, reason; @@ -1452,7 +1444,6 @@ cmdDomstate(vshControl *ctl, const vshCmd *cmd) } =20 cleanup: - virshDomainFree(dom); return ret; } =20 @@ -1493,7 +1484,7 @@ static const vshCmdOptDef opts_domtime[] =3D { static bool cmdDomTime(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D false; bool now =3D vshCommandOptBool(cmd, "now"); bool pretty =3D vshCommandOptBool(cmd, "pretty"); @@ -1552,7 +1543,6 @@ cmdDomTime(vshControl *ctl, const vshCmd *cmd) =20 ret =3D true; cleanup: - virshDomainFree(dom); return ret; } =20 @@ -2385,7 +2375,7 @@ VIR_ENUM_IMPL(virshDomainInterfaceAddressesSource, static bool cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; const char *ifacestr =3D NULL; virDomainInterfacePtr *ifaces =3D NULL; size_t i, j; @@ -2478,7 +2468,6 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd) } VIR_FREE(ifaces); =20 - virshDomainFree(dom); return ret; } =20 diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index ae979ddd49..b671ae398f 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -321,7 +321,7 @@ static const vshCmdOptDef opts_attach_device[] =3D { static bool cmdAttachDevice(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; const char *from =3D NULL; char *buffer; int rv; @@ -373,7 +373,6 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - virshDomainFree(dom); return ret; } =20 @@ -882,7 +881,7 @@ virshParseRateStr(vshControl *ctl, static bool cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; const char *mac =3D NULL, *target =3D NULL, *script =3D NULL, *type =3D NULL, *source =3D NULL, *model =3D NULL, *inboundStr =3D NULL, *outboundStr =3D NULL, *alias =3D NUL= L; @@ -1074,7 +1073,6 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) =20 cleanup: VIR_FREE(xml); - virshDomainFree(dom); return functionReturn; } =20 @@ -1103,7 +1101,7 @@ static const vshCmdOptDef opts_autostart[] =3D { static bool cmdAutostart(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; const char *name; int autostart; =20 @@ -1117,7 +1115,6 @@ cmdAutostart(vshControl *ctl, const vshCmd *cmd) vshError(ctl, _("Failed to mark domain '%s' as autostarted"), = name); else vshError(ctl, _("Failed to unmark domain '%s' as autostarted")= , name); - virshDomainFree(dom); return false; } =20 @@ -1126,7 +1123,6 @@ cmdAutostart(vshControl *ctl, const vshCmd *cmd) else vshPrintExtra(ctl, _("Domain '%s' unmarked as autostarted\n"), nam= e); =20 - virshDomainFree(dom); return true; } =20 @@ -1320,7 +1316,7 @@ static const vshCmdOptDef opts_blkdeviotune[] =3D { static bool cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; const char *name, *disk; const char *group_name =3D NULL; unsigned long long value; @@ -1441,7 +1437,6 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd) =20 cleanup: virTypedParamsFree(params, nparams); - virshDomainFree(dom); return ret; =20 save_error: @@ -1506,7 +1501,7 @@ static const vshCmdOptDef opts_blkiotune[] =3D { static bool cmdBlkiotune(vshControl * ctl, const vshCmd * cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; const char *device_weight =3D NULL; const char *device_riops =3D NULL; const char *device_wiops =3D NULL; @@ -1638,7 +1633,6 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd) =20 cleanup: virTypedParamsFree(params, nparams); - virshDomainFree(dom); return ret; =20 save_error: @@ -2019,7 +2013,7 @@ static const vshCmdOptDef opts_blockcommit[] =3D { static bool cmdBlockcommit(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D false; bool verbose =3D vshCommandOptBool(cmd, "verbose"); bool pivot =3D vshCommandOptBool(cmd, "pivot"); @@ -2156,7 +2150,6 @@ cmdBlockcommit(vshControl *ctl, const vshCmd *cmd) =20 ret =3D true; cleanup: - virshDomainFree(dom); virshBlockJobWaitFree(bjWait); return ret; } @@ -2262,7 +2255,7 @@ static const vshCmdOptDef opts_blockcopy[] =3D { static bool cmdBlockcopy(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; const char *dest =3D NULL; const char *format =3D NULL; unsigned long bandwidth =3D 0; @@ -2473,7 +2466,6 @@ cmdBlockcopy(vshControl *ctl, const vshCmd *cmd) cleanup: VIR_FREE(xmlstr); virTypedParamsFree(params, nparams); - virshDomainFree(dom); virshBlockJobWaitFree(bjWait); return ret; } @@ -2683,7 +2675,7 @@ cmdBlockjob(vshControl *ctl, const vshCmd *cmd) bool async =3D vshCommandOptBool(cmd, "async"); bool info =3D vshCommandOptBool(cmd, "info"); bool bandwidth =3D vshCommandOptBool(cmd, "bandwidth"); - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; const char *path; =20 VSH_EXCLUSIVE_OPTIONS("raw", "abort"); @@ -2715,7 +2707,6 @@ cmdBlockjob(vshControl *ctl, const vshCmd *cmd) ret =3D virshBlockJobInfo(ctl, dom, path, raw, bytes); =20 cleanup: - virshDomainFree(dom); return ret; } =20 @@ -2778,7 +2769,7 @@ static const vshCmdOptDef opts_blockpull[] =3D { static bool cmdBlockpull(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D false; bool blocking =3D vshCommandOptBool(cmd, "wait"); bool verbose =3D vshCommandOptBool(cmd, "verbose"); @@ -2861,7 +2852,6 @@ cmdBlockpull(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - virshDomainFree(dom); virshBlockJobWaitFree(bjWait); return ret; } @@ -2898,7 +2888,7 @@ static const vshCmdOptDef opts_blockresize[] =3D { static bool cmdBlockresize(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; const char *path =3D NULL; unsigned long long size =3D 0; unsigned int flags =3D 0; @@ -2926,7 +2916,6 @@ cmdBlockresize(vshControl *ctl, const vshCmd *cmd) ret =3D true; } =20 - virshDomainFree(dom); return ret; } =20 @@ -3000,7 +2989,7 @@ cmdRunConsole(vshControl *ctl, virDomainPtr dom, static bool cmdConsole(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D false; bool force =3D vshCommandOptBool(cmd, "force"); bool safe =3D vshCommandOptBool(cmd, "safe"); @@ -3021,7 +3010,6 @@ cmdConsole(vshControl *ctl, const vshCmd *cmd) ret =3D cmdRunConsole(ctl, dom, name, flags); =20 cleanup: - virshDomainFree(dom); return ret; } #endif /* WIN32 */ @@ -3064,7 +3052,7 @@ static const vshCmdOptDef opts_domif_setlink[] =3D { static bool cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; const char *iface; const char *state; char *value; @@ -3194,7 +3182,6 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); VIR_FREE(xml_buf); - virshDomainFree(dom); =20 return ret; } @@ -3236,7 +3223,7 @@ static const vshCmdOptDef opts_domiftune[] =3D { static bool cmdDomIftune(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; const char *name =3D NULL, *device =3D NULL, *inboundStr =3D NULL, *outboundStr =3D NULL; unsigned int flags =3D VIR_DOMAIN_AFFECT_CURRENT; @@ -3386,7 +3373,6 @@ cmdDomIftune(vshControl *ctl, const vshCmd *cmd) =20 cleanup: virTypedParamsFree(params, nparams); - virshDomainFree(dom); return ret; =20 save_error: @@ -3417,7 +3403,7 @@ static const vshCmdOptDef opts_suspend[] =3D { static bool cmdSuspend(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; const char *name; bool ret =3D true; =20 @@ -3431,7 +3417,6 @@ cmdSuspend(vshControl *ctl, const vshCmd *cmd) ret =3D false; } =20 - virshDomainFree(dom); return ret; } =20 @@ -3472,7 +3457,7 @@ static const vshCmdOptDef opts_dom_pm_suspend[] =3D { static bool cmdDomPMSuspend(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; const char *name; bool ret =3D false; const char *target =3D NULL; @@ -3505,7 +3490,6 @@ cmdDomPMSuspend(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - virshDomainFree(dom); return ret; } =20 @@ -3532,7 +3516,7 @@ static const vshCmdOptDef opts_dom_pm_wakeup[] =3D { static bool cmdDomPMWakeup(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; const char *name; bool ret =3D false; unsigned int flags =3D 0; @@ -3552,7 +3536,6 @@ cmdDomPMWakeup(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - virshDomainFree(dom); return ret; } =20 @@ -3625,7 +3608,7 @@ typedef struct { static bool cmdUndefine(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D false; const char *name =3D NULL; /* Flags to attempt. */ @@ -3974,7 +3957,6 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd) VIR_FREE(vol_nodes); xmlFreeDoc(doc); xmlXPathFreeContext(ctxt); - virshDomainFree(dom); return ret; =20 error: @@ -4077,7 +4059,7 @@ cmdStartGetFDs(vshControl *ctl, static bool cmdStart(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D false; #ifndef WIN32 bool console =3D vshCommandOptBool(cmd, "console"); @@ -4152,7 +4134,6 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - virshDomainFree(dom); VIR_FREE(fds); return ret; } @@ -4202,7 +4183,7 @@ doSave(void *opaque) virshCtrlData *data =3D opaque; vshControl *ctl =3D data->ctl; const vshCmd *cmd =3D data->cmd; - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; const char *name =3D NULL; const char *to =3D NULL; unsigned int flags =3D 0; @@ -4253,7 +4234,6 @@ doSave(void *opaque) pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL); out_sig: #endif /* !WIN32 */ - virshDomainFree(dom); VIR_FREE(xml); g_main_loop_quit(data->eventLoop); } @@ -4464,7 +4444,7 @@ virshWatchJob(vshControl *ctl, static bool cmdSave(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; virThread workerThread; bool verbose =3D false; const char *to =3D NULL; @@ -4502,7 +4482,6 @@ cmdSave(vshControl *ctl, const vshCmd *cmd) vshPrintExtra(ctl, _("\nDomain '%s' saved to %s\n"), name, to); =20 cleanup: - virshDomainFree(dom); return !data.ret; } =20 @@ -4735,7 +4714,7 @@ doManagedsave(void *opaque) virshCtrlData *data =3D opaque; vshControl *ctl =3D data->ctl; const vshCmd *cmd =3D data->cmd; - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; const char *name; unsigned int flags =3D 0; #ifndef WIN32 @@ -4768,14 +4747,13 @@ doManagedsave(void *opaque) pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL); out_sig: #endif /* !WIN32 */ - virshDomainFree(dom); g_main_loop_quit(data->eventLoop); } =20 static bool cmdManagedSave(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; bool verbose =3D false; const char *name =3D NULL; virThread workerThread; @@ -4809,7 +4787,6 @@ cmdManagedSave(vshControl *ctl, const vshCmd *cmd) vshPrintExtra(ctl, _("\nDomain '%s' state saved by libvirt\n"), na= me); =20 cleanup: - virshDomainFree(dom); return !data.ret; } =20 @@ -4834,7 +4811,7 @@ static const vshCmdOptDef opts_managedsaveremove[] = =3D { static bool cmdManagedSaveRemove(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; const char *name; bool ret =3D false; int hassave; @@ -4864,7 +4841,6 @@ cmdManagedSaveRemove(vshControl *ctl, const vshCmd *c= md) ret =3D true; =20 cleanup: - virshDomainFree(dom); return ret; } =20 @@ -4898,7 +4874,7 @@ static bool cmdManagedSaveEdit(vshControl *ctl, const vshCmd *cmd) { bool ret =3D false; - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; unsigned int getxml_flags =3D VIR_DOMAIN_XML_SECURE; unsigned int define_flags =3D 0; =20 @@ -4930,7 +4906,6 @@ cmdManagedSaveEdit(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - virshDomainFree(dom); return ret; } =20 @@ -4960,7 +4935,7 @@ static bool cmdManagedSaveDumpxml(vshControl *ctl, const vshCmd *cmd) { bool ret =3D false; - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; unsigned int flags =3D 0; char *xml =3D NULL; =20 @@ -4977,7 +4952,6 @@ cmdManagedSaveDumpxml(vshControl *ctl, const vshCmd *= cmd) ret =3D true; =20 cleanup: - virshDomainFree(dom); VIR_FREE(xml); return ret; } @@ -5017,7 +4991,7 @@ static bool cmdManagedSaveDefine(vshControl *ctl, const vshCmd *cmd) { bool ret =3D false; - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; const char *xmlfile =3D NULL; char *xml =3D NULL; unsigned int flags =3D 0; @@ -5049,7 +5023,6 @@ cmdManagedSaveDefine(vshControl *ctl, const vshCmd *c= md) ret =3D true; =20 cleanup: - virshDomainFree(dom); VIR_FREE(xml); return ret; } @@ -5186,7 +5159,7 @@ static bool cmdSchedinfo(vshControl *ctl, const vshCmd *cmd) { char *schedulertype; - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; virTypedParameterPtr params =3D NULL; virTypedParameterPtr updates =3D NULL; int nparams =3D 0; @@ -5283,7 +5256,6 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd) cleanup: virTypedParamsFree(params, nparams); virTypedParamsFree(updates, nupdates); - virshDomainFree(dom); return ret_val; } =20 @@ -5423,7 +5395,7 @@ doDump(void *opaque) virshCtrlData *data =3D opaque; vshControl *ctl =3D data->ctl; const vshCmd *cmd =3D data->cmd; - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; const char *name =3D NULL; const char *to =3D NULL; unsigned int flags =3D 0; @@ -5489,14 +5461,13 @@ doDump(void *opaque) pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL); out_sig: #endif /* !WIN32 */ - virshDomainFree(dom); g_main_loop_quit(data->eventLoop); } =20 static bool cmdDump(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; bool verbose =3D false; const char *name =3D NULL; const char *to =3D NULL; @@ -5534,7 +5505,6 @@ cmdDump(vshControl *ctl, const vshCmd *cmd) vshPrintExtra(ctl, _("\nDomain '%s' dumped to %s\n"), name, to); =20 cleanup: - virshDomainFree(dom); return !data.ret; } =20 @@ -5595,7 +5565,7 @@ virshGenFileName(vshControl *ctl, virDomainPtr dom, c= onst char *mime) static bool cmdScreenshot(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; const char *name =3D NULL; char *file =3D NULL; int fd =3D -1; @@ -5669,7 +5639,6 @@ cmdScreenshot(vshControl *ctl, const vshCmd *cmd) unlink(file); if (generated) VIR_FREE(file); - virshDomainFree(dom); if (st) virStreamFree(st); VIR_FORCE_CLOSE(fd); @@ -5728,7 +5697,7 @@ VIR_ENUM_IMPL(virshDomainLifecycleAction, static bool cmdSetLifecycleAction(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D true; bool config =3D vshCommandOptBool(cmd, "config"); bool live =3D vshCommandOptBool(cmd, "live"); @@ -5773,7 +5742,6 @@ cmdSetLifecycleAction(vshControl *ctl, const vshCmd *= cmd) ret =3D false; } =20 - virshDomainFree(dom); return ret; } =20 @@ -5812,7 +5780,7 @@ static const vshCmdOptDef opts_set_user_password[] = =3D { static bool cmdSetUserPassword(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; const char *name; const char *password =3D NULL; const char *user =3D NULL; @@ -5838,7 +5806,6 @@ cmdSetUserPassword(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - virshDomainFree(dom); return ret; } /* @@ -5862,7 +5829,7 @@ static const vshCmdOptDef opts_resume[] =3D { static bool cmdResume(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D true; const char *name; =20 @@ -5876,7 +5843,6 @@ cmdResume(vshControl *ctl, const vshCmd *cmd) ret =3D false; } =20 - virshDomainFree(dom); return ret; } =20 @@ -5906,7 +5872,7 @@ static const vshCmdOptDef opts_shutdown[] =3D { static bool cmdShutdown(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D false; const char *name; const char *mode =3D NULL; @@ -5961,7 +5927,6 @@ cmdShutdown(vshControl *ctl, const vshCmd *cmd) =20 ret =3D true; cleanup: - virshDomainFree(dom); g_strfreev(modes); return ret; } @@ -5992,7 +5957,7 @@ static const vshCmdOptDef opts_reboot[] =3D { static bool cmdReboot(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D false; const char *name; const char *mode =3D NULL; @@ -6042,7 +6007,6 @@ cmdReboot(vshControl *ctl, const vshCmd *cmd) =20 ret =3D true; cleanup: - virshDomainFree(dom); g_strfreev(modes); return ret; } @@ -6068,7 +6032,7 @@ static const vshCmdOptDef opts_reset[] =3D { static bool cmdReset(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D true; const char *name; =20 @@ -6082,7 +6046,6 @@ cmdReset(vshControl *ctl, const vshCmd *cmd) ret =3D false; } =20 - virshDomainFree(dom); return ret; } =20 @@ -6199,7 +6162,7 @@ static bool cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) { virDomainJobInfo info; - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D false; const char *unit; double val; @@ -6499,7 +6462,6 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - virshDomainFree(dom); virTypedParamsFree(params, nparams); return ret; =20 @@ -6529,7 +6491,7 @@ static const vshCmdOptDef opts_domjobabort[] =3D { static bool cmdDomjobabort(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D true; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) @@ -6538,7 +6500,6 @@ cmdDomjobabort(vshControl *ctl, const vshCmd *cmd) if (virDomainAbortJob(dom) < 0) ret =3D false; =20 - virshDomainFree(dom); return ret; } =20 @@ -6662,7 +6623,7 @@ virshCPUCountCollect(vshControl *ctl, static bool cmdVcpucount(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D false; bool maximum =3D vshCommandOptBool(cmd, "maximum"); bool active =3D vshCommandOptBool(cmd, "active"); @@ -6735,7 +6696,6 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - virshDomainFree(dom); return ret; } =20 @@ -7130,7 +7090,7 @@ virshParseCPUList(vshControl *ctl, int *cpumaplen, static bool cmdVcpuPin(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; unsigned int vcpu =3D 0; const char *cpulist =3D NULL; bool ret =3D false; @@ -7195,7 +7155,6 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd) =20 cleanup: VIR_FREE(cpumap); - virshDomainFree(dom); return ret; } =20 @@ -7229,7 +7188,7 @@ static const vshCmdOptDef opts_emulatorpin[] =3D { static bool cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; const char *cpulist =3D NULL; bool ret =3D false; unsigned char *cpumap =3D NULL; @@ -7257,13 +7216,11 @@ cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "cpulist", &cpulist) < 0) { - virshDomainFree(dom); return false; } query =3D !cpulist; =20 if ((maxcpu =3D virshNodeGetCPUCount(priv->conn)) < 0) { - virshDomainFree(dom); return false; } =20 @@ -7300,7 +7257,6 @@ cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd) ret =3D true; cleanup: VIR_FREE(cpumap); - virshDomainFree(dom); return ret; } =20 @@ -7345,7 +7301,7 @@ static const vshCmdOptDef opts_setvcpus[] =3D { static bool cmdSetvcpus(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; unsigned int count =3D 0; bool ret =3D false; bool maximum =3D vshCommandOptBool(cmd, "maximum"); @@ -7396,7 +7352,6 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - virshDomainFree(dom); return ret; } =20 @@ -7436,7 +7391,7 @@ static const vshCmdOptDef opts_guestvcpus[] =3D { static bool cmdGuestvcpus(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; bool enable =3D vshCommandOptBool(cmd, "enable"); bool disable =3D vshCommandOptBool(cmd, "disable"); virTypedParameterPtr params =3D NULL; @@ -7483,7 +7438,6 @@ cmdGuestvcpus(vshControl *ctl, const vshCmd *cmd) =20 cleanup: virTypedParamsFree(params, nparams); - virshDomainFree(dom); return ret; } =20 @@ -7526,7 +7480,7 @@ static const vshCmdOptDef opts_setvcpu[] =3D { static bool cmdSetvcpu(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; bool enable =3D vshCommandOptBool(cmd, "enable"); bool disable =3D vshCommandOptBool(cmd, "disable"); bool config =3D vshCommandOptBool(cmd, "config"); @@ -7566,7 +7520,6 @@ cmdSetvcpu(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - virshDomainFree(dom); return ret; } =20 @@ -7606,7 +7559,7 @@ cmdDomblkthreshold(vshControl *ctl, const vshCmd *cmd) { unsigned long long threshold; const char *dev =3D NULL; - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D false; =20 if (vshCommandOptStringReq(ctl, cmd, "dev", &dev)) @@ -7625,7 +7578,6 @@ cmdDomblkthreshold(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - virshDomainFree(dom); return ret; } =20 @@ -7653,7 +7605,7 @@ static const vshCmdOptDef opts_iothreadinfo[] =3D { static bool cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; bool config =3D vshCommandOptBool(cmd, "config"); bool live =3D vshCommandOptBool(cmd, "live"); bool current =3D vshCommandOptBool(cmd, "current"); @@ -7713,7 +7665,6 @@ cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd) virDomainIOThreadInfoFree(info[i]); VIR_FREE(info); vshTableFree(table); - virshDomainFree(dom); return ret; } =20 @@ -7753,7 +7704,7 @@ static const vshCmdOptDef opts_iothreadpin[] =3D { static bool cmdIOThreadPin(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; const char *cpulist =3D NULL; bool config =3D vshCommandOptBool(cmd, "config"); bool live =3D vshCommandOptBool(cmd, "live"); @@ -7797,7 +7748,6 @@ cmdIOThreadPin(vshControl *ctl, const vshCmd *cmd) =20 cleanup: VIR_FREE(cpumap); - virshDomainFree(dom); return ret; } =20 @@ -7830,7 +7780,7 @@ static const vshCmdOptDef opts_iothreadadd[] =3D { static bool cmdIOThreadAdd(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; int iothread_id =3D 0; bool ret =3D false; bool config =3D vshCommandOptBool(cmd, "config"); @@ -7862,7 +7812,6 @@ cmdIOThreadAdd(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - virshDomainFree(dom); return ret; } =20 @@ -7908,7 +7857,7 @@ static const vshCmdOptDef opts_iothreadset[] =3D { static bool cmdIOThreadSet(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; int id =3D 0; bool ret =3D false; bool live =3D vshCommandOptBool(cmd, "live"); @@ -7962,7 +7911,6 @@ cmdIOThreadSet(vshControl *ctl, const vshCmd *cmd) =20 cleanup: virTypedParamsFree(params, nparams); - virshDomainFree(dom); return ret; =20 save_error: @@ -8001,7 +7949,7 @@ static const vshCmdOptDef opts_iothreaddel[] =3D { static bool cmdIOThreadDel(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; int iothread_id =3D 0; bool ret =3D false; bool config =3D vshCommandOptBool(cmd, "config"); @@ -8033,7 +7981,6 @@ cmdIOThreadDel(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - virshDomainFree(dom); return ret; } =20 @@ -8090,7 +8037,7 @@ vshCPUStatsPrintField(vshControl *ctl, static bool cmdCPUStats(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; virTypedParameterPtr params =3D NULL; int max_id, cpu =3D 0, show_count =3D -1, nparams =3D 0, stats_per_cpu; size_t i, j; @@ -8211,7 +8158,6 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd) =20 cleanup: virTypedParamsFree(params, nparams); - virshDomainFree(dom); return ret; =20 failed_stats: @@ -8263,7 +8209,7 @@ static const vshCmdOptDef opts_create[] =3D { static bool cmdCreate(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; const char *from =3D NULL; bool ret =3D false; char *buffer; @@ -8307,7 +8253,6 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd) if (console) cmdRunConsole(ctl, dom, NULL, 0); #endif - virshDomainFree(dom); ret =3D true; =20 cleanup: @@ -8341,7 +8286,7 @@ static const vshCmdOptDef opts_define[] =3D { static bool cmdDefine(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; const char *from =3D NULL; bool ret =3D true; char *buffer; @@ -8366,7 +8311,6 @@ cmdDefine(vshControl *ctl, const vshCmd *cmd) if (dom !=3D NULL) { vshPrintExtra(ctl, _("Domain '%s' defined from %s\n"), virDomainGetName(dom), from); - virshDomainFree(dom); } else { vshError(ctl, _("Failed to define domain from %s"), from); ret =3D false; @@ -8399,7 +8343,7 @@ static const vshCmdOptDef opts_destroy[] =3D { static bool cmdDestroy(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D true; const char *name; unsigned int flags =3D 0; @@ -8423,7 +8367,6 @@ cmdDestroy(vshControl *ctl, const vshCmd *cmd) ret =3D false; } =20 - virshDomainFree(dom); return ret; } =20 @@ -8464,7 +8407,7 @@ static const vshCmdOptDef opts_desc[] =3D { static bool cmdDesc(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; bool config =3D vshCommandOptBool(cmd, "config"); bool live =3D vshCommandOptBool(cmd, "live"); bool current =3D vshCommandOptBool(cmd, "current"); @@ -8583,7 +8526,6 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd) unlink(tmp); VIR_FREE(tmp); } - virshDomainFree(dom); return ret; } =20 @@ -8650,7 +8592,7 @@ virshDomainGetEditMetadata(vshControl *ctl G_GNUC_UNU= SED, static bool cmdMetadata(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; bool config =3D vshCommandOptBool(cmd, "config"); bool live =3D vshCommandOptBool(cmd, "live"); bool current =3D vshCommandOptBool(cmd, "current"); @@ -8726,7 +8668,6 @@ cmdMetadata(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - virshDomainFree(dom); return ret; } =20 @@ -8811,7 +8752,7 @@ virshKeyCodeGetInt(const char *key_name) static bool cmdSendKey(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D false; const char *codeset_option; int codeset; @@ -8862,7 +8803,6 @@ cmdSendKey(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - virshDomainFree(dom); return ret; } =20 @@ -8993,7 +8933,7 @@ static const vshCmdOptDef opts_setmem[] =3D { static bool cmdSetmem(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; unsigned long long bytes =3D 0; unsigned long long max; unsigned long kibibytes =3D 0; @@ -9034,7 +8974,6 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd) =20 ret =3D true; cleanup: - virshDomainFree(dom); return ret; } =20 @@ -9071,7 +9010,7 @@ static const vshCmdOptDef opts_setmaxmem[] =3D { static bool cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; unsigned long long bytes =3D 0; unsigned long long max; unsigned long kibibytes =3D 0; @@ -9109,7 +9048,6 @@ cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd) =20 ret =3D true; cleanup: - virshDomainFree(dom); return ret; } =20 @@ -9197,7 +9135,7 @@ virshMemtuneGetSize(vshControl *ctl, const vshCmd *cm= d, static bool cmdMemtune(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; long long tmpVal; int nparams =3D 0; int maxparams =3D 0; @@ -9280,7 +9218,6 @@ cmdMemtune(vshControl *ctl, const vshCmd *cmd) =20 cleanup: virTypedParamsFree(params, nparams); - virshDomainFree(dom); return ret; =20 save_error: @@ -9366,7 +9303,7 @@ virshPrintPerfStatus(vshControl *ctl, virTypedParamet= erPtr params, int nparams) static bool cmdPerf(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; int nparams =3D 0; int maxparams =3D 0; virTypedParameterPtr params =3D NULL; @@ -9418,7 +9355,6 @@ cmdPerf(vshControl *ctl, const vshCmd *cmd) ret =3D true; cleanup: virTypedParamsFree(params, nparams); - virshDomainFree(dom); return ret; } =20 @@ -9459,7 +9395,7 @@ static const vshCmdOptDef opts_numatune[] =3D { static bool cmdNumatune(vshControl * ctl, const vshCmd * cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; int nparams =3D 0; int maxparams =3D 0; size_t i; @@ -9551,7 +9487,6 @@ cmdNumatune(vshControl * ctl, const vshCmd * cmd) =20 cleanup: virTypedParamsFree(params, nparams); - virshDomainFree(dom); return ret; =20 save_error: @@ -9761,7 +9696,7 @@ static const vshCmdOptDef opts_qemu_monitor_event[] = =3D { static bool cmdQemuMonitorEvent(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D false; unsigned int flags =3D 0; int eventId =3D -1; @@ -9819,7 +9754,6 @@ cmdQemuMonitorEvent(vshControl *ctl, const vshCmd *cm= d) if (eventId >=3D 0 && virConnectDomainQemuMonitorEventDeregister(priv->conn, eventId) < = 0) ret =3D false; - virshDomainFree(dom); =20 return ret; } @@ -9849,7 +9783,7 @@ static const vshCmdOptDef opts_qemu_attach[] =3D { static bool cmdQemuAttach(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; unsigned int flags =3D 0; unsigned int pid_value; /* API uses unsigned int, not pid_t */ virshControl *priv =3D ctl->privData; @@ -9864,7 +9798,6 @@ cmdQemuAttach(vshControl *ctl, const vshCmd *cmd) =20 vshPrintExtra(ctl, _("Domain '%s' attached to pid %u\n"), virDomainGetName(dom), pid_value); - virshDomainFree(dom); return true; } =20 @@ -9911,7 +9844,7 @@ static const vshCmdOptDef opts_qemu_agent_command[] = =3D { static bool cmdQemuAgentCommand(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D false; char *guest_agent_cmd =3D NULL; char *result =3D NULL; @@ -9979,7 +9912,6 @@ cmdQemuAgentCommand(vshControl *ctl, const vshCmd *cm= d) cleanup: VIR_FREE(result); VIR_FREE(guest_agent_cmd); - virshDomainFree(dom); =20 return ret; } @@ -10014,7 +9946,7 @@ static const vshCmdOptDef opts_lxc_enter_namespace[]= =3D { static bool cmdLxcEnterNamespace(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D false; const vshCmdOpt *opt =3D NULL; char **cmdargv =3D NULL; @@ -10109,7 +10041,6 @@ cmdLxcEnterNamespace(vshControl *ctl, const vshCmd = *cmd) cleanup: VIR_FREE(seclabel); VIR_FREE(secmodel); - virshDomainFree(dom); VIR_FREE(cmdargv); return ret; } @@ -10151,7 +10082,7 @@ static const vshCmdOptDef opts_dumpxml[] =3D { static bool cmdDumpXML(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D true; char *dump; unsigned int flags =3D 0; @@ -10180,7 +10111,6 @@ cmdDumpXML(vshControl *ctl, const vshCmd *cmd) ret =3D false; } =20 - virshDomainFree(dom); return ret; } =20 @@ -10278,7 +10208,7 @@ cmdDomXMLToNative(vshControl *ctl, const vshCmd *cm= d) char *xmlData =3D NULL; unsigned int flags =3D 0; virshControl *priv =3D ctl->privData; - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; =20 if (vshCommandOptStringReq(ctl, cmd, "format", &format) < 0 || vshCommandOptStringReq(ctl, cmd, "xml", &xmlFile) < 0) @@ -10313,7 +10243,6 @@ cmdDomXMLToNative(vshControl *ctl, const vshCmd *cm= d) } =20 cleanup: - virshDomainFree(dom); VIR_FREE(xmlData); VIR_FREE(configData); return ret; @@ -10345,14 +10274,13 @@ static const vshCmdOptDef opts_domname[] =3D { static bool cmdDomname(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; =20 if (!(dom =3D virshCommandOptDomainBy(ctl, cmd, NULL, VIRSH_BYID|VIRSH_BYUUID))) return false; =20 vshPrint(ctl, "%s\n", virDomainGetName(dom)); - virshDomainFree(dom); return true; } =20 @@ -10383,7 +10311,7 @@ static const vshCmdOptDef opts_domrename[] =3D { static bool cmdDomrename(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; const char *new_name =3D NULL; bool ret =3D false; =20 @@ -10400,7 +10328,6 @@ cmdDomrename(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - virshDomainFree(dom); return ret; } =20 @@ -10426,7 +10353,7 @@ static const vshCmdOptDef opts_domid[] =3D { static bool cmdDomid(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; unsigned int id; =20 if (!(dom =3D virshCommandOptDomainBy(ctl, cmd, NULL, @@ -10438,7 +10365,6 @@ cmdDomid(vshControl *ctl, const vshCmd *cmd) vshPrint(ctl, "%s\n", "-"); else vshPrint(ctl, "%d\n", id); - virshDomainFree(dom); return true; } =20 @@ -10463,7 +10389,7 @@ static const vshCmdOptDef opts_domuuid[] =3D { static bool cmdDomuuid(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; char uuid[VIR_UUID_STRING_BUFLEN]; =20 if (!(dom =3D virshCommandOptDomainBy(ctl, cmd, NULL, @@ -10475,7 +10401,6 @@ cmdDomuuid(vshControl *ctl, const vshCmd *cmd) else vshError(ctl, "%s", _("failed to get domain UUID")); =20 - virshDomainFree(dom); return true; } =20 @@ -10684,7 +10609,7 @@ static const vshCmdOptDef opts_migrate[] =3D { static void doMigrate(void *opaque) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; const char *desturi =3D NULL; const char *opt =3D NULL; unsigned int flags =3D 0; @@ -10972,10 +10897,9 @@ doMigrate(void *opaque) data->ret =3D 0; } else { /* For traditional live migration, connect to the destination host= directly. */ - virDomainPtr ddom =3D NULL; + g_autoptr(virshDomain) ddom =3D NULL; =20 if ((ddom =3D virDomainMigrate3(dom, dconn, params, nparams, flags= ))) { - virshDomainFree(ddom); data->ret =3D 0; } } @@ -10986,7 +10910,6 @@ doMigrate(void *opaque) out_sig: #endif /* !WIN32 */ virTypedParamsFree(params, nparams); - virshDomainFree(dom); g_main_loop_quit(data->eventLoop); return; =20 @@ -11046,7 +10969,7 @@ virshMigrateIteration(virConnectPtr conn G_GNUC_UNU= SED, static bool cmdMigrate(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; virThread workerThread; bool verbose =3D false; unsigned int timeout =3D 0; @@ -11144,7 +11067,6 @@ cmdMigrate(vshControl *ctl, const vshCmd *cmd) virConnectClose(data.dconn); if (iterEvent !=3D -1) virConnectDomainEventDeregisterAny(priv->conn, iterEvent); - virshDomainFree(dom); return !data.ret; } =20 @@ -11174,7 +11096,7 @@ static const vshCmdOptDef opts_migrate_setmaxdownti= me[] =3D { static bool cmdMigrateSetMaxDowntime(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; unsigned long long downtime =3D 0; bool ret =3D false; =20 @@ -11194,7 +11116,6 @@ cmdMigrateSetMaxDowntime(vshControl *ctl, const vsh= Cmd *cmd) ret =3D true; =20 done: - virshDomainFree(dom); return ret; } =20 @@ -11220,7 +11141,7 @@ static const vshCmdOptDef opts_migrate_getmaxdownti= me[] =3D { static bool cmdMigrateGetMaxDowntime(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; unsigned long long downtime; bool ret =3D false; =20 @@ -11234,7 +11155,6 @@ cmdMigrateGetMaxDowntime(vshControl *ctl, const vsh= Cmd *cmd) ret =3D true; =20 done: - virshDomainFree(dom); return ret; } =20 @@ -11266,7 +11186,7 @@ static const vshCmdOptDef opts_migrate_compcache[] = =3D { static bool cmdMigrateCompCache(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; unsigned long long size =3D 0; bool ret =3D false; const char *unit; @@ -11292,7 +11212,6 @@ cmdMigrateCompCache(vshControl *ctl, const vshCmd *= cmd) =20 ret =3D true; cleanup: - virshDomainFree(dom); return ret; } =20 @@ -11327,7 +11246,7 @@ static const vshCmdOptDef opts_migrate_setspeed[] = =3D { static bool cmdMigrateSetMaxSpeed(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; unsigned long bandwidth =3D 0; unsigned int flags =3D 0; bool ret =3D false; @@ -11347,7 +11266,6 @@ cmdMigrateSetMaxSpeed(vshControl *ctl, const vshCmd= *cmd) ret =3D true; =20 done: - virshDomainFree(dom); return ret; } =20 @@ -11376,7 +11294,7 @@ static const vshCmdOptDef opts_migrate_getspeed[] = =3D { static bool cmdMigrateGetMaxSpeed(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; unsigned long bandwidth; unsigned int flags =3D 0; bool ret =3D false; @@ -11395,7 +11313,6 @@ cmdMigrateGetMaxSpeed(vshControl *ctl, const vshCmd= *cmd) ret =3D true; =20 done: - virshDomainFree(dom); return ret; } =20 @@ -11421,7 +11338,7 @@ static const vshCmdOptDef opts_migrate_postcopy[] = =3D { static bool cmdMigratePostCopy(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D false; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) @@ -11433,7 +11350,6 @@ cmdMigratePostCopy(vshControl *ctl, const vshCmd *c= md) ret =3D true; =20 cleanup: - virshDomainFree(dom); return ret; } =20 @@ -11474,7 +11390,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) { xmlDocPtr xml =3D NULL; xmlXPathContextPtr ctxt =3D NULL; - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; bool ret =3D false; char *xpath =3D NULL; @@ -11704,7 +11620,6 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) VIR_FREE(output); xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); - virshDomainFree(dom); return ret; } =20 @@ -11731,7 +11646,7 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd) { xmlDocPtr xml =3D NULL; xmlXPathContextPtr ctxt =3D NULL; - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D false; int port =3D 0; char *listen_addr =3D NULL; @@ -11780,7 +11695,6 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd) VIR_FREE(listen_addr); xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); - virshDomainFree(dom); return ret; } =20 @@ -12004,7 +11918,7 @@ static const vshCmdOptDef opts_detach_device_alias[= ] =3D { static bool cmdDetachDeviceAlias(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; const char *alias =3D NULL; bool current =3D vshCommandOptBool(cmd, "current"); bool config =3D vshCommandOptBool(cmd, "config"); @@ -12035,7 +11949,6 @@ cmdDetachDeviceAlias(vshControl *ctl, const vshCmd = *cmd) ret =3D true; =20 cleanup: - virshDomainFree(dom); return ret; } =20 @@ -12070,7 +11983,7 @@ static const vshCmdOptDef opts_update_device[] =3D { static bool cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; const char *from =3D NULL; char *buffer =3D NULL; bool ret =3D false; @@ -12118,7 +12031,6 @@ cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd) =20 cleanup: VIR_FREE(buffer); - virshDomainFree(dom); return ret; } =20 @@ -12249,7 +12161,7 @@ virshDomainDetachInterface(char *doc, static bool cmdDetachInterface(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; char *doc_live =3D NULL, *doc_config =3D NULL; const char *mac =3D NULL, *type =3D NULL; int flags =3D 0; @@ -12307,7 +12219,6 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *c= md) } VIR_FREE(doc_live); VIR_FREE(doc_config); - virshDomainFree(dom); return ret; } =20 @@ -12612,7 +12523,7 @@ static bool cmdDetachDisk(vshControl *ctl, const vshCmd *cmd) { char *disk_xml =3D NULL; - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; const char *target =3D NULL; char *doc =3D NULL; int ret; @@ -12683,7 +12594,6 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd) xmlFreeNode(disk_node); VIR_FREE(disk_xml); VIR_FREE(doc); - virshDomainFree(dom); return functionReturn; } =20 @@ -12713,8 +12623,8 @@ static bool cmdEdit(vshControl *ctl, const vshCmd *cmd) { bool ret =3D false; - virDomainPtr dom =3D NULL; - virDomainPtr dom_edited =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; + g_autoptr(virshDomain) dom_edited =3D NULL; unsigned int query_flags =3D VIR_DOMAIN_XML_SECURE | VIR_DOMAIN_XML_IN= ACTIVE; unsigned int define_flags =3D VIR_DOMAIN_DEFINE_VALIDATE; virshControl *priv =3D ctl->privData; @@ -12750,8 +12660,6 @@ cmdEdit(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - virshDomainFree(dom); - virshDomainFree(dom_edited); =20 return ret; } @@ -13569,7 +13477,7 @@ static const vshCmdOptDef opts_event[] =3D { static bool cmdEvent(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D false; int timeout =3D 0; virshDomEventData *data =3D NULL; @@ -13679,7 +13587,6 @@ cmdEvent(vshControl *ctl, const vshCmd *cmd) } VIR_FREE(data); } - virshDomainFree(dom); return ret; } =20 @@ -13745,7 +13652,7 @@ static const vshCmdOptDef opts_change_media[] =3D { static bool cmdChangeMedia(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; const char *source =3D NULL; const char *path =3D NULL; char *doc =3D NULL; @@ -13845,7 +13752,6 @@ cmdChangeMedia(vshControl *ctl, const vshCmd *cmd) VIR_FREE(doc); xmlFreeNode(disk_node); VIR_FREE(disk_xml); - virshDomainFree(dom); return ret; } =20 @@ -13876,7 +13782,7 @@ static const vshCmdOptDef opts_domfstrim[] =3D { static bool cmdDomFSTrim(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D false; unsigned long long minimum =3D 0; const char *mountPoint =3D NULL; @@ -13899,7 +13805,6 @@ cmdDomFSTrim(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - virshDomainFree(dom); return ret; } =20 @@ -13925,7 +13830,7 @@ static const vshCmdOptDef opts_domfsfreeze[] =3D { static bool cmdDomFSFreeze(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; int ret =3D -1; const vshCmdOpt *opt =3D NULL; const char **mountpoints =3D NULL; @@ -13949,7 +13854,6 @@ cmdDomFSFreeze(vshControl *ctl, const vshCmd *cmd) =20 cleanup: VIR_FREE(mountpoints); - virshDomainFree(dom); return ret >=3D 0; } =20 @@ -13975,7 +13879,7 @@ static const vshCmdOptDef opts_domfsthaw[] =3D { static bool cmdDomFSThaw(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; int ret =3D -1; const vshCmdOpt *opt =3D NULL; const char **mountpoints =3D NULL; @@ -13999,7 +13903,6 @@ cmdDomFSThaw(vshControl *ctl, const vshCmd *cmd) =20 cleanup: VIR_FREE(mountpoints); - virshDomainFree(dom); return ret >=3D 0; } =20 @@ -14021,7 +13924,7 @@ static const vshCmdOptDef opts_domfsinfo[] =3D { static bool cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; int rc =3D -1; size_t i, j; virDomainFSInfoPtr *info =3D NULL; @@ -14081,7 +13984,6 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) VIR_FREE(info); } vshTableFree(table); - virshDomainFree(dom); return ret; } =20 @@ -14111,7 +14013,7 @@ static const vshCmdOptDef opts_guest_agent_timeout[= ] =3D { static bool cmdGuestAgentTimeout(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; int timeout =3D VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK; const unsigned int flags =3D 0; bool ret =3D false; @@ -14127,7 +14029,6 @@ cmdGuestAgentTimeout(vshControl *ctl, const vshCmd = *cmd) =20 ret =3D true; cleanup: - virshDomainFree(dom); return ret; } =20 @@ -14177,7 +14078,7 @@ static const vshCmdOptDef opts_guestinfo[] =3D { static bool cmdGuestInfo(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom; + g_autoptr(virshDomain) dom =3D NULL; bool ret =3D false; virTypedParameterPtr params =3D NULL; int nparams =3D 0; @@ -14213,7 +14114,6 @@ cmdGuestInfo(vshControl *ctl, const vshCmd *cmd) =20 cleanup: virTypedParamsFree(params, nparams); - virshDomainFree(dom); return ret; } =20 @@ -14244,7 +14144,7 @@ static const vshCmdOptDef opts_get_user_sshkeys[] = =3D { static bool cmdGetUserSSHKeys(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; const char *user; g_auto(GStrv) keys =3D NULL; int nkeys =3D 0; @@ -14268,7 +14168,6 @@ cmdGetUserSSHKeys(vshControl *ctl, const vshCmd *cm= d) =20 ret =3D true; cleanup: - virshDomainFree(dom); return ret; } =20 @@ -14312,7 +14211,7 @@ static const vshCmdOptDef opts_set_user_sshkeys[] = =3D { static bool cmdSetUserSSHKeys(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; const char *user; const char *from; g_autofree char *buffer =3D NULL; @@ -14369,7 +14268,6 @@ cmdSetUserSSHKeys(vshControl *ctl, const vshCmd *cm= d) =20 ret =3D true; cleanup: - virshDomainFree(dom); return ret; } =20 @@ -14403,7 +14301,7 @@ static const vshCmdOptDef opts_domdirtyrate_calc[] = =3D { static bool cmdDomDirtyRateCalc(vshControl *ctl, const vshCmd *cmd) { - virDomainPtr dom =3D NULL; + g_autoptr(virshDomain) dom =3D NULL; int seconds =3D 1; /* the default value is 1 */ bool ret =3D false; =20 @@ -14421,7 +14319,6 @@ cmdDomDirtyRateCalc(vshControl *ctl, const vshCmd *= cmd) ret =3D true; =20 cleanup: - virshDomainFree(dom); return ret; } =20 --=20 2.31.1 From nobody Sun May 5 17:07:13 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=1628757679; cv=none; d=zohomail.com; s=zohoarc; b=AO/tRTKMbBEMmr+J/3vi2u3l4rXWeGhs5tNSx9XkKaAM1zxHbpo0QfzOm5L5Kx6JhSvFRTl5Ct0SVEBRNBMeWpzmWhg99gI4U+xcez1E7NWo6SVg7QW+N3awkgBEr5Cky4zCmRyA244/CNDdH31zCa8rYlwsETYZ7P4ZZLybZ/c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628757679; 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=V0zRXkeDTF6IKuZgqpouXFEUpgnnwu+YHzgwoytPCPA=; b=lNgDhAqhW0LBf+XVWHeyIdE0z9AhPerlrGC+/QdLin0kIOwyJefz+5MTJc9QDZqjN66/L2ds52ZZ3a8wjypZD/fJfg2G8AIBNpN5ZOtfdW6hZzOu1NbINmiQRAapbvuZFuU9rJi24Zc8BVi53CSJNWskjpS9Iq77sgQuJ5yAnwc= 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) 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 1628757679618254.4511758019322; Thu, 12 Aug 2021 01:41:19 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-353-XifNFpiTPAeO4SmKGFxHwA-1; Thu, 12 Aug 2021 04:39:37 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D1422190A7A0; Thu, 12 Aug 2021 08:39: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 AE8312855E; Thu, 12 Aug 2021 08:39: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 6FE414A7C8; Thu, 12 Aug 2021 08:39:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17C8X8Af003655 for ; Thu, 12 Aug 2021 04:33:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 81F4410013C1; Thu, 12 Aug 2021 08:33:08 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A16F1036D3F for ; Thu, 12 Aug 2021 08:33:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628757678; 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=V0zRXkeDTF6IKuZgqpouXFEUpgnnwu+YHzgwoytPCPA=; b=Bccj3gspMoozRYHuy79ebVz9DSdqnvnexyLaC7yGzoJtfeX59RitIXFMtFhsN7TdLxugHD ojzjxp6Vt8SpVZsMfJt7cZ+OzjjQHu44cvKcZVWsJ6ChkvhCeTiSCAK1VpEPLQDCVCQDc1 5CCSmpEmmlA3bT+XGYwSq7akRPj4YuQ= X-MC-Unique: XifNFpiTPAeO4SmKGFxHwA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 05/12] tools: virsh: use automatic cleanup for xmlXPathContext Date: Thu, 12 Aug 2021 10:32:43 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1628757681061100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- tools/virsh-completer-domain.c | 6 ++---- tools/virsh-domain-monitor.c | 12 ++++-------- tools/virsh-domain.c | 27 +++++++++------------------ tools/virsh-host.c | 15 +++++---------- tools/virsh-interface.c | 6 ++---- tools/virsh-volume.c | 3 +-- 6 files changed, 23 insertions(+), 46 deletions(-) diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index d1430c951a..4cdc533a07 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -479,7 +479,7 @@ virshDomainVcpuCompleter(vshControl *ctl, { g_autoptr(virshDomain) dom =3D NULL; xmlDocPtr xml =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; int nvcpus =3D 0; unsigned int id; char **ret =3D NULL; @@ -506,7 +506,6 @@ virshDomainVcpuCompleter(vshControl *ctl, ret =3D g_steal_pointer(&tmp); =20 cleanup: - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); return ret; } @@ -519,7 +518,7 @@ virshDomainVcpulistCompleter(vshControl *ctl, { g_autoptr(virshDomain) dom =3D NULL; xmlDocPtr xml =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; int nvcpus =3D 0; unsigned int id; g_auto(GStrv) vcpulist =3D NULL; @@ -550,7 +549,6 @@ virshDomainVcpulistCompleter(vshControl *ctl, ret =3D virshCommaStringListComplete(vcpuid, (const char **)vcpulist); =20 cleanup: - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); return ret; } diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index d79f807d8b..cabf968393 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -56,7 +56,7 @@ virshGetDomainDescription(vshControl *ctl, virDomainPtr d= om, bool title, { char *desc =3D NULL; xmlDocPtr doc =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; int type; =20 if (title) @@ -92,7 +92,6 @@ virshGetDomainDescription(vshControl *ctl, virDomainPtr d= om, bool title, desc =3D g_strdup(""); =20 cleanup: - xmlXPathFreeContext(ctxt); xmlFreeDoc(doc); =20 return desc; @@ -595,7 +594,7 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) bool ret =3D false; unsigned int flags =3D 0; xmlDocPtr xmldoc =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; int ndisks; xmlNodePtr *disks =3D NULL; size_t i; @@ -694,7 +693,6 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) VIR_FREE(device); VIR_FREE(type); VIR_FREE(disks); - xmlXPathFreeContext(ctxt); xmlFreeDoc(xmldoc); return ret; } @@ -723,7 +721,7 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd) bool ret =3D false; unsigned int flags =3D 0; xmlDocPtr xmldoc =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; int ninterfaces; xmlNodePtr *interfaces =3D NULL; size_t i; @@ -782,7 +780,6 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd) vshTableFree(table); VIR_FREE(interfaces); xmlFreeDoc(xmldoc); - xmlXPathFreeContext(ctxt); return ret; } =20 @@ -824,7 +821,7 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd) virMacAddr macaddr; char macstr[VIR_MAC_STRING_BUFLEN] =3D ""; xmlDocPtr xml =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr *interfaces =3D NULL; int ninterfaces; unsigned int flags =3D 0; @@ -877,7 +874,6 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd) VIR_FREE(state); VIR_FREE(interfaces); VIR_FREE(xpath); - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); =20 return ret; diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index b671ae398f..398190bb5b 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -3065,7 +3065,7 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) unsigned int xmlflags =3D 0; size_t i; xmlDocPtr xml =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlXPathObjectPtr obj =3D NULL; xmlNodePtr cur =3D NULL; char *xml_buf =3D NULL; @@ -3179,7 +3179,6 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) =20 cleanup: xmlXPathFreeObject(obj); - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); VIR_FREE(xml_buf); =20 @@ -3639,7 +3638,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd) virshUndefineVolume *vols =3D NULL; /* info about the volumes to delet= e */ size_t nvols =3D 0; xmlDocPtr doc =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr *vol_nodes =3D NULL; /* XML nodes of volumes of the guest= */ int nvol_nodes; char *source =3D NULL; @@ -3956,7 +3955,6 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd) =20 VIR_FREE(vol_nodes); xmlFreeDoc(doc); - xmlXPathFreeContext(ctxt); return ret; =20 error: @@ -6555,7 +6553,7 @@ virshCPUCountCollect(vshControl *ctl, virDomainInfo info; int count; xmlDocPtr xml =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; =20 if (checkState && ((flags & VIR_DOMAIN_AFFECT_LIVE && virDomainIsActive(dom) < 1) || @@ -6614,7 +6612,6 @@ virshCPUCountCollect(vshControl *ctl, =20 ret =3D count; cleanup: - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); =20 return ret; @@ -6759,7 +6756,7 @@ virshDomainGetVcpuBitmap(vshControl *ctl, unsigned int flags =3D 0; virBitmap *ret =3D NULL; xmlDocPtr xml =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr *nodes =3D NULL; int nnodes; size_t i; @@ -6816,7 +6813,6 @@ virshDomainGetVcpuBitmap(vshControl *ctl, cleanup: VIR_FREE(online); VIR_FREE(nodes); - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); return ret; } @@ -11389,7 +11385,7 @@ static bool cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) { xmlDocPtr xml =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; g_autoptr(virshDomain) dom =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; bool ret =3D false; @@ -11618,7 +11614,6 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) VIR_FREE(passwd); VIR_FREE(listen_addr); VIR_FREE(output); - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); return ret; } @@ -11645,7 +11640,7 @@ static bool cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd) { xmlDocPtr xml =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; g_autoptr(virshDomain) dom =3D NULL; bool ret =3D false; int port =3D 0; @@ -11693,7 +11688,6 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd) =20 cleanup: VIR_FREE(listen_addr); - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); return ret; } @@ -11720,7 +11714,7 @@ static bool cmdTTYConsole(vshControl *ctl, const vshCmd *cmd) { xmlDocPtr xml =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; bool ret =3D false; char *tty =3D NULL; =20 @@ -11734,7 +11728,6 @@ cmdTTYConsole(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); VIR_FREE(tty); return ret; @@ -12078,7 +12071,7 @@ virshDomainDetachInterface(char *doc, { xmlDocPtr xml =3D NULL; xmlXPathObjectPtr obj =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr cur =3D NULL, matchNode =3D NULL; char *detach_xml =3D NULL; char buf[64]; @@ -12153,7 +12146,6 @@ virshDomainDetachInterface(char *doc, VIR_FREE(detach_xml); xmlFreeDoc(xml); xmlXPathFreeObject(obj); - xmlXPathFreeContext(ctxt); return ret =3D=3D 0; } =20 @@ -12259,7 +12251,7 @@ virshFindDisk(const char *doc, { xmlDocPtr xml =3D NULL; xmlXPathObjectPtr obj =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr cur =3D NULL; xmlNodePtr ret =3D NULL; size_t i; @@ -12334,7 +12326,6 @@ virshFindDisk(const char *doc, =20 cleanup: xmlXPathFreeObject(obj); - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); return ret; } diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 7b47b7583d..b2d3a9c85f 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -168,7 +168,7 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd) size_t i; char *cap_xml =3D NULL; xmlDocPtr xml =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; virshControl *priv =3D ctl->privData; =20 VSH_EXCLUSIVE_OPTIONS_VAR(all, cellno); @@ -243,7 +243,6 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); VIR_FREE(nodes); VIR_FREE(nodes_free); @@ -308,7 +307,7 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd) int nodes_cnt; char *cap_xml =3D NULL; xmlDocPtr doc =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; bool all =3D vshCommandOptBool(cmd, "all"); bool cellno =3D vshCommandOptBool(cmd, "cellno"); bool pagesz =3D vshCommandOptBool(cmd, "pagesize"); @@ -443,7 +442,6 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd) =20 ret =3D true; cleanup: - xmlXPathFreeContext(ctxt); xmlFreeDoc(doc); VIR_FREE(cap_xml); VIR_FREE(nodes); @@ -507,7 +505,7 @@ cmdAllocpages(vshControl *ctl, const vshCmd *cmd) unsigned int flags =3D 0; char *cap_xml =3D NULL; xmlDocPtr xml =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr *nodes =3D NULL; virshControl *priv =3D ctl->privData; =20 @@ -571,7 +569,6 @@ cmdAllocpages(vshControl *ctl, const vshCmd *cmd) =20 ret =3D true; cleanup: - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); VIR_FREE(nodes); VIR_FREE(cap_xml); @@ -607,7 +604,7 @@ cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd) int vcpus =3D -1; char *caps =3D NULL; xmlDocPtr xml =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; virshControl *priv =3D ctl->privData; bool ret =3D false; =20 @@ -631,7 +628,6 @@ cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml); VIR_FREE(caps); return ret; @@ -1125,7 +1121,7 @@ vshExtractCPUDefXMLs(vshControl *ctl, char *buffer =3D NULL; char *xmlStr =3D NULL; xmlDocPtr xml =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr *nodes =3D NULL; char *doc; size_t i; @@ -1188,7 +1184,6 @@ vshExtractCPUDefXMLs(vshControl *ctl, VIR_FREE(buffer); VIR_FREE(xmlStr); xmlFreeDoc(xml); - xmlXPathFreeContext(ctxt); VIR_FREE(nodes); return cpus; =20 diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c index 41acae5dcb..1a94eba1c3 100644 --- a/tools/virsh-interface.c +++ b/tools/virsh-interface.c @@ -822,7 +822,7 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd) xmlChar *br_xml =3D NULL; int br_xml_size; xmlDocPtr xml_doc =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr top_node, br_node, if_node, cur; virshControl *priv =3D ctl->privData; =20 @@ -1001,7 +1001,6 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd) VIR_FREE(if_type); VIR_FREE(if2_name); VIR_FREE(delay_str); - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml_doc); return ret; } @@ -1044,7 +1043,7 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *c= md) xmlChar *if_xml =3D NULL; int if_xml_size; xmlDocPtr xml_doc =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr top_node, if_node, cur; virshControl *priv =3D ctl->privData; =20 @@ -1201,7 +1200,6 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *c= md) VIR_FREE(br_xml); VIR_FREE(if_type); VIR_FREE(if_name); - xmlXPathFreeContext(ctxt); xmlFreeDoc(xml_doc); return ret; } diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index fe632b1b19..c9c4310cbd 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -526,7 +526,7 @@ static xmlChar * virshMakeCloneXML(const char *origxml, const char *newname) { xmlDocPtr doc =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; + g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlXPathObjectPtr obj =3D NULL; xmlChar *newxml =3D NULL; int size; @@ -545,7 +545,6 @@ virshMakeCloneXML(const char *origxml, const char *newn= ame) =20 cleanup: xmlXPathFreeObject(obj); - xmlXPathFreeContext(ctxt); xmlFreeDoc(doc); return newxml; } --=20 2.31.1 From nobody Sun May 5 17:07:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1628757558; cv=none; d=zohomail.com; s=zohoarc; b=kf4rBWGUVZdik6lpYVp0yn+GyaYJmeQGHt0wmbCRcYUjm/yfynVbT3vsDN7F/01aN2ZZ533sZ2//88i1h3gNmuQ6/IHnB6ywgTJZCLv6y3XnnAwmW0aroijZU1UsTaVp5j0mpXKlB612btWOLYctd9xtSR4mbJ4OTrsUNsJ53xM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628757558; 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=37RhxAwjmQmY2cqu6tkIDyyZmLUUmqTCNix1t0fqUSc=; b=hziAs89cB/hSlme6A2ceddpHYpFm30boXsn8smejPkIehWYKkY7sFs5IcFHQviHUCvWQ/++NGYDHFV80EDgs+QKDzS7gj3KPRksQ9bdTgGGo2xW1Yj9u4pS0LS/bO8SlZW/4yR0BiQ3EYrrFb9r5jiVPCLQcX8/CQwULMAJ0ZPk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1628757558979280.6253009211234; Thu, 12 Aug 2021 01:39:18 -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-444-k6I5rP1pNS2GRj41GgQRXQ-1; Thu, 12 Aug 2021 04:39:15 -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 249EE760C6; Thu, 12 Aug 2021 08:39:10 +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 0BBE519CBA; Thu, 12 Aug 2021 08:39:10 +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 C75F2181A0F7; Thu, 12 Aug 2021 08:39:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17C8X9gs003663 for ; Thu, 12 Aug 2021 04:33:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 53EA610372C0; Thu, 12 Aug 2021 08:33:09 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id D097A10013C1 for ; Thu, 12 Aug 2021 08:33:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628757558; 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=37RhxAwjmQmY2cqu6tkIDyyZmLUUmqTCNix1t0fqUSc=; b=QERxUTL0efDft77ZECS4ul5StAJqgfOBTVKBZvAIAWdfa2Ha9vOST7o/TtBtz/GBZ1anJw Gpowev0Blk1SqyZDPpxL0HluZK3nvtRcAx5tfeJ62cRQqh/y2k4ykz0YBGBWbFdUwtPxzA ZurydghNXLNVyBh0eHv7yusCjFUoT2A= X-MC-Unique: k6I5rP1pNS2GRj41GgQRXQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 06/12] tools: virsh: use automatic cleanup for xmlXPathObject Date: Thu, 12 Aug 2021 10:32:44 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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) X-ZM-MESSAGEID: 1628757560453100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- tools/virsh-domain.c | 9 +++------ tools/virsh-volume.c | 3 +-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 398190bb5b..0c60a4de99 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -3066,7 +3066,7 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) size_t i; xmlDocPtr xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; - xmlXPathObjectPtr obj =3D NULL; + g_autoptr(xmlXPathObject) obj =3D NULL; xmlNodePtr cur =3D NULL; char *xml_buf =3D NULL; =20 @@ -3178,7 +3178,6 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) } =20 cleanup: - xmlXPathFreeObject(obj); xmlFreeDoc(xml); VIR_FREE(xml_buf); =20 @@ -12070,7 +12069,7 @@ virshDomainDetachInterface(char *doc, const char *mac) { xmlDocPtr xml =3D NULL; - xmlXPathObjectPtr obj =3D NULL; + g_autoptr(xmlXPathObject) obj =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr cur =3D NULL, matchNode =3D NULL; char *detach_xml =3D NULL; @@ -12145,7 +12144,6 @@ virshDomainDetachInterface(char *doc, cleanup: VIR_FREE(detach_xml); xmlFreeDoc(xml); - xmlXPathFreeObject(obj); return ret =3D=3D 0; } =20 @@ -12250,7 +12248,7 @@ virshFindDisk(const char *doc, int type) { xmlDocPtr xml =3D NULL; - xmlXPathObjectPtr obj =3D NULL; + g_autoptr(xmlXPathObject) obj =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr cur =3D NULL; xmlNodePtr ret =3D NULL; @@ -12325,7 +12323,6 @@ virshFindDisk(const char *doc, vshError(NULL, _("No disk found whose source path or target is %s"), p= ath); =20 cleanup: - xmlXPathFreeObject(obj); xmlFreeDoc(xml); return ret; } diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index c9c4310cbd..4b179d7d87 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -527,7 +527,7 @@ virshMakeCloneXML(const char *origxml, const char *newn= ame) { xmlDocPtr doc =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; - xmlXPathObjectPtr obj =3D NULL; + g_autoptr(xmlXPathObject) obj =3D NULL; xmlChar *newxml =3D NULL; int size; =20 @@ -544,7 +544,6 @@ virshMakeCloneXML(const char *origxml, const char *newn= ame) xmlDocDumpMemory(doc, &newxml, &size); =20 cleanup: - xmlXPathFreeObject(obj); xmlFreeDoc(doc); return newxml; } --=20 2.31.1 From nobody Sun May 5 17:07:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1628757606; cv=none; d=zohomail.com; s=zohoarc; b=Q0tc77WnnsLgEbvyV4Yh/Mvur064iCdzZfpPZFmGH/b9x4w0eWpPjI3qXlGSTx7QPjm1XbzhdZ8YDhSvFLu5NIWZxnaS1CpK29dlJ+cxDnfnbyOnD2HLSI6a8yyEn3LxI2q7AD10vDvoT1N6nNW8MRkLRahT5s43issPCQp8LqQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628757606; 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=EEmhm6Ymt+Maqj/q7tIcTisjuCWVzGVsANO8YvW9mIs=; b=mvqnsIMyCKQs9hcUQG+Fisy8UIoaVrAVnb0gypSm9O4jD13BaTktot/X0TQy2+PQsRpVYH9QW1aAV5hCHFNsNMukzV4VF8K48nAwCCg0mCEVpmtuAFR1/Bn28kLMyd9e8Bi7imn816+geiTt0RpDKqjig9T6B3zefIOf5jwRhmI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1628757606723626.8804717720236; Thu, 12 Aug 2021 01:40:06 -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-228-H7sVJVRcN-mwHOdJ30pyUg-1; Thu, 12 Aug 2021 04:39:39 -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 675BB760C5; Thu, 12 Aug 2021 08:39:34 +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 4CF8D69CBB; Thu, 12 Aug 2021 08:39:34 +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 1DF9F4A7CD; Thu, 12 Aug 2021 08:39:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17C8XAeG003671 for ; Thu, 12 Aug 2021 04:33:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 266B310372CC; Thu, 12 Aug 2021 08:33:10 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id A35E510013C1 for ; Thu, 12 Aug 2021 08:33:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628757605; 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=EEmhm6Ymt+Maqj/q7tIcTisjuCWVzGVsANO8YvW9mIs=; b=YDM6vucLP+oY91MblVyrSlgc109Xeep5DEysxdUFlmGS2mwjSMHUm0/JD9n/gOPnWZ/H/M qkD5fOSay6sW0fYMIeWS6VcZvRfUZhSALknka9yafjJEqtKRI9tHVfXDD+pXRiTnCG6mms wtcTtn8w8ch0nSjfoMV6VVYoa36l3ic= X-MC-Unique: H7sVJVRcN-mwHOdJ30pyUg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 07/12] tools: virsh: use automatic cleanup for xmlDoc Date: Thu, 12 Aug 2021 10:32:45 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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) X-ZM-MESSAGEID: 1628757607908100002 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- tools/virsh-completer-domain.c | 6 ++---- tools/virsh-domain-monitor.c | 12 ++++-------- tools/virsh-domain.c | 27 +++++++++------------------ tools/virsh-host.c | 15 +++++---------- tools/virsh-interface.c | 6 ++---- tools/virsh-volume.c | 3 +-- 6 files changed, 23 insertions(+), 46 deletions(-) diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index 4cdc533a07..471f9974a1 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -478,7 +478,7 @@ virshDomainVcpuCompleter(vshControl *ctl, unsigned int flags) { g_autoptr(virshDomain) dom =3D NULL; - xmlDocPtr xml =3D NULL; + g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; int nvcpus =3D 0; unsigned int id; @@ -506,7 +506,6 @@ virshDomainVcpuCompleter(vshControl *ctl, ret =3D g_steal_pointer(&tmp); =20 cleanup: - xmlFreeDoc(xml); return ret; } =20 @@ -517,7 +516,7 @@ virshDomainVcpulistCompleter(vshControl *ctl, unsigned int flags) { g_autoptr(virshDomain) dom =3D NULL; - xmlDocPtr xml =3D NULL; + g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; int nvcpus =3D 0; unsigned int id; @@ -549,7 +548,6 @@ virshDomainVcpulistCompleter(vshControl *ctl, ret =3D virshCommaStringListComplete(vcpuid, (const char **)vcpulist); =20 cleanup: - xmlFreeDoc(xml); return ret; } =20 diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index cabf968393..fb52915cab 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -55,7 +55,7 @@ virshGetDomainDescription(vshControl *ctl, virDomainPtr d= om, bool title, unsigned int flags) { char *desc =3D NULL; - xmlDocPtr doc =3D NULL; + g_autoptr(xmlDoc) doc =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; int type; =20 @@ -92,7 +92,6 @@ virshGetDomainDescription(vshControl *ctl, virDomainPtr d= om, bool title, desc =3D g_strdup(""); =20 cleanup: - xmlFreeDoc(doc); =20 return desc; } @@ -593,7 +592,7 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) { bool ret =3D false; unsigned int flags =3D 0; - xmlDocPtr xmldoc =3D NULL; + g_autoptr(xmlDoc) xmldoc =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; int ndisks; xmlNodePtr *disks =3D NULL; @@ -693,7 +692,6 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) VIR_FREE(device); VIR_FREE(type); VIR_FREE(disks); - xmlFreeDoc(xmldoc); return ret; } =20 @@ -720,7 +718,7 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd) { bool ret =3D false; unsigned int flags =3D 0; - xmlDocPtr xmldoc =3D NULL; + g_autoptr(xmlDoc) xmldoc =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; int ninterfaces; xmlNodePtr *interfaces =3D NULL; @@ -779,7 +777,6 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd) cleanup: vshTableFree(table); VIR_FREE(interfaces); - xmlFreeDoc(xmldoc); return ret; } =20 @@ -820,7 +817,7 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd) char *xpath =3D NULL; virMacAddr macaddr; char macstr[VIR_MAC_STRING_BUFLEN] =3D ""; - xmlDocPtr xml =3D NULL; + g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr *interfaces =3D NULL; int ninterfaces; @@ -874,7 +871,6 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd) VIR_FREE(state); VIR_FREE(interfaces); VIR_FREE(xpath); - xmlFreeDoc(xml); =20 return ret; } diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 0c60a4de99..fe2bfdaed0 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -3064,7 +3064,7 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) unsigned int flags =3D 0; unsigned int xmlflags =3D 0; size_t i; - xmlDocPtr xml =3D NULL; + g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; g_autoptr(xmlXPathObject) obj =3D NULL; xmlNodePtr cur =3D NULL; @@ -3178,7 +3178,6 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) } =20 cleanup: - xmlFreeDoc(xml); VIR_FREE(xml_buf); =20 return ret; @@ -3636,7 +3635,7 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd) int nvol_list =3D 0; virshUndefineVolume *vols =3D NULL; /* info about the volumes to delet= e */ size_t nvols =3D 0; - xmlDocPtr doc =3D NULL; + g_autoptr(xmlDoc) doc =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr *vol_nodes =3D NULL; /* XML nodes of volumes of the guest= */ int nvol_nodes; @@ -3953,7 +3952,6 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd) VIR_FREE(vol_list); =20 VIR_FREE(vol_nodes); - xmlFreeDoc(doc); return ret; =20 error: @@ -6551,7 +6549,7 @@ virshCPUCountCollect(vshControl *ctl, int ret =3D -2; virDomainInfo info; int count; - xmlDocPtr xml =3D NULL; + g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; =20 if (checkState && @@ -6611,7 +6609,6 @@ virshCPUCountCollect(vshControl *ctl, =20 ret =3D count; cleanup: - xmlFreeDoc(xml); =20 return ret; } @@ -6754,7 +6751,7 @@ virshDomainGetVcpuBitmap(vshControl *ctl, { unsigned int flags =3D 0; virBitmap *ret =3D NULL; - xmlDocPtr xml =3D NULL; + g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr *nodes =3D NULL; int nnodes; @@ -6812,7 +6809,6 @@ virshDomainGetVcpuBitmap(vshControl *ctl, cleanup: VIR_FREE(online); VIR_FREE(nodes); - xmlFreeDoc(xml); return ret; } =20 @@ -11383,7 +11379,7 @@ static const vshCmdOptDef opts_domdisplay[] =3D { static bool cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) { - xmlDocPtr xml =3D NULL; + g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; g_autoptr(virshDomain) dom =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; @@ -11613,7 +11609,6 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) VIR_FREE(passwd); VIR_FREE(listen_addr); VIR_FREE(output); - xmlFreeDoc(xml); return ret; } =20 @@ -11638,7 +11633,7 @@ static const vshCmdOptDef opts_vncdisplay[] =3D { static bool cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd) { - xmlDocPtr xml =3D NULL; + g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; g_autoptr(virshDomain) dom =3D NULL; bool ret =3D false; @@ -11687,7 +11682,6 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd) =20 cleanup: VIR_FREE(listen_addr); - xmlFreeDoc(xml); return ret; } =20 @@ -11712,7 +11706,7 @@ static const vshCmdOptDef opts_ttyconsole[] =3D { static bool cmdTTYConsole(vshControl *ctl, const vshCmd *cmd) { - xmlDocPtr xml =3D NULL; + g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; bool ret =3D false; char *tty =3D NULL; @@ -11727,7 +11721,6 @@ cmdTTYConsole(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - xmlFreeDoc(xml); VIR_FREE(tty); return ret; } @@ -12068,7 +12061,7 @@ virshDomainDetachInterface(char *doc, const char *type, const char *mac) { - xmlDocPtr xml =3D NULL; + g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathObject) obj =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr cur =3D NULL, matchNode =3D NULL; @@ -12143,7 +12136,6 @@ virshDomainDetachInterface(char *doc, =20 cleanup: VIR_FREE(detach_xml); - xmlFreeDoc(xml); return ret =3D=3D 0; } =20 @@ -12247,7 +12239,7 @@ virshFindDisk(const char *doc, const char *path, int type) { - xmlDocPtr xml =3D NULL; + g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathObject) obj =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr cur =3D NULL; @@ -12323,7 +12315,6 @@ virshFindDisk(const char *doc, vshError(NULL, _("No disk found whose source path or target is %s"), p= ath); =20 cleanup: - xmlFreeDoc(xml); return ret; } =20 diff --git a/tools/virsh-host.c b/tools/virsh-host.c index b2d3a9c85f..a07f5adbfa 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -167,7 +167,7 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd) bool cellno =3D vshCommandOptBool(cmd, "cellno"); size_t i; char *cap_xml =3D NULL; - xmlDocPtr xml =3D NULL; + g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; virshControl *priv =3D ctl->privData; =20 @@ -243,7 +243,6 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - xmlFreeDoc(xml); VIR_FREE(nodes); VIR_FREE(nodes_free); VIR_FREE(nodes_id); @@ -306,7 +305,7 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd) xmlNodePtr *nodes =3D NULL; int nodes_cnt; char *cap_xml =3D NULL; - xmlDocPtr doc =3D NULL; + g_autoptr(xmlDoc) doc =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; bool all =3D vshCommandOptBool(cmd, "all"); bool cellno =3D vshCommandOptBool(cmd, "cellno"); @@ -442,7 +441,6 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd) =20 ret =3D true; cleanup: - xmlFreeDoc(doc); VIR_FREE(cap_xml); VIR_FREE(nodes); VIR_FREE(counts); @@ -504,7 +502,7 @@ cmdAllocpages(vshControl *ctl, const vshCmd *cmd) unsigned long long pageCounts[1], tmp; unsigned int flags =3D 0; char *cap_xml =3D NULL; - xmlDocPtr xml =3D NULL; + g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr *nodes =3D NULL; virshControl *priv =3D ctl->privData; @@ -569,7 +567,6 @@ cmdAllocpages(vshControl *ctl, const vshCmd *cmd) =20 ret =3D true; cleanup: - xmlFreeDoc(xml); VIR_FREE(nodes); VIR_FREE(cap_xml); return ret; @@ -603,7 +600,7 @@ cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd) const char *type =3D NULL; int vcpus =3D -1; char *caps =3D NULL; - xmlDocPtr xml =3D NULL; + g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; virshControl *priv =3D ctl->privData; bool ret =3D false; @@ -628,7 +625,6 @@ cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - xmlFreeDoc(xml); VIR_FREE(caps); return ret; } @@ -1120,7 +1116,7 @@ vshExtractCPUDefXMLs(vshControl *ctl, char **cpus =3D NULL; char *buffer =3D NULL; char *xmlStr =3D NULL; - xmlDocPtr xml =3D NULL; + g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr *nodes =3D NULL; char *doc; @@ -1183,7 +1179,6 @@ vshExtractCPUDefXMLs(vshControl *ctl, cleanup: VIR_FREE(buffer); VIR_FREE(xmlStr); - xmlFreeDoc(xml); VIR_FREE(nodes); return cpus; =20 diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c index 1a94eba1c3..71cc265efc 100644 --- a/tools/virsh-interface.c +++ b/tools/virsh-interface.c @@ -821,7 +821,7 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd) char *if_xml =3D NULL; xmlChar *br_xml =3D NULL; int br_xml_size; - xmlDocPtr xml_doc =3D NULL; + g_autoptr(xmlDoc) xml_doc =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr top_node, br_node, if_node, cur; virshControl *priv =3D ctl->privData; @@ -1001,7 +1001,6 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd) VIR_FREE(if_type); VIR_FREE(if2_name); VIR_FREE(delay_str); - xmlFreeDoc(xml_doc); return ret; } =20 @@ -1042,7 +1041,7 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *c= md) char *br_xml =3D NULL; xmlChar *if_xml =3D NULL; int if_xml_size; - xmlDocPtr xml_doc =3D NULL; + g_autoptr(xmlDoc) xml_doc =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr top_node, if_node, cur; virshControl *priv =3D ctl->privData; @@ -1200,7 +1199,6 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *c= md) VIR_FREE(br_xml); VIR_FREE(if_type); VIR_FREE(if_name); - xmlFreeDoc(xml_doc); return ret; } =20 diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index 4b179d7d87..6a1fe6785b 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -525,7 +525,7 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd) static xmlChar * virshMakeCloneXML(const char *origxml, const char *newname) { - xmlDocPtr doc =3D NULL; + g_autoptr(xmlDoc) doc =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; g_autoptr(xmlXPathObject) obj =3D NULL; xmlChar *newxml =3D NULL; @@ -544,7 +544,6 @@ virshMakeCloneXML(const char *origxml, const char *newn= ame) xmlDocDumpMemory(doc, &newxml, &size); =20 cleanup: - xmlFreeDoc(doc); return newxml; } =20 --=20 2.31.1 From nobody Sun May 5 17:07:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1628757585; cv=none; d=zohomail.com; s=zohoarc; b=Aiqv/xOBx+Kr/OqYxV9bcLfx702cSztlKRUlxsoiS8r2rhQNZy/56Hu8+W7CBKkWrLFd8i+lbuUOzCV0eXP32sjXmVhSoDFfcEVeJ2b0cfoMXqFhsoGSbJAhyMi8Z2oPgfa8UyWESA1J6UCdlAtNOgornAVX1ijj3XAMQWIXRg0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628757585; 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=mQUKqQ5rPeev7hI1EaJ4bdsF+hHxtkKX8wCCs/Y9Nkc=; b=ahrQkIGHytZh2m+aTlW5BLnkVeakmgNXJ3TshFrfdx3pZrThpchWaNMw6lSvKCjaBLgjLPqVFGpY2w+jBNb2uEG1E74y4wlNMlaJXv0535o41BtLudb6WrWxZbi1KpcXxnmWoZjiRoBMgo37a1nlP3W21hhDsLJyF5AdB8GMEG8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1628757585332117.68240571321212; Thu, 12 Aug 2021 01:39:45 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-162-002_mqJCPrCCKfTzInjXVA-1; Thu, 12 Aug 2021 04:39:42 -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 5B9291082924; Thu, 12 Aug 2021 08:39: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 3B55C60C9D; Thu, 12 Aug 2021 08:39: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 0616D181A2A9; Thu, 12 Aug 2021 08:39:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17C8XAAH003681 for ; Thu, 12 Aug 2021 04:33:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id EDFFC10372CC; Thu, 12 Aug 2021 08:33:10 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7510410013C1 for ; Thu, 12 Aug 2021 08:33:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628757584; 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=mQUKqQ5rPeev7hI1EaJ4bdsF+hHxtkKX8wCCs/Y9Nkc=; b=Kc9OCgqAqB5DLR2UZq2Ot/XhVoe2SNMmXbRwHiags4tVmJIShjqZW5+ExsWRE3jp99GMtc yUwWtayFlG9pMOXow8Yu111PwtuXes/LWUgf1qv8pY5oVtTDJGdYKnU372LgZ/w8tJGFce wQVTwLOG/3Fu5JJUCkLHHuZ8UwwznnY= X-MC-Unique: 002_mqJCPrCCKfTzInjXVA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 08/12] tools: virsh: use automatic cleanup for vshTable Date: Thu, 12 Aug 2021 10:32:46 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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) X-ZM-MESSAGEID: 1628757586281100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- tools/virsh-domain-monitor.c | 9 +++------ tools/virsh-domain.c | 9 +++------ tools/virsh-interface.c | 3 +-- tools/virsh-network.c | 9 +++------ tools/virsh-nwfilter.c | 6 ++---- tools/virsh-pool.c | 3 +-- tools/virsh-secret.c | 3 +-- tools/virsh-volume.c | 3 +-- tools/virt-admin.c | 6 ++---- 9 files changed, 17 insertions(+), 34 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index fb52915cab..4059acc7d6 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -602,7 +602,7 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) char *device =3D NULL; char *target =3D NULL; char *source =3D NULL; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 if (vshCommandOptBool(cmd, "inactive")) flags |=3D VIR_DOMAIN_XML_INACTIVE; @@ -686,7 +686,6 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - vshTableFree(table); VIR_FREE(source); VIR_FREE(target); VIR_FREE(device); @@ -723,7 +722,7 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd) int ninterfaces; xmlNodePtr *interfaces =3D NULL; size_t i; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 if (vshCommandOptBool(cmd, "inactive")) flags |=3D VIR_DOMAIN_XML_INACTIVE; @@ -775,7 +774,6 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - vshTableFree(table); VIR_FREE(interfaces); return ret; } @@ -1950,7 +1948,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd) char id_buf[VIR_INT64_STR_BUFLEN]; unsigned int id; unsigned int flags =3D VIR_CONNECT_LIST_DOMAINS_ACTIVE; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 /* construct filter flags */ if (vshCommandOptBool(cmd, "inactive") || @@ -2072,7 +2070,6 @@ cmdList(vshControl *ctl, const vshCmd *cmd) =20 ret =3D true; cleanup: - vshTableFree(table); virshDomainListFree(list); return ret; } diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index fe2bfdaed0..f72ec36f6f 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -6983,7 +6983,7 @@ virshVcpuPinQuery(vshControl *ctl, size_t i; int ncpus; bool ret =3D false; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 if ((ncpus =3D virshCPUCountCollect(ctl, dom, countFlags, true)) < 0) { if (ncpus =3D=3D -1) { @@ -7038,7 +7038,6 @@ virshVcpuPinQuery(vshControl *ctl, =20 ret =3D true; cleanup: - vshTableFree(table); VIR_FREE(cpumap); return ret; } @@ -7604,7 +7603,7 @@ cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd) virDomainIOThreadInfoPtr *info =3D NULL; size_t i; unsigned int flags =3D VIR_DOMAIN_AFFECT_CURRENT; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; bool ret =3D false; int rc; =20 @@ -7655,7 +7654,6 @@ cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd) for (i =3D 0; i < niothreads; i++) virDomainIOThreadInfoFree(info[i]); VIR_FREE(info); - vshTableFree(table); return ret; } =20 @@ -13907,7 +13905,7 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) int rc =3D -1; size_t i, j; virDomainFSInfoPtr *info =3D NULL; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; size_t ninfos =3D 0; bool ret =3D false; =20 @@ -13962,7 +13960,6 @@ cmdDomFSInfo(vshControl *ctl, const vshCmd *cmd) virDomainFSInfoFree(info[i]); VIR_FREE(info); } - vshTableFree(table); return ret; } =20 diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c index 71cc265efc..f88ec188f1 100644 --- a/tools/virsh-interface.c +++ b/tools/virsh-interface.c @@ -348,7 +348,7 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd G_G= NUC_UNUSED) struct virshInterfaceList *list =3D NULL; size_t i; bool ret =3D false; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 VSH_EXCLUSIVE_OPTIONS_VAR(all, inactive); =20 @@ -381,7 +381,6 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd G_G= NUC_UNUSED) =20 ret =3D true; cleanup: - vshTableFree(table); virshInterfaceListFree(list); return ret; } diff --git a/tools/virsh-network.c b/tools/virsh-network.c index 152df1086b..d641606dde 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -711,7 +711,7 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd G_GNU= C_UNUSED) bool optUUID =3D vshCommandOptBool(cmd, "uuid"); char uuid[VIR_UUID_STRING_BUFLEN]; unsigned int flags =3D VIR_CONNECT_LIST_NETWORKS_ACTIVE; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 if (vshCommandOptBool(cmd, "inactive")) flags =3D VIR_CONNECT_LIST_NETWORKS_INACTIVE; @@ -782,7 +782,6 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd G_GNU= C_UNUSED) =20 ret =3D true; cleanup: - vshTableFree(table); virshNetworkListFree(list); return ret; } @@ -1407,7 +1406,7 @@ cmdNetworkDHCPLeases(vshControl *ctl, const vshCmd *c= md) size_t i; unsigned int flags =3D 0; virNetworkPtr network =3D NULL; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 if (vshCommandOptStringReq(ctl, cmd, "mac", &mac) < 0) return false; @@ -1461,7 +1460,6 @@ cmdNetworkDHCPLeases(vshControl *ctl, const vshCmd *c= md) ret =3D true; =20 cleanup: - vshTableFree(table); if (leases) { for (i =3D 0; i < nleases; i++) virNetworkDHCPLeaseFree(leases[i]); @@ -1754,7 +1752,7 @@ cmdNetworkPortList(vshControl *ctl, const vshCmd *cmd) bool optUUID =3D vshCommandOptBool(cmd, "uuid"); char uuid[VIR_UUID_STRING_BUFLEN]; unsigned int flags =3D 0; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 if (optTable + optUUID > 1) { vshError(ctl, "%s", @@ -1795,7 +1793,6 @@ cmdNetworkPortList(vshControl *ctl, const vshCmd *cmd) =20 ret =3D true; cleanup: - vshTableFree(table); virshNetworkPortListFree(list); return ret; } diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c index 640e54446e..acb35e8aa1 100644 --- a/tools/virsh-nwfilter.c +++ b/tools/virsh-nwfilter.c @@ -354,7 +354,7 @@ cmdNWFilterList(vshControl *ctl, const vshCmd *cmd G_GN= UC_UNUSED) char uuid[VIR_UUID_STRING_BUFLEN]; bool ret =3D false; struct virshNWFilterList *list =3D NULL; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 if (!(list =3D virshNWFilterListCollect(ctl, 0))) return false; @@ -378,7 +378,6 @@ cmdNWFilterList(vshControl *ctl, const vshCmd *cmd G_GN= UC_UNUSED) =20 ret =3D true; cleanup: - vshTableFree(table); virshNWFilterListFree(list); return ret; } @@ -717,7 +716,7 @@ cmdNWFilterBindingList(vshControl *ctl, const vshCmd *c= md G_GNUC_UNUSED) size_t i; bool ret =3D false; struct virshNWFilterBindingList *list =3D NULL; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 if (!(list =3D virshNWFilterBindingListCollect(ctl, 0))) return false; @@ -740,7 +739,6 @@ cmdNWFilterBindingList(vshControl *ctl, const vshCmd *c= md G_GNUC_UNUSED) =20 ret =3D true; cleanup: - vshTableFree(table); virshNWFilterBindingListFree(list); return ret; } diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index 18f3839a4c..5bce5cf06c 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -1135,7 +1135,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd G_GNUC= _UNUSED) bool inactive, all; bool uuid =3D false; bool name =3D false; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 inactive =3D vshCommandOptBool(cmd, "inactive"); all =3D vshCommandOptBool(cmd, "all"); @@ -1390,7 +1390,6 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd G_GNUC= _UNUSED) ret =3D true; =20 cleanup: - vshTableFree(table); if (list && list->npools) { for (i =3D 0; i < list->npools; i++) { VIR_FREE(poolInfoTexts[i].state); diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c index cfecbb9b95..4f433fae9c 100644 --- a/tools/virsh-secret.c +++ b/tools/virsh-secret.c @@ -551,7 +551,7 @@ cmdSecretList(vshControl *ctl, const vshCmd *cmd G_GNUC= _UNUSED) struct virshSecretList *list =3D NULL; bool ret =3D false; unsigned int flags =3D 0; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 if (vshCommandOptBool(cmd, "ephemeral")) flags |=3D VIR_CONNECT_LIST_SECRETS_EPHEMERAL; @@ -605,7 +605,6 @@ cmdSecretList(vshControl *ctl, const vshCmd *cmd G_GNUC= _UNUSED) ret =3D true; =20 cleanup: - vshTableFree(table); virshSecretListFree(list); return ret; } diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index 6a1fe6785b..af93998d57 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -1415,7 +1415,7 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd G_GNUC_= UNUSED) }; struct volInfoText *volInfoTexts =3D NULL; struct virshStorageVolList *list =3D NULL; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 /* Look up the pool information given to us by the user */ if (!(pool =3D virshCommandOptPool(ctl, cmd, "pool", NULL))) @@ -1513,7 +1513,6 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd G_GNUC_= UNUSED) ret =3D true; =20 cleanup: - vshTableFree(table); =20 /* Safely free the memory allocated in this function */ if (list && list->nvols) { diff --git a/tools/virt-admin.c b/tools/virt-admin.c index dd17743b9d..c8e7ee794a 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -332,7 +332,7 @@ cmdSrvList(vshControl *ctl, const vshCmd *cmd G_GNUC_UN= USED) char *uri =3D NULL; virAdmServerPtr *srvs =3D NULL; vshAdmControl *priv =3D ctl->privData; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 /* Obtain a list of available servers on the daemon */ if ((nsrvs =3D virAdmConnectListServers(priv->conn, &srvs, 0)) < 0) { @@ -361,7 +361,6 @@ cmdSrvList(vshControl *ctl, const vshCmd *cmd G_GNUC_UN= USED) =20 ret =3D true; cleanup: - vshTableFree(table); if (srvs) { for (i =3D 0; i < nsrvs; i++) virAdmServerFree(srvs[i]); @@ -580,7 +579,7 @@ cmdSrvClientsList(vshControl *ctl, const vshCmd *cmd) virAdmServerPtr srv =3D NULL; virAdmClientPtr *clts =3D NULL; vshAdmControl *priv =3D ctl->privData; - vshTable *table =3D NULL; + g_autoptr(vshTable) table =3D NULL; =20 if (vshCommandOptStringReq(ctl, cmd, "server", &srvname) < 0) return false; @@ -621,7 +620,6 @@ cmdSrvClientsList(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - vshTableFree(table); if (clts) { for (i =3D 0; i < nclts; i++) virAdmClientFree(clts[i]); --=20 2.31.1 From nobody Sun May 5 17:07:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1628757588; cv=none; d=zohomail.com; s=zohoarc; b=TEZu9TCZn6JEFkBUvgFVAOdrzK7nYRdmh9Arq7Cjv7l7auEz4d03XCcVesS2V/VsdfR1uAeZ4GI96B5mPcUjw0qMGbUXUZw4f4CAvEJm0tQ2XQGiJR50Pt9ReZzhZ5BzJr7pnhDr4Q3qttyBeFJZqVmpd2yFCpq+OKkpddDX4RM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628757588; 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=adZsM/LeAD8UVudNoumZtMhpy1skqoTMSWl+ZIlz2Bs=; b=EMVglPDK4cm7bt4CSNGUs1Qj2bmm+s7PzcKgyjDBn6n7pt0DZ37BCgnod/h5QyhhlwRKzdkRwB87vRc7hqnCpClCS+E7VJDGOtf8NfHBgaoG1sds792d7bKNAPLrdXWR46EATZPrYJuocfTv+sbx+q5v4hxBxdeX5BSqOYAHQC4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1628757588816348.1050783581328; Thu, 12 Aug 2021 01:39:48 -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-338-YDrtqhxWMdaTljOQTLzRxQ-1; Thu, 12 Aug 2021 04:39:45 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 142DF760C6; Thu, 12 Aug 2021 08:39:40 +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 E9B966789A; Thu, 12 Aug 2021 08:39:39 +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 B7199181A2AE; Thu, 12 Aug 2021 08:39:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17C8XBgE003693 for ; Thu, 12 Aug 2021 04:33:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id C084E10372CC; Thu, 12 Aug 2021 08:33:11 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4867B10013C1 for ; Thu, 12 Aug 2021 08:33:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628757587; 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=adZsM/LeAD8UVudNoumZtMhpy1skqoTMSWl+ZIlz2Bs=; b=jWokzr7+39eqfMubLOTSax48au9PXgtdKx1yWhBpRIWIwxtkl96Lek8UCjPx9D8cHkdj88 O25wkDniSBQVob8muFClJm739/mPvsJreDL2lWkMConAvs/cql2RPtNuwB5aSggj+GLfRl +1ZQpjubxaCo+8/uLIhh33biLCQVhuM= X-MC-Unique: YDrtqhxWMdaTljOQTLzRxQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 09/12] tools: virsh: reduce variable scope to use automatic cleanup Date: Thu, 12 Aug 2021 10:32:47 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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.16 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) X-ZM-MESSAGEID: 1628757590516100001 Some variables are used in a loop and only freed in the cleanup section because we need to be able to jump out of the loop. Reduce their scope and free them automatically. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- tools/virsh-domain-monitor.c | 39 +++++++++++++----------------------- tools/virsh-domain.c | 34 +++++++++---------------------- 2 files changed, 23 insertions(+), 50 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 4059acc7d6..b07959b1ee 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -598,10 +598,6 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) xmlNodePtr *disks =3D NULL; size_t i; bool details =3D false; - char *type =3D NULL; - char *device =3D NULL; - char *target =3D NULL; - char *source =3D NULL; g_autoptr(vshTable) table =3D NULL; =20 if (vshCommandOptBool(cmd, "inactive")) @@ -625,6 +621,11 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) goto cleanup; =20 for (i =3D 0; i < ndisks; i++) { + g_autofree char *type =3D NULL; + g_autofree char *device =3D NULL; + g_autofree char *target =3D NULL; + g_autofree char *source =3D NULL; + ctxt->node =3D disks[i]; =20 type =3D virXPathString("string(./@type)", ctxt); @@ -674,11 +675,6 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) NULLSTR_MINUS(source), NULL) < 0) goto cleanup; } - - VIR_FREE(source); - VIR_FREE(target); - VIR_FREE(device); - VIR_FREE(type); } =20 vshTablePrintToStdout(table, ctl); @@ -686,10 +682,6 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - VIR_FREE(source); - VIR_FREE(target); - VIR_FREE(device); - VIR_FREE(type); VIR_FREE(disks); return ret; } @@ -999,7 +991,6 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd) virDomainBlockStatsStruct stats; virTypedParameterPtr params =3D NULL; virTypedParameterPtr par =3D NULL; - char *value =3D NULL; const char *field =3D NULL; int rc, nparams =3D 0; size_t i; @@ -1065,6 +1056,8 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd) =20 /* at first print all known values in desired order */ for (i =3D 0; domblkstat_output[i].field !=3D NULL; i++) { + g_autofree char *value =3D NULL; + if (!(par =3D virTypedParamsGet(params, nparams, domblkstat_output[i].field))) continue; @@ -1087,18 +1080,17 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd) =20 vshPrint(ctl, "%s %-*s %s\n", device, human ? 31 : 0, field, value); - - VIR_FREE(value); } =20 /* go through the fields again, for remaining fields */ for (i =3D 0; i < nparams; i++) { + g_autofree char *value =3D NULL; + if (!*params[i].field) continue; =20 value =3D vshGetTypedParamValue(ctl, params+i); vshPrint(ctl, "%s %s %s\n", device, params[i].field, value); - VIR_FREE(value); } } =20 @@ -1939,7 +1931,6 @@ cmdList(vshControl *ctl, const vshCmd *cmd) bool optName =3D vshCommandOptBool(cmd, "name"); bool optID =3D vshCommandOptBool(cmd, "id"); size_t i; - char *title; char uuid[VIR_UUID_STRING_BUFLEN]; int state; bool ret =3D false; @@ -2022,6 +2013,8 @@ cmdList(vshControl *ctl, const vshCmd *cmd) state =3D -2; =20 if (optTitle) { + g_autofree char *title =3D NULL; + if (!(title =3D virshGetDomainDescription(ctl, dom, true, = 0))) goto cleanup; if (vshTableRowAppend(table, id_buf, @@ -2030,7 +2023,6 @@ cmdList(vshControl *ctl, const vshCmd *cmd) : virshDomainStateToString(state), title, NULL) < 0) goto cleanup; - VIR_FREE(title); } else { if (vshTableRowAppend(table, id_buf, virDomainGetName(dom), @@ -2187,7 +2179,6 @@ virshDomainStatsPrintRecord(vshControl *ctl G_GNUC_UN= USED, virDomainStatsRecordPtr record, bool raw G_GNUC_UNUSED) { - char *param; size_t i; =20 vshPrint(ctl, "Domain: '%s'\n", virDomainGetName(record->dom)); @@ -2195,12 +2186,12 @@ virshDomainStatsPrintRecord(vshControl *ctl G_GNUC_= UNUSED, /* XXX: Implement pretty-printing */ =20 for (i =3D 0; i < record->nparams; i++) { + g_autofree char *param =3D NULL; + if (!(param =3D vshGetTypedParamValue(ctl, record->params + i))) return false; =20 vshPrint(ctl, " %s=3D%s\n", record->params[i].field, param); - - VIR_FREE(param); } =20 return true; @@ -2400,7 +2391,6 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd) =20 for (i =3D 0; i < ifaces_count; i++) { virDomainInterfacePtr iface =3D ifaces[i]; - char *ip_addr_str =3D NULL; const char *type =3D NULL; =20 if (ifacestr && STRNEQ(ifacestr, iface->name)) @@ -2416,6 +2406,7 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd) =20 for (j =3D 0; j < iface->naddrs; j++) { g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + g_autofree char *ip_addr_str =3D NULL; =20 switch (iface->addrs[j].type) { case VIR_IP_ADDR_TYPE_IPV4: @@ -2443,8 +2434,6 @@ cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd) else vshPrint(ctl, " %-10s %-17s %s\n", "-", "-", ip_addr_str); - - VIR_FREE(ip_addr_str); } } =20 diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index f72ec36f6f..542e2a1736 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -3055,7 +3055,6 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshDomain) dom =3D NULL; const char *iface; const char *state; - char *value; virMacAddr macaddr; const char *element; const char *attr; @@ -3119,13 +3118,10 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) while (cur) { if (cur->type =3D=3D XML_ELEMENT_NODE && virXMLNodeNameEqual(cur, element)) { - value =3D virXMLPropString(cur, attr); + g_autofree char *value =3D virXMLPropString(cur, attr); =20 - if (STRCASEEQ(value, iface)) { - VIR_FREE(value); + if (STRCASEEQ(value, iface)) goto hit; - } - VIR_FREE(value); } cur =3D cur->next; } @@ -3639,9 +3635,6 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd) g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr *vol_nodes =3D NULL; /* XML nodes of volumes of the guest= */ int nvol_nodes; - char *source =3D NULL; - char *target =3D NULL; - char *pool =3D NULL; size_t i; size_t j; virshControl *priv =3D ctl->privData; @@ -3759,14 +3752,13 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd) goto error; =20 for (i =3D 0; i < nvol_nodes; i++) { + g_autofree char *source =3D NULL; + g_autofree char *target =3D NULL; + g_autofree char *pool =3D NULL; virshUndefineVolume vol; =20 ctxt->node =3D vol_nodes[i]; =20 - VIR_FREE(source); - VIR_FREE(target); - VIR_FREE(pool); - /* get volume source and target paths */ if (!(target =3D virXPathString("string(./target/@dev)", ctxt)= )) goto error; @@ -3936,9 +3928,6 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd) } =20 cleanup: - VIR_FREE(source); - VIR_FREE(target); - VIR_FREE(pool); for (i =3D 0; i < nvols; i++) { VIR_FREE(vols[i].source); VIR_FREE(vols[i].target); @@ -5096,7 +5085,6 @@ cmdSchedInfoUpdate(vshControl *ctl, const vshCmd *cmd, virTypedParameterPtr src_params, int nsrc_params, virTypedParameterPtr *update_params) { - char *set_field =3D NULL; char *set_val =3D NULL; const char *val =3D NULL; const vshCmdOpt *opt =3D NULL; @@ -5107,7 +5095,8 @@ cmdSchedInfoUpdate(vshControl *ctl, const vshCmd *cmd, int rv; =20 while ((opt =3D vshCommandOptArgv(ctl, cmd, opt))) { - set_field =3D g_strdup(opt->data); + g_autofree char *set_field =3D g_strdup(opt->data); + if (!(set_val =3D strchr(set_field, '=3D'))) { vshError(ctl, "%s", _("Invalid syntax for --set, " "expecting name=3Dvalue")); @@ -5121,8 +5110,6 @@ cmdSchedInfoUpdate(vshControl *ctl, const vshCmd *cmd, ¶ms, &nparams, &maxparams, set_field, set_val) < 0) goto cleanup; - - VIR_FREE(set_field); } =20 rv =3D vshCommandOptStringReq(ctl, cmd, "cap", &val); @@ -5145,7 +5132,6 @@ cmdSchedInfoUpdate(vshControl *ctl, const vshCmd *cmd, *update_params =3D g_steal_pointer(¶ms); =20 cleanup: - VIR_FREE(set_field); virTypedParamsFree(params, nparams); return ret; } @@ -6759,7 +6745,6 @@ virshDomainGetVcpuBitmap(vshControl *ctl, unsigned int curvcpus =3D 0; unsigned int maxvcpus =3D 0; unsigned int vcpuid; - char *online =3D NULL; =20 if (inactive) flags |=3D VIR_DOMAIN_XML_INACTIVE; @@ -6788,6 +6773,8 @@ virshDomainGetVcpuBitmap(vshControl *ctl, } =20 for (i =3D 0; i < nnodes; i++) { + g_autofree char *online =3D NULL; + ctxt->node =3D nodes[i]; =20 if (virXPathUInt("string(@id)", ctxt, &vcpuid) < 0 || @@ -6796,8 +6783,6 @@ virshDomainGetVcpuBitmap(vshControl *ctl, =20 if (STREQ(online, "yes")) ignore_value(virBitmapSetBit(ret, vcpuid)); - - VIR_FREE(online); } =20 if (virBitmapCountBits(ret) !=3D curvcpus) { @@ -6807,7 +6792,6 @@ virshDomainGetVcpuBitmap(vshControl *ctl, } =20 cleanup: - VIR_FREE(online); VIR_FREE(nodes); return ret; } --=20 2.31.1 From nobody Sun May 5 17:07:13 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=1628757501; cv=none; d=zohomail.com; s=zohoarc; b=GrUxb4sKRt4WAgmqREvicEnOKf1bKMph9kEIn246iRIKaEUfdF4NwHiEQNIBcV6efpVFET6BV4Z1M5n0NohJIxvVgalH8olKDz0Yt6FA7qArhrsU/CwcGFB9/uWlFub4OPz2R45YaqC3qrKmz2ia0NCFLg59eR3PdQzfq1pFjDM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628757501; 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=y0mC0iVaMyCAqGcMTxNoEvFDEbI6M/R94QLL0i1YN9Q=; b=FyxOLF1J16gl39oF5W6t1PhJHfh1QRrn6tAY/+s0giDBOZAcEEWp1qvZyGCp/F/SDQtrsdEOkPrUZVZiceTy5/Dss/XOngcbgCQwtzM499a7N2yec7cQ3FZgbD1xANuNtvhPexp4g9wLToAkAyBlxBxJVqhSZyjtv8P5fG8MhtU= 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) 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 162875750170331.380467079793902; Thu, 12 Aug 2021 01:38:21 -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-127-9TlRgPZZME6HReqa4vm-Tg-1; Thu, 12 Aug 2021 04:38:17 -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 F1347190A7A2; Thu, 12 Aug 2021 08:38:10 +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 416A710016FB; Thu, 12 Aug 2021 08:38:07 +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 413B34BB7B; Thu, 12 Aug 2021 08:38:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17C8XGnC003720 for ; Thu, 12 Aug 2021 04:33:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5E23C10013C1; Thu, 12 Aug 2021 08:33:16 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id DAAAB10016FF for ; Thu, 12 Aug 2021 08:33:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628757500; 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=y0mC0iVaMyCAqGcMTxNoEvFDEbI6M/R94QLL0i1YN9Q=; b=WRNYE9dSGdF8jl4GtbtmyDGR9vQUqjQU/Wny1FaewDM/G/x+hDcT3//jSK//NFrns6ZJWe nYuPmr1sbbFXMxibzW3x0aRh0149rpRt5Fc5Xww7dRfFbfz0nUbtdsHDJRume3EPIJ7o1V /cfoWkzrA5PJiIdvjv/1v7ctkuBW7Ig= X-MC-Unique: 9TlRgPZZME6HReqa4vm-Tg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 10/12] tools: virsh: use automatic cleanup for char ** Date: Thu, 12 Aug 2021 10:32:48 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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) X-ZM-MESSAGEID: 1628757502726100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- tools/virsh-domain.c | 11 +++-------- tools/virsh-host.c | 3 +-- tools/virsh-nodedev.c | 6 ++---- tools/virsh-pool.c | 4 +--- 4 files changed, 7 insertions(+), 17 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 542e2a1736..0636bbfa31 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -4002,7 +4002,7 @@ cmdStartGetFDs(vshControl *ctl, int **fdsret) { const char *fdopt; - char **fdlist =3D NULL; + g_auto(GStrv) fdlist =3D NULL; int *fds =3D NULL; size_t nfds =3D 0; size_t i; @@ -4028,14 +4028,11 @@ cmdStartGetFDs(vshControl *ctl, fds[nfds - 1] =3D fd; } =20 - g_strfreev(fdlist); - *fdsret =3D fds; *nfdsret =3D nfds; return 0; =20 error: - g_strfreev(fdlist); VIR_FREE(fds); return -1; } @@ -5859,7 +5856,7 @@ cmdShutdown(vshControl *ctl, const vshCmd *cmd) const char *mode =3D NULL; int flags =3D 0; int rv; - char **modes =3D NULL; + g_auto(GStrv) modes =3D NULL; char **tmp; =20 if (vshCommandOptStringReq(ctl, cmd, "mode", &mode) < 0) @@ -5908,7 +5905,6 @@ cmdShutdown(vshControl *ctl, const vshCmd *cmd) =20 ret =3D true; cleanup: - g_strfreev(modes); return ret; } =20 @@ -5943,7 +5939,7 @@ cmdReboot(vshControl *ctl, const vshCmd *cmd) const char *name; const char *mode =3D NULL; int flags =3D 0; - char **modes =3D NULL; + g_auto(GStrv) modes =3D NULL; char **tmp; =20 if (vshCommandOptStringReq(ctl, cmd, "mode", &mode) < 0) @@ -5988,7 +5984,6 @@ cmdReboot(vshControl *ctl, const vshCmd *cmd) =20 ret =3D true; cleanup: - g_strfreev(modes); return ret; } =20 diff --git a/tools/virsh-host.c b/tools/virsh-host.c index a07f5adbfa..df1fe49e09 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -1301,7 +1301,7 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd) const char *from =3D NULL; bool ret =3D false; char *result =3D NULL; - char **list =3D NULL; + g_auto(GStrv) list =3D NULL; unsigned int flags =3D 0; virshControl *priv =3D ctl->privData; =20 @@ -1326,7 +1326,6 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd) } =20 VIR_FREE(result); - g_strfreev(list); return ret; } =20 diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index 5b1afe4601..c6c7d97d50 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -115,7 +115,7 @@ static virNodeDevice* vshFindNodeDevice(vshControl *ctl, const char *value) { virNodeDevicePtr dev =3D NULL; - char **arr =3D NULL; + g_auto(GStrv) arr =3D NULL; int narr; virshControl *priv =3D ctl->privData; =20 @@ -140,7 +140,6 @@ vshFindNodeDevice(vshControl *ctl, const char *value) } =20 cleanup: - g_strfreev(arr); return dev; } =20 @@ -409,7 +408,7 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd G= _GNUC_UNUSED) bool tree =3D vshCommandOptBool(cmd, "tree"); bool ret =3D true; unsigned int flags =3D 0; - char **caps =3D NULL; + g_auto(GStrv) caps =3D NULL; int ncaps =3D 0; struct virshNodeDeviceList *list =3D NULL; int cap_type =3D -1; @@ -555,7 +554,6 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd G= _GNUC_UNUSED) } =20 cleanup: - g_strfreev(caps); virshNodeDeviceListFree(list); return ret; } diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index 5bce5cf06c..03987770f6 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -1175,7 +1175,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd G_GNUC= _UNUSED) =20 if (type) { int poolType =3D -1; - char **poolTypes =3D NULL; + g_auto(GStrv) poolTypes =3D NULL; int npoolTypes =3D 0; =20 if ((npoolTypes =3D vshStringToArray(type, &poolTypes)) < 0) @@ -1184,7 +1184,6 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd G_GNUC= _UNUSED) for (i =3D 0; i < npoolTypes; i++) { if ((poolType =3D virStoragePoolTypeFromString(poolTypes[i])) = < 0) { vshError(ctl, _("Invalid pool type '%s'"), poolTypes[i]); - g_strfreev(poolTypes); return false; } =20 @@ -1235,7 +1234,6 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd G_GNUC= _UNUSED) break; } } - g_strfreev(poolTypes); } =20 if (!(list =3D virshStoragePoolListCollect(ctl, flags))) --=20 2.31.1 From nobody Sun May 5 17:07:13 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=1628757561; cv=none; d=zohomail.com; s=zohoarc; b=HwosbP2p/oGHAcpoI0hnfcbU6Z9bFfbyL9durAaPu6EA2WpyNEkCr9+3X0yVibt74/PVYiRz5L+jlYDd7HapdCETNoWaeKBzte2mQCtbEiYwZvoO2V5XHya1r9c/oRunqrCnVW62chAeK31jCshGCR2Z0RCSUrWzsDIyt9/J/6M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628757561; 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=CPI17F5LWGqUqlwLxMVo5V12VqhFYZJlCYMClQ0bxwQ=; b=aePYzuY78pAy+pSdfEcYt6MikX94XcbY/9IilYDwgH66yhvU0d8Ye8DDbYVnlKy7WB9cdIJVQIUxbT2yDkYRPhzdsThlG7c0tNl+L8un5yu7lrCvakoEwLCKRuBKESQvPU+7coekKyOkcI9OLSx76xoSvXAKb7WFHpfdApbeKQw= 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) 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 1628757561929904.8992228385829; Thu, 12 Aug 2021 01:39:21 -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-369-j1s7FLUcM8aYccy8DY2IHQ-1; Thu, 12 Aug 2021 04:39:18 -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 DE95E801B3D; Thu, 12 Aug 2021 08:39:12 +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 C1FFC77708; Thu, 12 Aug 2021 08:39:12 +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 8E9D9181A12D; Thu, 12 Aug 2021 08:39:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17C8XHFl003725 for ; Thu, 12 Aug 2021 04:33:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5933610013C1; Thu, 12 Aug 2021 08:33:17 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE1B810372C0 for ; Thu, 12 Aug 2021 08:33:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628757560; 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=CPI17F5LWGqUqlwLxMVo5V12VqhFYZJlCYMClQ0bxwQ=; b=K9HfXRu4rd0JhXWs/vVx9sC25rex0x93xnc+ka9BxE5jrxsorps4x3LyAmS3My3kriDsxZ oXLSfNT+PdubimrHpkAGBM4vlig6qTsLk2qziuP7yaX1a7zLfixSyC3Kqt77V0XKju5MP3 vziAz20JZCu3pDuuW+C2zgGfMQHuQj0= X-MC-Unique: j1s7FLUcM8aYccy8DY2IHQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 11/12] tools: virsh: use g_autofree Date: Thu, 12 Aug 2021 10:32:49 +0200 Message-Id: <7662b66422668346d6083552287a13cfd086c3e4.1628756993.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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) X-ZM-MESSAGEID: 1628757562929100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- tools/virsh-domain-monitor.c | 18 ++-- tools/virsh-domain.c | 168 ++++++++++++----------------------- tools/virsh-host.c | 92 ++++++------------- tools/virsh-interface.c | 6 +- tools/virsh-network.c | 15 ++-- tools/virsh-nodedev.c | 14 +-- tools/virsh-nwfilter.c | 9 +- tools/virsh-pool.c | 27 ++---- tools/virsh-secret.c | 6 +- tools/virsh-util.c | 3 +- tools/virsh-volume.c | 18 ++-- tools/virsh.c | 3 +- 12 files changed, 122 insertions(+), 257 deletions(-) diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index b07959b1ee..49f632f11b 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -595,7 +595,7 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) g_autoptr(xmlDoc) xmldoc =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; int ndisks; - xmlNodePtr *disks =3D NULL; + g_autofree xmlNodePtr *disks =3D NULL; size_t i; bool details =3D false; g_autoptr(vshTable) table =3D NULL; @@ -682,7 +682,6 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - VIR_FREE(disks); return ret; } =20 @@ -712,7 +711,7 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd) g_autoptr(xmlDoc) xmldoc =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; int ninterfaces; - xmlNodePtr *interfaces =3D NULL; + g_autofree xmlNodePtr *interfaces =3D NULL; size_t i; g_autoptr(vshTable) table =3D NULL; =20 @@ -766,7 +765,6 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - VIR_FREE(interfaces); return ret; } =20 @@ -803,13 +801,13 @@ static bool cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd) { const char *iface =3D NULL; - char *state =3D NULL; - char *xpath =3D NULL; + g_autofree char *state =3D NULL; + g_autofree char *xpath =3D NULL; virMacAddr macaddr; char macstr[VIR_MAC_STRING_BUFLEN] =3D ""; g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; - xmlNodePtr *interfaces =3D NULL; + g_autofree xmlNodePtr *interfaces =3D NULL; int ninterfaces; unsigned int flags =3D 0; bool ret =3D false; @@ -858,9 +856,6 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - VIR_FREE(state); - VIR_FREE(interfaces); - VIR_FREE(xpath); =20 return ret; } @@ -989,7 +984,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshDomain) dom =3D NULL; const char *name =3D NULL, *device =3D NULL; virDomainBlockStatsStruct stats; - virTypedParameterPtr params =3D NULL; + g_autofree virTypedParameterPtr params =3D NULL; virTypedParameterPtr par =3D NULL; const char *field =3D NULL; int rc, nparams =3D 0; @@ -1097,7 +1092,6 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - VIR_FREE(params); return ret; } #undef DOMBLKSTAT_LEGACY_PRINT diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 0636bbfa31..0b536b75dd 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -890,7 +890,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) int ret; bool functionReturn =3D false; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; - char *xml =3D NULL; + g_autofree char *xml =3D NULL; unsigned int flags =3D VIR_DOMAIN_AFFECT_CURRENT; bool current =3D vshCommandOptBool(cmd, "current"); bool config =3D vshCommandOptBool(cmd, "config"); @@ -1072,7 +1072,6 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) } =20 cleanup: - VIR_FREE(xml); return functionReturn; } =20 @@ -1424,9 +1423,8 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd) } =20 for (i =3D 0; i < nparams; i++) { - char *str =3D vshGetTypedParamValue(ctl, ¶ms[i]); + g_autofree char *str =3D vshGetTypedParamValue(ctl, ¶ms[i]= ); vshPrint(ctl, "%-15s: %s\n", params[i].field, str); - VIR_FREE(str); } } else { if (virDomainSetBlockIoTune(dom, disk, params, nparams, flags) < 0) @@ -1619,9 +1617,8 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd) } =20 for (i =3D 0; i < nparams; i++) { - char *str =3D vshGetTypedParamValue(ctl, ¶ms[i]); + g_autofree char *str =3D vshGetTypedParamValue(ctl, ¶ms[i]= ); vshPrint(ctl, "%-15s: %s\n", params[i].field, str); - VIR_FREE(str); } } else { /* set the blkio parameters */ @@ -3067,7 +3064,7 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) g_autoptr(xmlXPathContext) ctxt =3D NULL; g_autoptr(xmlXPathObject) obj =3D NULL; xmlNodePtr cur =3D NULL; - char *xml_buf =3D NULL; + g_autofree char *xml_buf =3D NULL; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -3174,7 +3171,6 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) } =20 cleanup: - VIR_FREE(xml_buf); =20 return ret; } @@ -3352,9 +3348,8 @@ cmdDomIftune(vshControl *ctl, const vshCmd *cmd) } =20 for (i =3D 0; i < nparams; i++) { - char *str =3D vshGetTypedParamValue(ctl, ¶ms[i]); + g_autofree char *str =3D vshGetTypedParamValue(ctl, ¶ms[i]= ); vshPrint(ctl, "%-15s: %s\n", params[i].field, str); - VIR_FREE(str); } } else { if (virDomainSetInterfaceParameters(dom, device, params, @@ -4048,7 +4043,7 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) unsigned int flags =3D VIR_DOMAIN_NONE; int rc; size_t nfds =3D 0; - int *fds =3D NULL; + g_autofree int *fds =3D NULL; =20 if (!(dom =3D virshCommandOptDomainBy(ctl, cmd, NULL, VIRSH_BYNAME | VIRSH_BYUUID))) @@ -4115,7 +4110,6 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - VIR_FREE(fds); return ret; } =20 @@ -4169,7 +4163,7 @@ doSave(void *opaque) const char *to =3D NULL; unsigned int flags =3D 0; const char *xmlfile =3D NULL; - char *xml =3D NULL; + g_autofree char *xml =3D NULL; #ifndef WIN32 sigset_t sigmask, oldsigmask; =20 @@ -4215,7 +4209,6 @@ doSave(void *opaque) pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL); out_sig: #endif /* !WIN32 */ - VIR_FREE(xml); g_main_loop_quit(data->eventLoop); } =20 @@ -4494,7 +4487,7 @@ cmdSaveImageDumpxml(vshControl *ctl, const vshCmd *cm= d) const char *file =3D NULL; bool ret =3D false; unsigned int flags =3D 0; - char *xml =3D NULL; + g_autofree char *xml =3D NULL; virshControl *priv =3D ctl->privData; =20 if (vshCommandOptBool(cmd, "security-info")) @@ -4511,7 +4504,6 @@ cmdSaveImageDumpxml(vshControl *ctl, const vshCmd *cm= d) ret =3D true; =20 cleanup: - VIR_FREE(xml); return ret; } =20 @@ -4552,7 +4544,7 @@ cmdSaveImageDefine(vshControl *ctl, const vshCmd *cmd) const char *file =3D NULL; bool ret =3D false; const char *xmlfile =3D NULL; - char *xml =3D NULL; + g_autofree char *xml =3D NULL; unsigned int flags =3D 0; virshControl *priv =3D ctl->privData; =20 @@ -4579,7 +4571,6 @@ cmdSaveImageDefine(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - VIR_FREE(xml); return ret; } =20 @@ -4918,7 +4909,7 @@ cmdManagedSaveDumpxml(vshControl *ctl, const vshCmd *= cmd) bool ret =3D false; g_autoptr(virshDomain) dom =3D NULL; unsigned int flags =3D 0; - char *xml =3D NULL; + g_autofree char *xml =3D NULL; =20 if (vshCommandOptBool(cmd, "security-info")) flags |=3D VIR_DOMAIN_XML_SECURE; @@ -4933,7 +4924,6 @@ cmdManagedSaveDumpxml(vshControl *ctl, const vshCmd *= cmd) ret =3D true; =20 cleanup: - VIR_FREE(xml); return ret; } =20 @@ -4974,7 +4964,7 @@ cmdManagedSaveDefine(vshControl *ctl, const vshCmd *c= md) bool ret =3D false; g_autoptr(virshDomain) dom =3D NULL; const char *xmlfile =3D NULL; - char *xml =3D NULL; + g_autofree char *xml =3D NULL; unsigned int flags =3D 0; =20 if (vshCommandOptBool(cmd, "running")) @@ -5004,7 +4994,6 @@ cmdManagedSaveDefine(vshControl *ctl, const vshCmd *c= md) ret =3D true; =20 cleanup: - VIR_FREE(xml); return ret; } =20 @@ -5278,7 +5267,7 @@ cmdRestore(vshControl *ctl, const vshCmd *cmd) bool ret =3D false; unsigned int flags =3D 0; const char *xmlfile =3D NULL; - char *xml =3D NULL; + g_autofree char *xml =3D NULL; virshControl *priv =3D ctl->privData; =20 if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) @@ -5309,7 +5298,6 @@ cmdRestore(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - VIR_FREE(xml); return ret; } =20 @@ -6702,7 +6690,7 @@ virshVcpuinfoPrintAffinity(vshControl *ctl, int maxcpu, bool pretty) { - char *str =3D NULL; + g_autofree char *str =3D NULL; size_t i; int ret =3D -1; =20 @@ -6720,7 +6708,6 @@ virshVcpuinfoPrintAffinity(vshControl *ctl, ret =3D 0; =20 cleanup: - VIR_FREE(str); return ret; } =20 @@ -6734,7 +6721,7 @@ virshDomainGetVcpuBitmap(vshControl *ctl, virBitmap *ret =3D NULL; g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; - xmlNodePtr *nodes =3D NULL; + g_autofree xmlNodePtr *nodes =3D NULL; int nnodes; size_t i; unsigned int curvcpus =3D 0; @@ -6787,7 +6774,6 @@ virshDomainGetVcpuBitmap(vshControl *ctl, } =20 cleanup: - VIR_FREE(nodes); return ret; } =20 @@ -6937,13 +6923,12 @@ virshPrintPinInfo(vshControl *ctl, unsigned char *cpumap, size_t cpumaplen) { - char *str =3D NULL; + g_autofree char *str =3D NULL; =20 if (!(str =3D virBitmapDataFormat(cpumap, cpumaplen))) return false; =20 vshPrint(ctl, "%s", str); - VIR_FREE(str); return true; } =20 @@ -6956,7 +6941,7 @@ virshVcpuPinQuery(vshControl *ctl, int maxcpu, unsigned int flags) { - unsigned char *cpumap =3D NULL; + g_autofree unsigned char *cpumap =3D NULL; unsigned int countFlags =3D flags | VIR_DOMAIN_VCPU_MAXIMUM; int cpumaplen; size_t i; @@ -7017,7 +7002,6 @@ virshVcpuPinQuery(vshControl *ctl, =20 ret =3D true; cleanup: - VIR_FREE(cpumap); return ret; } =20 @@ -7063,7 +7047,7 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd) unsigned int vcpu =3D 0; const char *cpulist =3D NULL; bool ret =3D false; - unsigned char *cpumap =3D NULL; + g_autofree unsigned char *cpumap =3D NULL; int cpumaplen; int maxcpu; bool config =3D vshCommandOptBool(cmd, "config"); @@ -7123,7 +7107,6 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - VIR_FREE(cpumap); return ret; } =20 @@ -7160,7 +7143,7 @@ cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshDomain) dom =3D NULL; const char *cpulist =3D NULL; bool ret =3D false; - unsigned char *cpumap =3D NULL; + g_autofree unsigned char *cpumap =3D NULL; int cpumaplen; int maxcpu; bool config =3D vshCommandOptBool(cmd, "config"); @@ -7225,7 +7208,6 @@ cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd) =20 ret =3D true; cleanup: - VIR_FREE(cpumap); return ret; } =20 @@ -7680,7 +7662,7 @@ cmdIOThreadPin(vshControl *ctl, const vshCmd *cmd) unsigned int iothread_id =3D 0; int maxcpu; bool ret =3D false; - unsigned char *cpumap =3D NULL; + g_autofree unsigned char *cpumap =3D NULL; int cpumaplen; unsigned int flags =3D VIR_DOMAIN_AFFECT_CURRENT; virshControl *priv =3D ctl->privData; @@ -7715,7 +7697,6 @@ cmdIOThreadPin(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - VIR_FREE(cpumap); return ret; } =20 @@ -7996,9 +7977,8 @@ vshCPUStatsPrintField(vshControl *ctl, param->value.ul / 1000000000, param->value.ul % 1000000000); } else { - char *s =3D vshGetTypedParamValue(ctl, param); + g_autofree char *s =3D vshGetTypedParamValue(ctl, param); vshPrint(ctl, "%s\n", s); - VIR_FREE(s); } } =20 @@ -8180,13 +8160,13 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshDomain) dom =3D NULL; const char *from =3D NULL; bool ret =3D false; - char *buffer; + g_autofree char *buffer =3D NULL; #ifndef WIN32 bool console =3D vshCommandOptBool(cmd, "console"); #endif unsigned int flags =3D 0; size_t nfds =3D 0; - int *fds =3D NULL; + g_autofree int *fds =3D NULL; virshControl *priv =3D ctl->privData; =20 if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) @@ -8224,8 +8204,6 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - VIR_FREE(buffer); - VIR_FREE(fds); return ret; } =20 @@ -8623,14 +8601,13 @@ cmdMetadata(vshControl *ctl, const vshCmd *cmd) =20 vshPrintExtra(ctl, "%s\n", _("Metadata modified")); } else { - char *data; + g_autofree char *data =3D NULL; /* get */ if (!(data =3D virDomainGetMetadata(dom, VIR_DOMAIN_METADATA_ELEME= NT, uri, flags))) goto cleanup; =20 vshPrint(ctl, "%s\n", data); - VIR_FREE(data); } =20 ret =3D true; @@ -9172,9 +9149,8 @@ cmdMemtune(vshControl *ctl, const vshCmd *cmd) params[i].value.ul =3D=3D VIR_DOMAIN_MEMORY_PARAM_UNLIMITE= D) { vshPrint(ctl, "%-15s: %s\n", params[i].field, _("unlimited= ")); } else { - char *str =3D vshGetTypedParamValue(ctl, ¶ms[i]); + g_autofree char *str =3D vshGetTypedParamValue(ctl, ¶m= s[i]); vshPrint(ctl, "%-15s: %s\n", params[i].field, str); - VIR_FREE(str); } } } else { @@ -9441,9 +9417,8 @@ cmdNumatune(vshControl * ctl, const vshCmd * cmd) vshPrint(ctl, "%-15s: %s\n", params[i].field, virDomainNumatuneMemModeTypeToString(params[i].va= lue.i)); } else { - char *str =3D vshGetTypedParamValue(ctl, ¶ms[i]); + g_autofree char *str =3D vshGetTypedParamValue(ctl, ¶m= s[i]); vshPrint(ctl, "%-15s: %s\n", params[i].field, str); - VIR_FREE(str); } } } else { @@ -9587,7 +9562,7 @@ virshEventQemuPrint(virConnectPtr conn G_GNUC_UNUSED, { virshQemuEventData *data =3D opaque; virJSONValue *pretty =3D NULL; - char *str =3D NULL; + g_autofree char *str =3D NULL; =20 if (!data->loop && data->count) return; @@ -9613,8 +9588,6 @@ virshEventQemuPrint(virConnectPtr conn G_GNUC_UNUSED, data->count++; if (!data->loop) vshEventDone(data->ctl); - - VIR_FREE(str); } =20 static const vshCmdInfo info_qemu_monitor_event[] =3D { @@ -9917,15 +9890,15 @@ cmdLxcEnterNamespace(vshControl *ctl, const vshCmd = *cmd) g_autoptr(virshDomain) dom =3D NULL; bool ret =3D false; const vshCmdOpt *opt =3D NULL; - char **cmdargv =3D NULL; + g_autofree char **cmdargv =3D NULL; size_t ncmdargv =3D 0; pid_t pid; int nfdlist; int *fdlist; size_t i; bool setlabel =3D true; - virSecurityModelPtr secmodel =3D NULL; - virSecurityLabelPtr seclabel =3D NULL; + g_autofree virSecurityModelPtr secmodel =3D NULL; + g_autofree virSecurityLabelPtr seclabel =3D NULL; virshControl *priv =3D ctl->privData; =20 dom =3D virshCommandOptDomain(ctl, cmd, NULL); @@ -10007,9 +9980,6 @@ cmdLxcEnterNamespace(vshControl *ctl, const vshCmd *= cmd) ret =3D true; =20 cleanup: - VIR_FREE(seclabel); - VIR_FREE(secmodel); - VIR_FREE(cmdargv); return ret; } =20 @@ -10052,7 +10022,7 @@ cmdDumpXML(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; bool ret =3D true; - char *dump; + g_autofree char *dump =3D NULL; unsigned int flags =3D 0; bool inactive =3D vshCommandOptBool(cmd, "inactive"); bool secure =3D vshCommandOptBool(cmd, "security-info"); @@ -10074,7 +10044,6 @@ cmdDumpXML(vshControl *ctl, const vshCmd *cmd) dump =3D virDomainGetXMLDesc(dom, flags); if (dump !=3D NULL) { vshPrint(ctl, "%s", dump); - VIR_FREE(dump); } else { ret =3D false; } @@ -10115,8 +10084,8 @@ cmdDomXMLFromNative(vshControl *ctl, const vshCmd *= cmd) bool ret =3D true; const char *format =3D NULL; const char *configFile =3D NULL; - char *configData; - char *xmlData; + g_autofree char *configData =3D NULL; + g_autofree char *xmlData =3D NULL; unsigned int flags =3D 0; virshControl *priv =3D ctl->privData; =20 @@ -10130,12 +10099,10 @@ cmdDomXMLFromNative(vshControl *ctl, const vshCmd= *cmd) xmlData =3D virConnectDomainXMLFromNative(priv->conn, format, configDa= ta, flags); if (xmlData !=3D NULL) { vshPrint(ctl, "%s", xmlData); - VIR_FREE(xmlData); } else { ret =3D false; } =20 - VIR_FREE(configData); return ret; } =20 @@ -10172,8 +10139,8 @@ cmdDomXMLToNative(vshControl *ctl, const vshCmd *cm= d) bool ret =3D false; const char *format =3D NULL; const char *xmlFile =3D NULL; - char *configData =3D NULL; - char *xmlData =3D NULL; + g_autofree char *configData =3D NULL; + g_autofree char *xmlData =3D NULL; unsigned int flags =3D 0; virshControl *priv =3D ctl->privData; g_autoptr(virshDomain) dom =3D NULL; @@ -10211,8 +10178,6 @@ cmdDomXMLToNative(vshControl *ctl, const vshCmd *cm= d) } =20 cleanup: - VIR_FREE(xmlData); - VIR_FREE(configData); return ret; } =20 @@ -11615,7 +11580,7 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshDomain) dom =3D NULL; bool ret =3D false; int port =3D 0; - char *listen_addr =3D NULL; + g_autofree char *listen_addr =3D NULL; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -11658,7 +11623,6 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - VIR_FREE(listen_addr); return ret; } =20 @@ -11686,7 +11650,7 @@ cmdTTYConsole(vshControl *ctl, const vshCmd *cmd) g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; bool ret =3D false; - char *tty =3D NULL; + g_autofree char *tty =3D NULL; =20 if (virshDomainGetXML(ctl, cmd, 0, &xml, &ctxt) < 0) return false; @@ -11698,7 +11662,6 @@ cmdTTYConsole(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - VIR_FREE(tty); return ret; } =20 @@ -11947,7 +11910,7 @@ cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; const char *from =3D NULL; - char *buffer =3D NULL; + g_autofree char *buffer =3D NULL; bool ret =3D false; unsigned int flags =3D VIR_DOMAIN_AFFECT_CURRENT; bool current =3D vshCommandOptBool(cmd, "current"); @@ -11992,7 +11955,6 @@ cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - VIR_FREE(buffer); return ret; } =20 @@ -12042,7 +12004,7 @@ virshDomainDetachInterface(char *doc, g_autoptr(xmlXPathObject) obj =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr cur =3D NULL, matchNode =3D NULL; - char *detach_xml =3D NULL; + g_autofree char *detach_xml =3D NULL; char buf[64]; int diff_mac, ret =3D -1; size_t i; @@ -12077,9 +12039,8 @@ virshDomainDetachInterface(char *doc, while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE && virXMLNodeNameEqual(cur, "mac")) { - char *tmp_mac =3D virXMLPropString(cur, "address"); + g_autofree char *tmp_mac =3D virXMLPropString(cur, "addres= s"); diff_mac =3D virMacAddrCompare(tmp_mac, mac); - VIR_FREE(tmp_mac); if (!diff_mac) { if (matchNode) { /* this is the 2nd match, so it's ambiguous */ @@ -12112,7 +12073,6 @@ virshDomainDetachInterface(char *doc, ret =3D virDomainDetachDevice(dom, detach_xml); =20 cleanup: - VIR_FREE(detach_xml); return ret =3D=3D 0; } =20 @@ -12121,7 +12081,8 @@ static bool cmdDetachInterface(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; - char *doc_live =3D NULL, *doc_config =3D NULL; + g_autofree char *doc_live =3D NULL; + g_autofree char *doc_config =3D NULL; const char *mac =3D NULL, *type =3D NULL; int flags =3D 0; bool ret =3D false, affect_config, affect_live; @@ -12176,8 +12137,6 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *c= md) } else { vshPrintExtra(ctl, "%s", _("Interface detached successfully\n")); } - VIR_FREE(doc_live); - VIR_FREE(doc_config); return ret; } =20 @@ -12248,13 +12207,11 @@ virshFindDisk(const char *doc, =20 /* Check if the disk is CDROM or floppy disk */ if (virXMLNodeNameEqual(n, "disk")) { - char *device_value =3D virXMLPropString(n, "device"); + g_autofree char *device_value =3D virXMLPropString(n, "dev= ice"); =20 if (STREQ(device_value, "cdrom") || STREQ(device_value, "floppy")) is_supported =3D true; - - VIR_FREE(device_value); } =20 if (!is_supported) @@ -12264,7 +12221,7 @@ virshFindDisk(const char *doc, cur =3D obj->nodesetval->nodeTab[i]->children; while (cur !=3D NULL) { if (cur->type =3D=3D XML_ELEMENT_NODE) { - char *tmp =3D NULL; + g_autofree char *tmp =3D NULL; =20 if (virXMLNodeNameEqual(cur, "source")) { if ((tmp =3D virXMLPropString(cur, "file")) || @@ -12280,10 +12237,8 @@ virshFindDisk(const char *doc, ret =3D xmlCopyNode(obj->nodesetval->nodeTab[i], 1); /* drop backing store since they are not needed here */ virshDiskDropBackingStore(ret); - VIR_FREE(tmp); goto cleanup; } - VIR_FREE(tmp); } cur =3D cur->next; } @@ -12317,10 +12272,10 @@ virshUpdateDiskXML(xmlNodePtr disk_node, xmlNodePtr source =3D NULL; xmlNodePtr target_node =3D NULL; xmlNodePtr text_node =3D NULL; - char *device_type =3D NULL; + g_autofree char *device_type =3D NULL; char *ret =3D NULL; - char *startupPolicy =3D NULL; - char *source_path =3D NULL; + g_autofree char *startupPolicy =3D NULL; + g_autofree char *source_path =3D NULL; =20 if (!disk_node) return NULL; @@ -12436,9 +12391,6 @@ virshUpdateDiskXML(xmlNodePtr disk_node, } =20 cleanup: - VIR_FREE(device_type); - VIR_FREE(startupPolicy); - VIR_FREE(source_path); return ret; } =20 @@ -12478,10 +12430,10 @@ static const vshCmdOptDef opts_detach_disk[] =3D { static bool cmdDetachDisk(vshControl *ctl, const vshCmd *cmd) { - char *disk_xml =3D NULL; + g_autofree char *disk_xml =3D NULL; g_autoptr(virshDomain) dom =3D NULL; const char *target =3D NULL; - char *doc =3D NULL; + g_autofree char *doc =3D NULL; int ret; bool functionReturn =3D false; xmlNodePtr disk_node =3D NULL; @@ -12548,8 +12500,6 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd) =20 cleanup: xmlFreeNode(disk_node); - VIR_FREE(disk_xml); - VIR_FREE(doc); return functionReturn; } =20 @@ -13225,16 +13175,13 @@ virshEventJobCompletedPrint(virConnectPtr conn G_= GNUC_UNUSED, { g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; size_t i; - char *value; =20 virBufferAsprintf(&buf, _("event 'job-completed' for domain '%s':\n"), virDomainGetName(dom)); for (i =3D 0; i < nparams; i++) { - value =3D virTypedParameterToString(¶ms[i]); - if (value) { + g_autofree char *value =3D virTypedParameterToString(¶ms[i]); + if (value) virBufferAsprintf(&buf, "\t%s: %s\n", params[i].field, value); - VIR_FREE(value); - } } virshEventPrint(opaque, &buf); } @@ -13611,9 +13558,9 @@ cmdChangeMedia(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshDomain) dom =3D NULL; const char *source =3D NULL; const char *path =3D NULL; - char *doc =3D NULL; + g_autofree char *doc =3D NULL; xmlNodePtr disk_node =3D NULL; - char *disk_xml =3D NULL; + g_autofree char *disk_xml =3D NULL; bool ret =3D false; virshUpdateDiskXMLType update_type; const char *action =3D NULL; @@ -13705,9 +13652,7 @@ cmdChangeMedia(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - VIR_FREE(doc); xmlFreeNode(disk_node); - VIR_FREE(disk_xml); return ret; } =20 @@ -13789,7 +13734,7 @@ cmdDomFSFreeze(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshDomain) dom =3D NULL; int ret =3D -1; const vshCmdOpt *opt =3D NULL; - const char **mountpoints =3D NULL; + g_autofree const char **mountpoints =3D NULL; size_t nmountpoints =3D 0; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) @@ -13809,7 +13754,6 @@ cmdDomFSFreeze(vshControl *ctl, const vshCmd *cmd) vshPrintExtra(ctl, _("Froze %d filesystem(s)\n"), ret); =20 cleanup: - VIR_FREE(mountpoints); return ret >=3D 0; } =20 @@ -13838,7 +13782,7 @@ cmdDomFSThaw(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshDomain) dom =3D NULL; int ret =3D -1; const vshCmdOpt *opt =3D NULL; - const char **mountpoints =3D NULL; + g_autofree const char **mountpoints =3D NULL; size_t nmountpoints =3D 0; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) @@ -13858,7 +13802,6 @@ cmdDomFSThaw(vshControl *ctl, const vshCmd *cmd) vshPrintExtra(ctl, _("Thawed %d filesystem(s)\n"), ret); =20 cleanup: - VIR_FREE(mountpoints); return ret >=3D 0; } =20 @@ -14060,9 +14003,8 @@ cmdGuestInfo(vshControl *ctl, const vshCmd *cmd) goto cleanup; =20 for (i =3D 0; i < nparams; i++) { - char *str =3D vshGetTypedParamValue(ctl, ¶ms[i]); + g_autofree char *str =3D vshGetTypedParamValue(ctl, ¶ms[i]); vshPrint(ctl, "%-20s: %s\n", params[i].field, str); - VIR_FREE(str); } =20 ret =3D true; diff --git a/tools/virsh-host.c b/tools/virsh-host.c index df1fe49e09..a32af023ae 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -49,7 +49,7 @@ static const vshCmdInfo info_capabilities[] =3D { static bool cmdCapabilities(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED) { - char *caps; + g_autofree char *caps =3D NULL; virshControl *priv =3D ctl->privData; =20 if ((caps =3D virConnectGetCapabilities(priv->conn)) =3D=3D NULL) { @@ -57,7 +57,6 @@ cmdCapabilities(vshControl *ctl, const vshCmd *cmd G_GNUC= _UNUSED) return false; } vshPrint(ctl, "%s\n", caps); - VIR_FREE(caps); =20 return true; } @@ -99,7 +98,7 @@ static bool cmdDomCapabilities(vshControl *ctl, const vshCmd *cmd) { bool ret =3D false; - char *caps =3D NULL; + g_autofree char *caps =3D NULL; const char *virttype =3D NULL; const char *emulatorbin =3D NULL; const char *arch =3D NULL; @@ -123,7 +122,6 @@ cmdDomCapabilities(vshControl *ctl, const vshCmd *cmd) vshPrint(ctl, "%s\n", caps); ret =3D true; cleanup: - VIR_FREE(caps); return ret; } =20 @@ -159,14 +157,14 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd) bool ret =3D false; int cell =3D -1; unsigned long long memory =3D 0; - xmlNodePtr *nodes =3D NULL; + g_autofree xmlNodePtr *nodes =3D NULL; unsigned long nodes_cnt; - unsigned long *nodes_id =3D NULL; - unsigned long long *nodes_free =3D NULL; + g_autofree unsigned long *nodes_id =3D NULL; + g_autofree unsigned long long *nodes_free =3D NULL; bool all =3D vshCommandOptBool(cmd, "all"); bool cellno =3D vshCommandOptBool(cmd, "cellno"); size_t i; - char *cap_xml =3D NULL; + g_autofree char *cap_xml =3D NULL; g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; virshControl *priv =3D ctl->privData; @@ -202,13 +200,11 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd) =20 for (i =3D 0; i < nodes_cnt; i++) { unsigned long id; - char *val =3D virXMLPropString(nodes[i], "id"); + g_autofree char *val =3D virXMLPropString(nodes[i], "id"); if (virStrToLong_ulp(val, NULL, 10, &id)) { vshError(ctl, "%s", _("conversion from string failed")); - VIR_FREE(val); goto cleanup; } - VIR_FREE(val); nodes_id[i] =3D id; if (virNodeGetCellsFreeMemory(priv->conn, &(nodes_free[i]), id, 1) !=3D 1) { @@ -243,10 +239,6 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - VIR_FREE(nodes); - VIR_FREE(nodes_free); - VIR_FREE(nodes_id); - VIR_FREE(cap_xml); return ret; } =20 @@ -296,15 +288,15 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd) { bool ret =3D false; unsigned int npages; - unsigned int *pagesize =3D NULL; + g_autofree unsigned int *pagesize =3D NULL; unsigned long long bytes =3D 0; unsigned int kibibytes =3D 0; int cell; - unsigned long long *counts =3D NULL; + g_autofree unsigned long long *counts =3D NULL; size_t i, j; xmlNodePtr *nodes =3D NULL; int nodes_cnt; - char *cap_xml =3D NULL; + g_autofree char *cap_xml =3D NULL; g_autoptr(xmlDoc) doc =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; bool all =3D vshCommandOptBool(cmd, "all"); @@ -347,15 +339,12 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd) pagesize =3D g_new0(unsigned int, nodes_cnt); =20 for (i =3D 0; i < nodes_cnt; i++) { - char *val =3D virXMLPropString(nodes[i], "size"); + g_autofree char *val =3D virXMLPropString(nodes[i], "size"= ); =20 if (virStrToLong_uip(val, NULL, 10, &pagesize[i]) < 0) { vshError(ctl, _("unable to parse page size: %s"), val); - VIR_FREE(val); goto cleanup; } - - VIR_FREE(val); } =20 /* Here, if we've done the trick few lines above, @@ -387,14 +376,12 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd) nodes_cnt =3D virXPathNodeSet("/capabilities/host/topology/cells/c= ell", ctxt, &nodes); for (i =3D 0; i < nodes_cnt; i++) { - char *val =3D virXMLPropString(nodes[i], "id"); + g_autofree char *val =3D virXMLPropString(nodes[i], "id"); =20 if (virStrToLong_i(val, NULL, 10, &cell) < 0) { vshError(ctl, _("unable to parse numa node id: %s"), val); - VIR_FREE(val); goto cleanup; } - VIR_FREE(val); =20 if (virNodeGetFreePages(priv->conn, npages, pagesize, cell, 1, counts, 0) < 0) @@ -441,10 +428,7 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd) =20 ret =3D true; cleanup: - VIR_FREE(cap_xml); VIR_FREE(nodes); - VIR_FREE(counts); - VIR_FREE(pagesize); return ret; } =20 @@ -501,10 +485,10 @@ cmdAllocpages(vshControl *ctl, const vshCmd *cmd) unsigned int pageSizes[1]; unsigned long long pageCounts[1], tmp; unsigned int flags =3D 0; - char *cap_xml =3D NULL; + g_autofree char *cap_xml =3D NULL; g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; - xmlNodePtr *nodes =3D NULL; + g_autofree xmlNodePtr *nodes =3D NULL; virshControl *priv =3D ctl->privData; =20 VSH_EXCLUSIVE_OPTIONS_VAR(all, cellno); @@ -547,13 +531,11 @@ cmdAllocpages(vshControl *ctl, const vshCmd *cmd) =20 for (i =3D 0; i < nodes_cnt; i++) { unsigned long id; - char *val =3D virXMLPropString(nodes[i], "id"); + g_autofree char *val =3D virXMLPropString(nodes[i], "id"); if (virStrToLong_ulp(val, NULL, 10, &id)) { vshError(ctl, "%s", _("conversion from string failed")); - VIR_FREE(val); goto cleanup; } - VIR_FREE(val); =20 if (virNodeAllocPages(priv->conn, 1, pageSizes, pageCounts, id, 1, flags) < 0) @@ -567,8 +549,6 @@ cmdAllocpages(vshControl *ctl, const vshCmd *cmd) =20 ret =3D true; cleanup: - VIR_FREE(nodes); - VIR_FREE(cap_xml); return ret; } =20 @@ -599,7 +579,7 @@ cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd) { const char *type =3D NULL; int vcpus =3D -1; - char *caps =3D NULL; + g_autofree char *caps =3D NULL; g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; virshControl *priv =3D ctl->privData; @@ -625,7 +605,6 @@ cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - VIR_FREE(caps); return ret; } =20 @@ -691,7 +670,7 @@ static bool cmdNodeCpuMap(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED) { int cpu, cpunum; - unsigned char *cpumap =3D NULL; + g_autofree unsigned char *cpumap =3D NULL; unsigned int online; bool pretty =3D vshCommandOptBool(cmd, "pretty"); bool ret =3D false; @@ -708,12 +687,11 @@ cmdNodeCpuMap(vshControl *ctl, const vshCmd *cmd G_GN= UC_UNUSED) =20 vshPrint(ctl, "%-15s ", _("CPU map:")); if (pretty) { - char *str =3D virBitmapDataFormat(cpumap, VIR_CPU_MAPLEN(cpunum)); + g_autofree char *str =3D virBitmapDataFormat(cpumap, VIR_CPU_MAPLE= N(cpunum)); =20 if (!str) goto cleanup; vshPrint(ctl, "%s", str); - VIR_FREE(str); } else { for (cpu =3D 0; cpu < cpunum; cpu++) vshPrint(ctl, "%c", VIR_CPU_USED(cpumap, cpu) ? 'y' : '-'); @@ -723,7 +701,6 @@ cmdNodeCpuMap(vshControl *ctl, const vshCmd *cmd G_GNUC= _UNUSED) ret =3D true; =20 cleanup: - VIR_FREE(cpumap); return ret; } =20 @@ -788,7 +765,7 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd) size_t i, j; bool flag_percent =3D vshCommandOptBool(cmd, "percent"); int cpuNum =3D VIR_NODE_CPU_STATS_ALL_CPUS; - virNodeCPUStatsPtr params; + g_autofree virNodeCPUStatsPtr params =3D NULL; int nparams =3D 0; bool ret =3D false; unsigned long long cpu_stats[VIRSH_CPU_LAST] =3D { 0 }; @@ -871,7 +848,6 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - VIR_FREE(params); return ret; } =20 @@ -902,7 +878,7 @@ cmdNodeMemStats(vshControl *ctl, const vshCmd *cmd) int nparams =3D 0; size_t i; int cellNum =3D VIR_NODE_MEMORY_STATS_ALL_CELLS; - virNodeMemoryStatsPtr params =3D NULL; + g_autofree virNodeMemoryStatsPtr params =3D NULL; bool ret =3D false; virshControl *priv =3D ctl->privData; =20 @@ -935,7 +911,6 @@ cmdNodeMemStats(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - VIR_FREE(params); return ret; } =20 @@ -1023,7 +998,7 @@ static const vshCmdInfo info_sysinfo[] =3D { static bool cmdSysinfo(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED) { - char *sysinfo; + g_autofree char *sysinfo =3D NULL; virshControl *priv =3D ctl->privData; =20 sysinfo =3D virConnectGetSysinfo(priv->conn, 0); @@ -1033,7 +1008,6 @@ cmdSysinfo(vshControl *ctl, const vshCmd *cmd G_GNUC_= UNUSED) } =20 vshPrint(ctl, "%s", sysinfo); - VIR_FREE(sysinfo); =20 return true; } @@ -1054,7 +1028,7 @@ static const vshCmdInfo info_hostname[] =3D { static bool cmdHostname(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED) { - char *hostname; + g_autofree char *hostname =3D NULL; virshControl *priv =3D ctl->privData; =20 hostname =3D virConnectGetHostname(priv->conn); @@ -1064,7 +1038,6 @@ cmdHostname(vshControl *ctl, const vshCmd *cmd G_GNUC= _UNUSED) } =20 vshPrint(ctl, "%s\n", hostname); - VIR_FREE(hostname); =20 return true; } @@ -1085,7 +1058,7 @@ static const vshCmdInfo info_uri[] =3D { static bool cmdURI(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUSED) { - char *uri; + g_autofree char *uri =3D NULL; virshControl *priv =3D ctl->privData; =20 uri =3D virConnectGetURI(priv->conn); @@ -1095,7 +1068,6 @@ cmdURI(vshControl *ctl, const vshCmd *cmd G_GNUC_UNUS= ED) } =20 vshPrint(ctl, "%s\n", uri); - VIR_FREE(uri); =20 return true; } @@ -1114,11 +1086,11 @@ vshExtractCPUDefXMLs(vshControl *ctl, const char *xmlFile) { char **cpus =3D NULL; - char *buffer =3D NULL; - char *xmlStr =3D NULL; + g_autofree char *buffer =3D NULL; + g_autofree char *xmlStr =3D NULL; g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; - xmlNodePtr *nodes =3D NULL; + g_autofree xmlNodePtr *nodes =3D NULL; char *doc; size_t i; int n; @@ -1177,9 +1149,6 @@ vshExtractCPUDefXMLs(vshControl *ctl, } =20 cleanup: - VIR_FREE(buffer); - VIR_FREE(xmlStr); - VIR_FREE(nodes); return cpus; =20 error: @@ -1300,7 +1269,7 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd) { const char *from =3D NULL; bool ret =3D false; - char *result =3D NULL; + g_autofree char *result =3D NULL; g_auto(GStrv) list =3D NULL; unsigned int flags =3D 0; virshControl *priv =3D ctl->privData; @@ -1325,7 +1294,6 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd) ret =3D true; } =20 - VIR_FREE(result); return ret; } =20 @@ -1577,9 +1545,8 @@ cmdNodeMemoryTune(vshControl *ctl, const vshCmd *cmd) */ vshPrint(ctl, _("Shared memory:\n")); for (i =3D 0; i < nparams; i++) { - char *str =3D vshGetTypedParamValue(ctl, ¶ms[i]); + g_autofree char *str =3D vshGetTypedParamValue(ctl, ¶ms[i]= ); vshPrint(ctl, "\t%-15s %s\n", params[i].field, str); - VIR_FREE(str); } } else { if (virNodeSetMemoryParameters(priv->conn, params, nparams, flags)= !=3D 0) @@ -1766,7 +1733,7 @@ cmdHypervisorCPUBaseline(vshControl *ctl, const char *arch =3D NULL; const char *machine =3D NULL; bool ret =3D false; - char *result =3D NULL; + g_autofree char *result =3D NULL; char **list =3D NULL; unsigned int flags =3D 0; virshControl *priv =3D ctl->privData; @@ -1797,7 +1764,6 @@ cmdHypervisorCPUBaseline(vshControl *ctl, ret =3D true; } =20 - VIR_FREE(result); g_strfreev(list); return ret; } diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c index f88ec188f1..07d5f50be3 100644 --- a/tools/virsh-interface.c +++ b/tools/virsh-interface.c @@ -486,7 +486,7 @@ cmdInterfaceDumpXML(vshControl *ctl, const vshCmd *cmd) { virInterfacePtr iface; bool ret =3D true; - char *dump; + g_autofree char *dump =3D NULL; unsigned int flags =3D 0; bool inactive =3D vshCommandOptBool(cmd, "inactive"); =20 @@ -499,7 +499,6 @@ cmdInterfaceDumpXML(vshControl *ctl, const vshCmd *cmd) dump =3D virInterfaceGetXMLDesc(iface, flags); if (dump !=3D NULL) { vshPrint(ctl, "%s", dump); - VIR_FREE(dump); } else { ret =3D false; } @@ -533,7 +532,7 @@ cmdInterfaceDefine(vshControl *ctl, const vshCmd *cmd) virInterfacePtr iface; const char *from =3D NULL; bool ret =3D true; - char *buffer; + g_autofree char *buffer =3D NULL; virshControl *priv =3D ctl->privData; =20 if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) @@ -543,7 +542,6 @@ cmdInterfaceDefine(vshControl *ctl, const vshCmd *cmd) return false; =20 iface =3D virInterfaceDefineXML(priv->conn, buffer, 0); - VIR_FREE(buffer); =20 if (iface !=3D NULL) { vshPrintExtra(ctl, _("Interface %s defined from %s\n"), diff --git a/tools/virsh-network.c b/tools/virsh-network.c index d641606dde..0d61e20093 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -206,7 +206,7 @@ cmdNetworkCreate(vshControl *ctl, const vshCmd *cmd) virNetworkPtr network; const char *from =3D NULL; bool ret =3D true; - char *buffer; + g_autofree char *buffer =3D NULL; virshControl *priv =3D ctl->privData; =20 if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) @@ -216,7 +216,6 @@ cmdNetworkCreate(vshControl *ctl, const vshCmd *cmd) return false; =20 network =3D virNetworkCreateXML(priv->conn, buffer); - VIR_FREE(buffer); =20 if (network !=3D NULL) { vshPrintExtra(ctl, _("Network %s created from %s\n"), @@ -254,7 +253,7 @@ cmdNetworkDefine(vshControl *ctl, const vshCmd *cmd) virNetworkPtr network; const char *from =3D NULL; bool ret =3D true; - char *buffer; + g_autofree char *buffer =3D NULL; virshControl *priv =3D ctl->privData; =20 if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) @@ -264,7 +263,6 @@ cmdNetworkDefine(vshControl *ctl, const vshCmd *cmd) return false; =20 network =3D virNetworkDefineXML(priv->conn, buffer); - VIR_FREE(buffer); =20 if (network !=3D NULL) { vshPrintExtra(ctl, _("Network %s defined from %s\n"), @@ -343,7 +341,7 @@ cmdNetworkDumpXML(vshControl *ctl, const vshCmd *cmd) { virNetworkPtr network; bool ret =3D true; - char *dump; + g_autofree char *dump =3D NULL; unsigned int flags =3D 0; int inactive; =20 @@ -358,7 +356,6 @@ cmdNetworkDumpXML(vshControl *ctl, const vshCmd *cmd) =20 if (dump !=3D NULL) { vshPrint(ctl, "%s", dump); - VIR_FREE(dump); } else { ret =3D false; } @@ -964,7 +961,7 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd) const char *sectionStr =3D NULL; int command, section, parentIndex =3D -1; const char *xml =3D NULL; - char *xmlFromFile =3D NULL; + g_autofree char *xmlFromFile =3D NULL; bool config =3D vshCommandOptBool(cmd, "config"); bool live =3D vshCommandOptBool(cmd, "live"); unsigned int flags =3D VIR_NETWORK_UPDATE_AFFECT_CURRENT; @@ -1059,7 +1056,6 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd) cleanup: vshReportError(ctl); virNetworkFree(network); - VIR_FREE(xmlFromFile); return ret; } =20 @@ -1556,7 +1552,7 @@ cmdNetworkPortDumpXML(vshControl *ctl, const vshCmd *= cmd) virNetworkPtr network; virNetworkPortPtr port =3D NULL; bool ret =3D true; - char *dump; + g_autofree char *dump =3D NULL; unsigned int flags =3D 0; =20 if (!(network =3D virshCommandOptNetwork(ctl, cmd, NULL))) @@ -1569,7 +1565,6 @@ cmdNetworkPortDumpXML(vshControl *ctl, const vshCmd *= cmd) =20 if (dump !=3D NULL) { vshPrint(ctl, "%s", dump); - VIR_FREE(dump); } else { ret =3D false; } diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index c6c7d97d50..c4b1d556ca 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -58,7 +58,7 @@ cmdNodeDeviceCreate(vshControl *ctl, const vshCmd *cmd) virNodeDevicePtr dev =3D NULL; const char *from =3D NULL; bool ret =3D true; - char *buffer; + g_autofree char *buffer =3D NULL; virshControl *priv =3D ctl->privData; =20 if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) @@ -68,7 +68,6 @@ cmdNodeDeviceCreate(vshControl *ctl, const vshCmd *cmd) return false; =20 dev =3D virNodeDeviceCreateXML(priv->conn, buffer, 0); - VIR_FREE(buffer); =20 if (dev !=3D NULL) { vshPrintExtra(ctl, _("Node device %s created from %s\n"), @@ -293,7 +292,7 @@ virshNodeDeviceListCollect(vshControl *ctl, =20 /* filter the list if the list was acquired by fallback means */ for (i =3D 0; i < list->ndevices; i++) { - char **caps =3D NULL; + g_autofree char **caps =3D NULL; int ncaps =3D 0; bool match =3D false; size_t j, k; @@ -310,7 +309,6 @@ virshNodeDeviceListCollect(vshControl *ctl, =20 if ((ncaps =3D virNodeDeviceListCaps(device, caps, ncaps)) < 0) { vshError(ctl, "%s", _("Failed to get capability names of the d= evice")); - VIR_FREE(caps); goto cleanup; } =20 @@ -326,8 +324,6 @@ virshNodeDeviceListCollect(vshControl *ctl, } } =20 - VIR_FREE(caps); - if (!match) goto remove_entry; =20 @@ -586,7 +582,7 @@ static bool cmdNodeDeviceDumpXML(vshControl *ctl, const vshCmd *cmd) { virNodeDevicePtr device =3D NULL; - char *xml =3D NULL; + g_autofree char *xml =3D NULL; const char *device_value =3D NULL; bool ret =3D false; =20 @@ -605,7 +601,6 @@ cmdNodeDeviceDumpXML(vshControl *ctl, const vshCmd *cmd) =20 ret =3D true; cleanup: - VIR_FREE(xml); if (device) virNodeDeviceFree(device); return ret; @@ -1084,7 +1079,7 @@ cmdNodeDeviceDefine(vshControl *ctl, const vshCmd *cm= d G_GNUC_UNUSED) virNodeDevice *dev =3D NULL; const char *from =3D NULL; bool ret =3D true; - char *buffer; + g_autofree char *buffer =3D NULL; virshControl *priv =3D ctl->privData; =20 if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) @@ -1094,7 +1089,6 @@ cmdNodeDeviceDefine(vshControl *ctl, const vshCmd *cm= d G_GNUC_UNUSED) return false; =20 dev =3D virNodeDeviceDefineXML(priv->conn, buffer, 0); - VIR_FREE(buffer); =20 if (dev !=3D NULL) { vshPrintExtra(ctl, _("Node device '%s' defined from '%s'\n"), diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c index acb35e8aa1..f38f33798d 100644 --- a/tools/virsh-nwfilter.c +++ b/tools/virsh-nwfilter.c @@ -90,7 +90,7 @@ cmdNWFilterDefine(vshControl *ctl, const vshCmd *cmd) virNWFilterPtr nwfilter; const char *from =3D NULL; bool ret =3D true; - char *buffer; + g_autofree char *buffer =3D NULL; virshControl *priv =3D ctl->privData; =20 if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) @@ -100,7 +100,6 @@ cmdNWFilterDefine(vshControl *ctl, const vshCmd *cmd) return false; =20 nwfilter =3D virNWFilterDefineXML(priv->conn, buffer); - VIR_FREE(buffer); =20 if (nwfilter !=3D NULL) { vshPrintExtra(ctl, _("Network filter %s defined from %s\n"), @@ -185,7 +184,7 @@ cmdNWFilterDumpXML(vshControl *ctl, const vshCmd *cmd) { virNWFilterPtr nwfilter; bool ret =3D true; - char *dump; + g_autofree char *dump =3D NULL; =20 if (!(nwfilter =3D virshCommandOptNWFilter(ctl, cmd, NULL))) return false; @@ -193,7 +192,6 @@ cmdNWFilterDumpXML(vshControl *ctl, const vshCmd *cmd) dump =3D virNWFilterGetXMLDesc(nwfilter, 0); if (dump !=3D NULL) { vshPrint(ctl, "%s", dump); - VIR_FREE(dump); } else { ret =3D false; } @@ -600,7 +598,7 @@ cmdNWFilterBindingDumpXML(vshControl *ctl, const vshCmd= *cmd) { virNWFilterBindingPtr binding; bool ret =3D true; - char *dump; + g_autofree char *dump =3D NULL; =20 if (!(binding =3D virshCommandOptNWFilterBinding(ctl, cmd, NULL))) return false; @@ -608,7 +606,6 @@ cmdNWFilterBindingDumpXML(vshControl *ctl, const vshCmd= *cmd) dump =3D virNWFilterBindingGetXMLDesc(binding, 0); if (dump !=3D NULL) { vshPrint(ctl, "%s", dump); - VIR_FREE(dump); } else { ret =3D false; } diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index 03987770f6..f0ee95bdf8 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -270,7 +270,7 @@ cmdPoolCreate(vshControl *ctl, const vshCmd *cmd) virStoragePoolPtr pool; const char *from =3D NULL; bool ret =3D true; - char *buffer; + g_autofree char *buffer =3D NULL; bool build; bool overwrite; bool no_overwrite; @@ -298,7 +298,6 @@ cmdPoolCreate(vshControl *ctl, const vshCmd *cmd) return false; =20 pool =3D virStoragePoolCreateXML(priv->conn, buffer, flags); - VIR_FREE(buffer); =20 if (pool !=3D NULL) { vshPrintExtra(ctl, _("Pool %s created from %s\n"), @@ -464,7 +463,7 @@ cmdPoolCreateAs(vshControl *ctl, const vshCmd *cmd) { virStoragePoolPtr pool; const char *name; - char *xml; + g_autofree char *xml =3D NULL; bool printXML =3D vshCommandOptBool(cmd, "print-xml"); bool build; bool overwrite; @@ -491,10 +490,8 @@ cmdPoolCreateAs(vshControl *ctl, const vshCmd *cmd) =20 if (printXML) { vshPrint(ctl, "%s", xml); - VIR_FREE(xml); } else { pool =3D virStoragePoolCreateXML(priv->conn, xml, flags); - VIR_FREE(xml); =20 if (pool !=3D NULL) { vshPrintExtra(ctl, _("Pool %s created\n"), name); @@ -533,7 +530,7 @@ cmdPoolDefine(vshControl *ctl, const vshCmd *cmd) virStoragePoolPtr pool; const char *from =3D NULL; bool ret =3D true; - char *buffer; + g_autofree char *buffer =3D NULL; virshControl *priv =3D ctl->privData; =20 if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) @@ -543,7 +540,6 @@ cmdPoolDefine(vshControl *ctl, const vshCmd *cmd) return false; =20 pool =3D virStoragePoolDefineXML(priv->conn, buffer, 0); - VIR_FREE(buffer); =20 if (pool !=3D NULL) { vshPrintExtra(ctl, _("Pool %s defined from %s\n"), @@ -574,7 +570,7 @@ cmdPoolDefineAs(vshControl *ctl, const vshCmd *cmd) { virStoragePoolPtr pool; const char *name; - char *xml; + g_autofree char *xml =3D NULL; bool printXML =3D vshCommandOptBool(cmd, "print-xml"); virshControl *priv =3D ctl->privData; =20 @@ -583,10 +579,8 @@ cmdPoolDefineAs(vshControl *ctl, const vshCmd *cmd) =20 if (printXML) { vshPrint(ctl, "%s", xml); - VIR_FREE(xml); } else { pool =3D virStoragePoolDefineXML(priv->conn, xml, 0); - VIR_FREE(xml); =20 if (pool !=3D NULL) { vshPrintExtra(ctl, _("Pool %s defined\n"), name); @@ -799,7 +793,7 @@ cmdPoolDumpXML(vshControl *ctl, const vshCmd *cmd) bool ret =3D true; bool inactive =3D vshCommandOptBool(cmd, "inactive"); unsigned int flags =3D 0; - char *dump; + g_autofree char *dump =3D NULL; =20 if (inactive) flags |=3D VIR_STORAGE_XML_INACTIVE; @@ -810,7 +804,6 @@ cmdPoolDumpXML(vshControl *ctl, const vshCmd *cmd) dump =3D virStoragePoolGetXMLDesc(pool, flags); if (dump !=3D NULL) { vshPrint(ctl, "%s", dump); - VIR_FREE(dump); } else { ret =3D false; } @@ -1442,8 +1435,8 @@ static bool cmdPoolDiscoverSourcesAs(vshControl * ctl, const vshCmd * cmd G_GNUC_UNUSE= D) { const char *type =3D NULL, *host =3D NULL; - char *srcSpec =3D NULL; - char *srcList; + g_autofree char *srcSpec =3D NULL; + g_autofree char *srcList =3D NULL; const char *initiator =3D NULL; virshControl *priv =3D ctl->privData; =20 @@ -1479,13 +1472,11 @@ cmdPoolDiscoverSourcesAs(vshControl * ctl, const vs= hCmd * cmd G_GNUC_UNUSED) } =20 srcList =3D virConnectFindStoragePoolSources(priv->conn, type, srcSpec= , 0); - VIR_FREE(srcSpec); if (srcList =3D=3D NULL) { vshError(ctl, _("Failed to find any %s pool sources"), type); return false; } vshPrint(ctl, "%s", srcList); - VIR_FREE(srcList); =20 return true; } @@ -1832,7 +1823,7 @@ cmdPoolEdit(vshControl *ctl, const vshCmd *cmd) virStoragePoolPtr pool =3D NULL; virStoragePoolPtr pool_edited =3D NULL; unsigned int flags =3D VIR_STORAGE_XML_INACTIVE; - char *tmp_desc =3D NULL; + g_autofree char *tmp_desc =3D NULL; virshControl *priv =3D ctl->privData; =20 pool =3D virshCommandOptPool(ctl, cmd, "pool", NULL); @@ -1847,8 +1838,6 @@ cmdPoolEdit(vshControl *ctl, const vshCmd *cmd) } else { goto cleanup; } - } else { - VIR_FREE(tmp_desc); } =20 #define EDIT_GET_XML virStoragePoolGetXMLDesc(pool, flags) diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c index 4f433fae9c..dde0d26398 100644 --- a/tools/virsh-secret.c +++ b/tools/virsh-secret.c @@ -80,7 +80,7 @@ static bool cmdSecretDefine(vshControl *ctl, const vshCmd *cmd) { const char *from =3D NULL; - char *buffer; + g_autofree char *buffer =3D NULL; virSecretPtr res; char uuid[VIR_UUID_STRING_BUFLEN]; bool ret =3D false; @@ -106,7 +106,6 @@ cmdSecretDefine(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - VIR_FREE(buffer); virshSecretFree(res); return ret; } @@ -139,7 +138,7 @@ cmdSecretDumpXML(vshControl *ctl, const vshCmd *cmd) { virSecretPtr secret; bool ret =3D false; - char *xml; + g_autofree char *xml =3D NULL; =20 secret =3D virshCommandOptSecret(ctl, cmd, NULL); if (secret =3D=3D NULL) @@ -149,7 +148,6 @@ cmdSecretDumpXML(vshControl *ctl, const vshCmd *cmd) if (xml =3D=3D NULL) goto cleanup; vshPrint(ctl, "%s", xml); - VIR_FREE(xml); ret =3D true; =20 cleanup: diff --git a/tools/virsh-util.c b/tools/virsh-util.c index 97b8f4d5c3..19cd0bcb99 100644 --- a/tools/virsh-util.c +++ b/tools/virsh-util.c @@ -304,7 +304,7 @@ virshDomainGetXMLFromDom(vshControl *ctl, xmlDocPtr *xml, xmlXPathContextPtr *ctxt) { - char *desc =3D NULL; + g_autofree char *desc =3D NULL; =20 if (!(desc =3D virDomainGetXMLDesc(dom, flags))) { vshError(ctl, _("Failed to get domain description xml")); @@ -312,7 +312,6 @@ virshDomainGetXMLFromDom(vshControl *ctl, } =20 *xml =3D virXMLParseStringCtxt(desc, _("(domain_definition)"), ctxt); - VIR_FREE(desc); =20 if (!(*xml)) { vshError(ctl, _("Failed to parse domain description xml")); diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index af93998d57..b4dfcc2f7a 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -233,7 +233,7 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd) { virStoragePoolPtr pool; virStorageVolPtr vol =3D NULL; - char *xml =3D NULL; + g_autofree char *xml =3D NULL; bool printXML =3D vshCommandOptBool(cmd, "print-xml"); const char *name, *capacityStr =3D NULL, *allocationStr =3D NULL, *for= mat =3D NULL; const char *snapshotStrVol =3D NULL, *snapshotStrFormat =3D NULL; @@ -290,7 +290,7 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd) /* Convert the snapshot parameters into backingStore XML */ if (snapshotStrVol) { virStorageVolPtr snapVol; - char *snapshotStrVolPath; + g_autofree char *snapshotStrVolPath =3D NULL; /* Lookup snapshot backing volume. Try the backing-vol * parameter as a name */ vshDebug(ctl, VSH_ERR_DEBUG, @@ -347,7 +347,6 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd) virBufferAddLit(&buf, "\n"); =20 /* Cleanup snapshot allocations */ - VIR_FREE(snapshotStrVolPath); virStorageVolFree(snapVol); } =20 @@ -372,7 +371,6 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd) if (vol) virStorageVolFree(vol); virStoragePoolFree(pool); - VIR_FREE(xml); return ret; } =20 @@ -407,7 +405,7 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd) const char *from =3D NULL; bool ret =3D false; unsigned int flags =3D 0; - char *buffer =3D NULL; + g_autofree char *buffer =3D NULL; =20 if (vshCommandOptBool(cmd, "prealloc-metadata")) flags |=3D VIR_STORAGE_VOL_CREATE_PREALLOC_METADATA; @@ -433,7 +431,6 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd) } =20 cleanup: - VIR_FREE(buffer); virStoragePoolFree(pool); return ret; } @@ -477,7 +474,7 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd) virStorageVolPtr newvol =3D NULL, inputvol =3D NULL; const char *from =3D NULL; bool ret =3D false; - char *buffer =3D NULL; + g_autofree char *buffer =3D NULL; unsigned int flags =3D 0; =20 if (!(pool =3D virshCommandOptPool(ctl, cmd, "pool", NULL))) @@ -512,7 +509,6 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd) =20 ret =3D true; cleanup: - VIR_FREE(buffer); if (pool) virStoragePoolFree(pool); if (inputvol) @@ -585,7 +581,7 @@ cmdVolClone(vshControl *ctl, const vshCmd *cmd) virStoragePoolPtr origpool =3D NULL; virStorageVolPtr origvol =3D NULL, newvol =3D NULL; const char *name =3D NULL; - char *origxml =3D NULL; + g_autofree char *origxml =3D NULL; xmlChar *newxml =3D NULL; bool ret =3D false; unsigned int flags =3D 0; @@ -632,7 +628,6 @@ cmdVolClone(vshControl *ctl, const vshCmd *cmd) ret =3D true; =20 cleanup: - VIR_FREE(origxml); xmlFree(newxml); if (origvol) virStorageVolFree(origvol); @@ -1680,7 +1675,7 @@ static bool cmdVolPath(vshControl *ctl, const vshCmd *cmd) { virStorageVolPtr vol; - char * StorageVolPath; + g_autofree char *StorageVolPath =3D NULL; =20 if (!(vol =3D virshCommandOptVol(ctl, cmd, "vol", "pool", NULL))) return false; @@ -1691,7 +1686,6 @@ cmdVolPath(vshControl *ctl, const vshCmd *cmd) } =20 vshPrint(ctl, "%s\n", StorageVolPath); - VIR_FREE(StorageVolPath); virStorageVolFree(vol); return true; } diff --git a/tools/virsh.c b/tools/virsh.c index fc27cb529e..ce5fd247dd 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -81,7 +81,7 @@ virshCatchDisconnect(virConnectPtr conn, vshControl *ctl =3D opaque; const char *str =3D "unknown reason"; virErrorPtr error; - char *uri; + g_autofree char *uri =3D NULL; =20 virErrorPreserveLast(&error); uri =3D virConnectGetURI(conn); @@ -101,7 +101,6 @@ virshCatchDisconnect(virConnectPtr conn, break; } vshError(ctl, _(str), NULLSTR(uri)); - VIR_FREE(uri); =20 virErrorRestore(&error); disconnected++; --=20 2.31.1 From nobody Sun May 5 17:07:13 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=1628757591; cv=none; d=zohomail.com; s=zohoarc; b=QOV61onKgt/YEWFsG/Bayky03BQKs0yx6qK3QgzAVGOr5QbA9RBGWrIRlhhq60/A3+uKvX8vAUhNQy37TqoNf9wp+btZH0dvYC99y75B/dx7tUdc/HpcmiAb6oqpdG2PrgcAWikBY4IEFuhqgz1HHkMO8RIyGaR4lZcyN/Hwhgg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628757591; 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=ueDC9W+oWgTgPfYaAUKsbzWOATEf5jeGMu9Jg7/k12E=; b=Bb2x4NzYbA5gxvNsLiHJ6QawyeytZ87wVcBro1UpI34EiH/MrzVSVboVTiFvyGF0hAyCsxc9hqsEccc8bUueI50SFMbTNvL4ZM4b5YvpnivV6zbZOCV4OwUKeuewERDNB8dRjMwIVcHki55ltcGCm0b42xgaGCKNeQoLHqRDcC8= 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) 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 1628757591937264.39508681476923; Thu, 12 Aug 2021 01:39:51 -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-227-jN6DiF5UPSiALOuwq1Musg-1; Thu, 12 Aug 2021 04:39:48 -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 98AA4190A7A1; Thu, 12 Aug 2021 08:39: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 58222295E5; Thu, 12 Aug 2021 08:39: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 283BB181A3ED; Thu, 12 Aug 2021 08:39:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17C8XIFZ003735 for ; Thu, 12 Aug 2021 04:33:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 54BE710016FF; Thu, 12 Aug 2021 08:33:18 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id A942B10013C1 for ; Thu, 12 Aug 2021 08:33:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628757590; 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=ueDC9W+oWgTgPfYaAUKsbzWOATEf5jeGMu9Jg7/k12E=; b=B/Atqty41Pkf5yJufCUl4FPWawscDDQhwTiT1IRPA+UGBeHWaw4U0Hg7gGUhOaUb2zb62x 6F4moiZcd57orAJfIUp7zqpqs8IxhyCYlT8vLXb9JLtWSZuwapFOTVuJ2lvJ9ZnaaDO3kR Gd1caDlDCj/4/6A/IyALr23A/1zJ6ws= X-MC-Unique: jN6DiF5UPSiALOuwq1Musg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 12/12] tools: virsh: remove redundant labels Date: Thu, 12 Aug 2021 10:32:50 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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) X-ZM-MESSAGEID: 1628757592924100001 Signed-off-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- tools/virsh-completer-domain.c | 30 +- tools/virsh-domain-monitor.c | 128 +++---- tools/virsh-domain.c | 634 ++++++++++++--------------------- tools/virsh-host.c | 87 ++--- tools/virsh-nodedev.c | 7 +- tools/virsh-volume.c | 5 +- tools/vsh.c | 11 +- 7 files changed, 317 insertions(+), 585 deletions(-) diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index 471f9974a1..c86d8e8156 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -447,7 +447,6 @@ virshDomainIOThreadIdCompleter(vshControl *ctl, g_autofree virDomainIOThreadInfoPtr *info =3D NULL; size_t i; int rc; - char **ret =3D NULL; g_auto(GStrv) tmp =3D NULL; =20 virCheckFlags(0, NULL); @@ -456,7 +455,7 @@ virshDomainIOThreadIdCompleter(vshControl *ctl, return NULL; =20 if ((rc =3D virDomainGetIOThreadInfo(dom, &info, flags)) < 0) - goto cleanup; + return NULL; =20 niothreads =3D rc; =20 @@ -465,10 +464,7 @@ virshDomainIOThreadIdCompleter(vshControl *ctl, for (i =3D 0; i < niothreads; i++) tmp[i] =3D g_strdup_printf("%u", info[i]->iothread_id); =20 - ret =3D g_steal_pointer(&tmp); - - cleanup: - return ret; + return g_steal_pointer(&tmp); } =20 =20 @@ -482,7 +478,6 @@ virshDomainVcpuCompleter(vshControl *ctl, g_autoptr(xmlXPathContext) ctxt =3D NULL; int nvcpus =3D 0; unsigned int id; - char **ret =3D NULL; g_auto(GStrv) tmp =3D NULL; =20 virCheckFlags(0, NULL); @@ -492,21 +487,18 @@ virshDomainVcpuCompleter(vshControl *ctl, =20 if (virshDomainGetXMLFromDom(ctl, dom, VIR_DOMAIN_XML_INACTIVE, &xml, &ctxt) < 0) - goto cleanup; + return NULL; =20 /* Query the max rather than the current vcpu count */ if (virXPathInt("string(/domain/vcpu)", ctxt, &nvcpus) < 0) - goto cleanup; + return NULL; =20 tmp =3D g_new0(char *, nvcpus + 1); =20 for (id =3D 0; id < nvcpus; id++) tmp[id] =3D g_strdup_printf("%u", id); =20 - ret =3D g_steal_pointer(&tmp); - - cleanup: - return ret; + return g_steal_pointer(&tmp); } =20 =20 @@ -522,7 +514,6 @@ virshDomainVcpulistCompleter(vshControl *ctl, unsigned int id; g_auto(GStrv) vcpulist =3D NULL; const char *vcpuid =3D NULL; - char **ret =3D NULL; =20 virCheckFlags(0, NULL); =20 @@ -530,25 +521,22 @@ virshDomainVcpulistCompleter(vshControl *ctl, return NULL; =20 if (vshCommandOptStringQuiet(ctl, cmd, "vcpulist", &vcpuid) < 0) - goto cleanup; + return NULL; =20 if (virshDomainGetXMLFromDom(ctl, dom, VIR_DOMAIN_XML_INACTIVE, &xml, &ctxt) < 0) - goto cleanup; + return NULL; =20 /* Query the max rather than the current vcpu count */ if (virXPathInt("string(/domain/vcpu)", ctxt, &nvcpus) < 0) - goto cleanup; + return NULL; =20 vcpulist =3D g_new0(char *, nvcpus + 1); =20 for (id =3D 0; id < nvcpus; id++) vcpulist[id] =3D g_strdup_printf("%u", id); =20 - ret =3D virshCommaStringListComplete(vcpuid, (const char **)vcpulist); - - cleanup: - return ret; + return virshCommaStringListComplete(vcpuid, (const char **)vcpulist); } =20 =20 diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index 49f632f11b..d5e9ad3bce 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -81,7 +81,7 @@ virshGetDomainDescription(vshControl *ctl, virDomainPtr d= om, bool title, =20 /* fall back to xml */ if (virshDomainGetXMLFromDom(ctl, dom, flags, &doc, &ctxt) < 0) - goto cleanup; + return NULL; =20 if (title) desc =3D virXPathString("string(./title[1])", ctxt); @@ -91,8 +91,6 @@ virshGetDomainDescription(vshControl *ctl, virDomainPtr d= om, bool title, if (!desc) desc =3D g_strdup(""); =20 - cleanup: - return desc; } =20 @@ -299,7 +297,6 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd) virDomainMemoryStatStruct stats[VIR_DOMAIN_MEMORY_STAT_NR]; unsigned int nr_stats; size_t i; - bool ret =3D false; int rv =3D 0; int period =3D -1; bool config =3D vshCommandOptBool(cmd, "config"); @@ -326,26 +323,25 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd) * This is not really an unsigned long, but it */ if ((rv =3D vshCommandOptInt(ctl, cmd, "period", &period)) < 0) - goto cleanup; + return false; if (rv > 0) { if (period < 0) { vshError(ctl, _("Invalid collection period value '%d'"), perio= d); - goto cleanup; + return false; } =20 if (virDomainSetMemoryStatsPeriod(dom, period, flags) < 0) { vshError(ctl, "%s", _("Unable to change balloon collection period.")); - } else { - ret =3D true; + return false; } - goto cleanup; + return true; } =20 nr_stats =3D virDomainMemoryStats(dom, stats, VIR_DOMAIN_MEMORY_STAT_N= R, 0); if (nr_stats =3D=3D -1) { vshError(ctl, _("Failed to get memory statistics for domain %s"), = name); - goto cleanup; + return false; } =20 for (i =3D 0; i < nr_stats; i++) { @@ -377,9 +373,7 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd) vshPrint(ctl, "hugetlb_pgfail %llu\n", stats[i].val); } =20 - ret =3D true; - cleanup: - return ret; + return true; } =20 /* @@ -590,7 +584,6 @@ static const vshCmdOptDef opts_domblklist[] =3D { static bool cmdDomblklist(vshControl *ctl, const vshCmd *cmd) { - bool ret =3D false; unsigned int flags =3D 0; g_autoptr(xmlDoc) xmldoc =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; @@ -606,11 +599,11 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) details =3D vshCommandOptBool(cmd, "details"); =20 if (virshDomainGetXML(ctl, cmd, flags, &xmldoc, &ctxt) < 0) - goto cleanup; + return false; =20 ndisks =3D virXPathNodeSet("./devices/disk", ctxt, &disks); if (ndisks < 0) - goto cleanup; + return false; =20 if (details) table =3D vshTableNew(_("Type"), _("Device"), _("Target"), _("Sour= ce"), NULL); @@ -618,7 +611,7 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) table =3D vshTableNew(_("Target"), _("Source"), NULL); =20 if (!table) - goto cleanup; + return false; =20 for (i =3D 0; i < ndisks; i++) { g_autofree char *type =3D NULL; @@ -633,14 +626,14 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) device =3D virXPathString("string(./@device)", ctxt); if (!type || !device) { vshPrint(ctl, "unable to query block list details"); - goto cleanup; + return false; } } =20 target =3D virXPathString("string(./target/@dev)", ctxt); if (!target) { vshError(ctl, "unable to query block list"); - goto cleanup; + return false; } =20 if (STREQ_NULLABLE(type, "nvme")) { @@ -652,7 +645,7 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) !(addrNode =3D virXPathNode("./source/address", ctxt)) || virPCIDeviceAddressParseXML(addrNode, &addr) < 0) { vshError(ctl, "Unable to query NVMe disk address"); - goto cleanup; + return false; } =20 source =3D g_strdup_printf("nvme://%04x:%02x:%02x.%d/%s", @@ -669,20 +662,17 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd) if (details) { if (vshTableRowAppend(table, type, device, target, NULLSTR_MINUS(source), NULL) < 0) - goto cleanup; + return false; } else { if (vshTableRowAppend(table, target, NULLSTR_MINUS(source), NULL) < 0) - goto cleanup; + return false; } } =20 vshTablePrintToStdout(table, ctl); =20 - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -706,7 +696,6 @@ static const vshCmdOptDef opts_domiflist[] =3D { static bool cmdDomiflist(vshControl *ctl, const vshCmd *cmd) { - bool ret =3D false; unsigned int flags =3D 0; g_autoptr(xmlDoc) xmldoc =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; @@ -719,16 +708,16 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd) flags |=3D VIR_DOMAIN_XML_INACTIVE; =20 if (virshDomainGetXML(ctl, cmd, flags, &xmldoc, &ctxt) < 0) - goto cleanup; + return false; =20 ninterfaces =3D virXPathNodeSet("./devices/interface", ctxt, &interfac= es); if (ninterfaces < 0) - goto cleanup; + return false; =20 table =3D vshTableNew(_("Interface"), _("Type"), _("Source"), _("Model"), _("MAC"), NULL); if (!table) - goto cleanup; + return false; =20 for (i =3D 0; i < ninterfaces; i++) { g_autofree char *type =3D NULL; @@ -757,15 +746,12 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd) model ? model : "-", mac ? mac : "-", NULL) < 0) - goto cleanup; + return false; } =20 vshTablePrintToStdout(table, ctl); =20 - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -810,7 +796,6 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd) g_autofree xmlNodePtr *interfaces =3D NULL; int ninterfaces; unsigned int flags =3D 0; - bool ret =3D false; =20 if (vshCommandOptStringReq(ctl, cmd, "interface", &iface) < 0) return false; @@ -819,7 +804,7 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd) flags =3D VIR_DOMAIN_XML_INACTIVE; =20 if (virshDomainGetXML(ctl, cmd, flags, &xml, &ctxt) < 0) - goto cleanup; + return false; =20 /* normalize the mac addr */ if (virMacAddrParse(iface, &macaddr) =3D=3D 0) @@ -831,7 +816,7 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd) =20 if ((ninterfaces =3D virXPathNodeSet(xpath, ctxt, &interfaces)) < 0) { vshError(ctl, _("Failed to extract interface information")); - goto cleanup; + return false; } =20 if (ninterfaces < 1) { @@ -840,10 +825,10 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd) else vshError(ctl, _("Interface (dev: %s) not found."), iface); =20 - goto cleanup; + return false; } else if (ninterfaces > 1) { vshError(ctl, _("multiple matching interfaces found")); - goto cleanup; + return false; } =20 ctxt->node =3D interfaces[0]; @@ -853,11 +838,7 @@ cmdDomIfGetLink(vshControl *ctl, const vshCmd *cmd) else vshPrint(ctl, "%s up", iface); =20 - ret =3D true; - - cleanup: - - return ret; + return true; } =20 /* @@ -882,16 +863,13 @@ static bool cmdDomControl(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; - bool ret =3D true; virDomainControlInfo info; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 - if (virDomainGetControlInfo(dom, &info, 0) < 0) { - ret =3D false; - goto cleanup; - } + if (virDomainGetControlInfo(dom, &info, 0) < 0) + return false; =20 if (info.state !=3D VIR_DOMAIN_CONTROL_OK && info.state !=3D VIR_DOMAIN_CONTROL_ERROR) { @@ -907,8 +885,7 @@ cmdDomControl(vshControl *ctl, const vshCmd *cmd) virshDomainControlStateToString(info.state)); } =20 - cleanup: - return ret; + return true; } =20 /* @@ -989,7 +966,6 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd) const char *field =3D NULL; int rc, nparams =3D 0; size_t i; - bool ret =3D false; bool human =3D vshCommandOptBool(cmd, "human"); /* human readable outp= ut */ =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) @@ -1000,7 +976,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd) API contract. */ if (vshCommandOptStringReq(ctl, cmd, "device", &device) < 0) - goto cleanup; + return false; =20 if (!device) device =3D ""; @@ -1014,7 +990,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd) if (rc < 0) { /* try older API if newer is not supported */ if (last_error->code !=3D VIR_ERR_NO_SUPPORT) - goto cleanup; + return false; =20 vshResetLibvirtError(); =20 @@ -1022,7 +998,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd) sizeof(stats)) =3D=3D -1) { vshError(ctl, _("Failed to get block stats %s %s"), name, device); - goto cleanup; + return false; } =20 /* human friendly output */ @@ -1040,7 +1016,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd) params =3D g_new0(virTypedParameter, nparams); if (virDomainBlockStatsFlags(dom, device, params, &nparams, 0) < 0= ) { vshError(ctl, _("Failed to get block stats for domain '%s' dev= ice '%s'"), name, device); - goto cleanup; + return false; } =20 /* set for prettier output */ @@ -1089,10 +1065,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd) } } =20 - ret =3D true; - - cleanup: - return ret; + return true; } #undef DOMBLKSTAT_LEGACY_PRINT =20 @@ -1126,17 +1099,16 @@ cmdDomIfstat(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshDomain) dom =3D NULL; const char *name =3D NULL, *device =3D NULL; virDomainInterfaceStatsStruct stats; - bool ret =3D false; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "interface", &device) < 0) - goto cleanup; + return false; =20 if (virDomainInterfaceStats(dom, device, &stats, sizeof(stats)) =3D=3D= -1) { vshError(ctl, _("Failed to get interface stats %s %s"), name, devi= ce); - goto cleanup; + return false; } =20 if (stats.rx_bytes >=3D 0) @@ -1163,10 +1135,7 @@ cmdDomIfstat(vshControl *ctl, const vshCmd *cmd) if (stats.tx_drop >=3D 0) vshPrint(ctl, "%s tx_drop %lld\n", device, stats.tx_drop); =20 - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -1398,17 +1367,14 @@ static bool cmdDomstate(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; - bool ret =3D true; bool showReason =3D vshCommandOptBool(cmd, "reason"); int state, reason; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 - if ((state =3D virshDomainState(ctl, dom, &reason)) < 0) { - ret =3D false; - goto cleanup; - } + if ((state =3D virshDomainState(ctl, dom, &reason)) < 0) + return false; =20 if (showReason) { vshPrint(ctl, "%s (%s)\n", @@ -1419,8 +1385,7 @@ cmdDomstate(vshControl *ctl, const vshCmd *cmd) virshDomainStateToString(state)); } =20 - cleanup: - return ret; + return true; } =20 /* @@ -1461,7 +1426,6 @@ static bool cmdDomTime(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; - bool ret =3D false; bool now =3D vshCommandOptBool(cmd, "now"); bool pretty =3D vshCommandOptBool(cmd, "pretty"); bool rtcSync =3D vshCommandOptBool(cmd, "sync"); @@ -1482,7 +1446,7 @@ cmdDomTime(vshControl *ctl, const vshCmd *cmd) =20 if (rv < 0) { /* invalid integer format */ - goto cleanup; + return false; } else if (rv > 0) { /* valid integer to set */ doSet =3D true; @@ -1491,18 +1455,18 @@ cmdDomTime(vshControl *ctl, const vshCmd *cmd) if (doSet || now || rtcSync) { if (now && ((seconds =3D time(NULL)) =3D=3D (time_t) -1)) { vshError(ctl, _("Unable to get current time")); - goto cleanup; + return false; } =20 if (rtcSync) flags |=3D VIR_DOMAIN_TIME_SYNC; =20 if (virDomainSetTime(dom, seconds, nseconds, flags) < 0) - goto cleanup; + return false; =20 } else { if (virDomainGetTime(dom, &seconds, &nseconds, flags) < 0) - goto cleanup; + return false; =20 if (pretty) { g_autoptr(GDateTime) then =3D NULL; @@ -1517,9 +1481,7 @@ cmdDomTime(vshControl *ctl, const vshCmd *cmd) } } =20 - ret =3D true; - cleanup: - return ret; + return true; } =20 /* diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 0b536b75dd..d06c24cc74 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -325,7 +325,6 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd) const char *from =3D NULL; char *buffer; int rv; - bool ret =3D false; unsigned int flags =3D VIR_DOMAIN_AFFECT_CURRENT; bool current =3D vshCommandOptBool(cmd, "current"); bool config =3D vshCommandOptBool(cmd, "config"); @@ -346,7 +345,7 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) - goto cleanup; + return false; =20 if (persistent && virDomainIsActive(dom) =3D=3D 1) @@ -354,7 +353,7 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd) =20 if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) { vshReportError(ctl); - goto cleanup; + return false; } =20 if (flags || current) @@ -366,14 +365,11 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd) =20 if (rv < 0) { vshError(ctl, _("Failed to attach device from %s"), from); - goto cleanup; + return false; } =20 vshPrintExtra(ctl, "%s", _("Device attached successfully\n")); - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -888,7 +884,6 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) virNetDevBandwidthRate inbound, outbound; virDomainNetType typ; int ret; - bool functionReturn =3D false; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; g_autofree char *xml =3D NULL; unsigned int flags =3D VIR_DOMAIN_AFFECT_CURRENT; @@ -917,35 +912,35 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) vshCommandOptStringReq(ctl, cmd, "alias", &alias) < 0 || vshCommandOptStringReq(ctl, cmd, "inbound", &inboundStr) < 0 || vshCommandOptStringReq(ctl, cmd, "outbound", &outboundStr) < 0) - goto cleanup; + return false; =20 /* check interface type */ if ((int)(typ =3D virDomainNetTypeFromString(type)) < 0) { vshError(ctl, _("No support for %s in command 'attach-interface'"), type); - goto cleanup; + return false; } =20 if (inboundStr) { memset(&inbound, 0, sizeof(inbound)); if (virshParseRateStr(ctl, inboundStr, &inbound) < 0) - goto cleanup; + return false; if (!inbound.average && !inbound.floor) { vshError(ctl, _("either inbound average or floor is mandatory"= )); - goto cleanup; + return false; } } if (outboundStr) { memset(&outbound, 0, sizeof(outbound)); if (virshParseRateStr(ctl, outboundStr, &outbound) < 0) - goto cleanup; + return false; if (outbound.average =3D=3D 0) { vshError(ctl, _("outbound average is mandatory")); - goto cleanup; + return false; } if (outbound.floor) { vshError(ctl, _("outbound floor is unsupported yet")); - goto cleanup; + return false; } } =20 @@ -975,7 +970,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) if (virshAddressParse(pciaddrstr, false, &addr) < 0) { vshError(ctl, _("cannot parse pci address '%s' for network int= erface"), source); - goto cleanup; + return false; } =20 virBufferAddLit(&buf, "\n"); @@ -998,7 +993,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) case VIR_DOMAIN_NET_TYPE_LAST: vshError(ctl, _("No support for %s in command 'attach-interface'"), type); - goto cleanup; + return false; break; } =20 @@ -1048,12 +1043,11 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *c= md) =20 if (vshCommandOptBool(cmd, "print-xml")) { vshPrint(ctl, "%s", xml); - functionReturn =3D true; - goto cleanup; + return true; } =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) - goto cleanup; + return false; =20 if (persistent && virDomainIsActive(dom) =3D=3D 1) @@ -1066,13 +1060,11 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *c= md) =20 if (ret !=3D 0) { vshError(ctl, "%s", _("Failed to attach interface")); - } else { - vshPrintExtra(ctl, "%s", _("Interface attached successfully\n")); - functionReturn =3D true; + return false; } =20 - cleanup: - return functionReturn; + vshPrintExtra(ctl, "%s", _("Interface attached successfully\n")); + return true; } =20 /* @@ -2690,11 +2682,11 @@ cmdBlockjob(vshControl *ctl, const vshCmd *cmd) VSH_EXCLUSIVE_OPTIONS_VAR(bytes, async); =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) - goto cleanup; + return false; =20 /* XXX Allow path to be optional to list info on all devices at once */ if (vshCommandOptStringReq(ctl, cmd, "path", &path) < 0) - goto cleanup; + return false; =20 if (bandwidth) ret =3D virshBlockJobSetSpeed(ctl, cmd, dom, path, bytes); @@ -2703,7 +2695,6 @@ cmdBlockjob(vshControl *ctl, const vshCmd *cmd) else ret =3D virshBlockJobInfo(ctl, dom, path, raw, bytes); =20 - cleanup: return ret; } =20 @@ -2987,7 +2978,6 @@ static bool cmdConsole(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; - bool ret =3D false; bool force =3D vshCommandOptBool(cmd, "force"); bool safe =3D vshCommandOptBool(cmd, "safe"); unsigned int flags =3D 0; @@ -2997,17 +2987,14 @@ cmdConsole(vshControl *ctl, const vshCmd *cmd) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "devname", &name) < 0) /* sc_proh= ibit_devname */ - goto cleanup; + return false; =20 if (force) flags |=3D VIR_DOMAIN_CONSOLE_FORCE; if (safe) flags |=3D VIR_DOMAIN_CONSOLE_SAFE; =20 - ret =3D cmdRunConsole(ctl, dom, name, flags); - - cleanup: - return ret; + return cmdRunConsole(ctl, dom, name, flags); } #endif /* WIN32 */ =20 @@ -3056,7 +3043,6 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) const char *element; const char *attr; bool config; - bool ret =3D false; unsigned int flags =3D 0; unsigned int xmlflags =3D 0; size_t i; @@ -3071,13 +3057,13 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) =20 if (vshCommandOptStringReq(ctl, cmd, "interface", &iface) < 0 || vshCommandOptStringReq(ctl, cmd, "state", &state) < 0) - goto cleanup; + return false; =20 config =3D vshCommandOptBool(cmd, "config"); =20 if (STRNEQ(state, "up") && STRNEQ(state, "down")) { vshError(ctl, _("invalid link state '%s'"), state); - goto cleanup; + return false; } =20 if (config) { @@ -3091,13 +3077,13 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) flags =3D VIR_DOMAIN_AFFECT_CONFIG; =20 if (virshDomainGetXMLFromDom(ctl, dom, xmlflags, &xml, &ctxt) < 0) - goto cleanup; + return false; =20 obj =3D xmlXPathEval(BAD_CAST "/domain/devices/interface", ctxt); if (obj =3D=3D NULL || obj->type !=3D XPATH_NODESET || obj->nodesetval =3D=3D NULL || obj->nodesetval->nodeNr =3D=3D 0) { vshError(ctl, _("Failed to extract interface information or no int= erfaces found")); - goto cleanup; + return false; } =20 if (virMacAddrParse(iface, &macaddr) =3D=3D 0) { @@ -3125,7 +3111,7 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) } =20 vshError(ctl, _("interface (%s: %s) not found"), element, iface); - goto cleanup; + return false; =20 hit: /* find and modify/add link state node */ @@ -3150,29 +3136,25 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd) BAD_CAST "link", NULL); if (!cur) - goto cleanup; + return false; =20 if (xmlNewProp(cur, BAD_CAST "state", BAD_CAST state) =3D=3D NULL) - goto cleanup; + return false; } =20 if (!(xml_buf =3D virXMLNodeToString(xml, obj->nodesetval->nodeTab[i])= )) { vshSaveLibvirtError(); vshError(ctl, _("Failed to create XML")); - goto cleanup; + return false; } =20 if (virDomainUpdateDeviceFlags(dom, xml_buf, flags) < 0) { vshError(ctl, _("Failed to update interface link state")); - goto cleanup; - } else { - vshPrintExtra(ctl, "%s", _("Device updated successfully\n")); - ret =3D true; + return false; } =20 - cleanup: - - return ret; + vshPrintExtra(ctl, "%s", _("Device updated successfully\n")); + return true; } =20 /* "domiftune" command @@ -3447,7 +3429,6 @@ cmdDomPMSuspend(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; const char *name; - bool ret =3D false; const char *target =3D NULL; int suspendTarget; unsigned long long duration =3D 0; @@ -3456,29 +3437,26 @@ cmdDomPMSuspend(vshControl *ctl, const vshCmd *cmd) return false; =20 if (vshCommandOptULongLong(ctl, cmd, "duration", &duration) < 0) - goto cleanup; + return false; =20 if (vshCommandOptStringReq(ctl, cmd, "target", &target) < 0) - goto cleanup; + return false; =20 if ((suspendTarget =3D virshNodeSuspendTargetTypeFromString(target)) <= 0) { vshError(ctl, "%s", _("Invalid target")); - goto cleanup; + return false; } =20 if (virDomainPMSuspendForDuration(dom, suspendTarget, duration, 0) < 0= ) { vshError(ctl, _("Domain '%s' could not be suspended"), virDomainGetName(dom)); - goto cleanup; + return false; } =20 vshPrintExtra(ctl, _("Domain '%s' successfully suspended"), virDomainGetName(dom)); =20 - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -3506,7 +3484,6 @@ cmdDomPMWakeup(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; const char *name; - bool ret =3D false; unsigned int flags =3D 0; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) @@ -3515,16 +3492,13 @@ cmdDomPMWakeup(vshControl *ctl, const vshCmd *cmd) if (virDomainPMWakeup(dom, flags) < 0) { vshError(ctl, _("Domain '%s' could not be woken up"), virDomainGetName(dom)); - goto cleanup; + return false; } =20 vshPrintExtra(ctl, _("Domain '%s' successfully woken up"), virDomainGetName(dom)); =20 - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -4036,7 +4010,6 @@ static bool cmdStart(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; - bool ret =3D false; #ifndef WIN32 bool console =3D vshCommandOptBool(cmd, "console"); #endif @@ -4051,11 +4024,11 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) =20 if (virDomainGetID(dom) !=3D (unsigned int)-1) { vshError(ctl, "%s", _("Domain is already active")); - goto cleanup; + return false; } =20 if (cmdStartGetFDs(ctl, cmd, &nfds, &fds) < 0) - goto cleanup; + return false; =20 if (vshCommandOptBool(cmd, "paused")) flags |=3D VIR_DOMAIN_START_PAUSED; @@ -4075,7 +4048,7 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) if (last_error->code !=3D VIR_ERR_NO_SUPPORT && last_error->code !=3D VIR_ERR_INVALID_ARG) { vshReportError(ctl); - goto cleanup; + return false; } vshResetLibvirtError(); rc =3D virDomainHasManagedSaveImage(dom, 0); @@ -4085,7 +4058,7 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) } else if (rc > 0) { if (virDomainManagedSaveRemove(dom, 0) < 0) { vshReportError(ctl); - goto cleanup; + return false; } } flags &=3D ~VIR_DOMAIN_START_FORCE_BOOT; @@ -4096,7 +4069,7 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) (flags ? virDomainCreateWithFlags(dom, flags) : virDomainCreate(dom))) < 0) { vshError(ctl, _("Failed to start domain '%s'"), virDomainGetName(d= om)); - goto cleanup; + return false; } =20 started: @@ -4104,13 +4077,10 @@ cmdStart(vshControl *ctl, const vshCmd *cmd) virDomainGetName(dom)); #ifndef WIN32 if (console && !cmdRunConsole(ctl, dom, NULL, 0)) - goto cleanup; + return false; #endif =20 - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -4485,7 +4455,6 @@ static bool cmdSaveImageDumpxml(vshControl *ctl, const vshCmd *cmd) { const char *file =3D NULL; - bool ret =3D false; unsigned int flags =3D 0; g_autofree char *xml =3D NULL; virshControl *priv =3D ctl->privData; @@ -4498,13 +4467,10 @@ cmdSaveImageDumpxml(vshControl *ctl, const vshCmd *= cmd) =20 xml =3D virDomainSaveImageGetXMLDesc(priv->conn, file, flags); if (!xml) - goto cleanup; + return false; =20 vshPrint(ctl, "%s", xml); - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -4542,7 +4508,6 @@ static bool cmdSaveImageDefine(vshControl *ctl, const vshCmd *cmd) { const char *file =3D NULL; - bool ret =3D false; const char *xmlfile =3D NULL; g_autofree char *xml =3D NULL; unsigned int flags =3D 0; @@ -4560,18 +4525,15 @@ cmdSaveImageDefine(vshControl *ctl, const vshCmd *c= md) return false; =20 if (virFileReadAll(xmlfile, VSH_MAX_XML_FILE, &xml) < 0) - goto cleanup; + return false; =20 if (virDomainSaveImageDefineXML(priv->conn, file, xml, flags) < 0) { vshError(ctl, _("Failed to update %s"), file); - goto cleanup; + return false; } =20 vshPrintExtra(ctl, _("State file %s updated.\n"), file); - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -4785,7 +4747,6 @@ cmdManagedSaveRemove(vshControl *ctl, const vshCmd *c= md) { g_autoptr(virshDomain) dom =3D NULL; const char *name; - bool ret =3D false; int hassave; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) @@ -4794,14 +4755,14 @@ cmdManagedSaveRemove(vshControl *ctl, const vshCmd = *cmd) hassave =3D virDomainHasManagedSaveImage(dom, 0); if (hassave < 0) { vshError(ctl, "%s", _("Failed to check for domain managed save ima= ge")); - goto cleanup; + return false; } =20 if (hassave) { if (virDomainManagedSaveRemove(dom, 0) < 0) { vshError(ctl, _("Failed to remove managed save image for domai= n '%s'"), name); - goto cleanup; + return false; } else vshPrintExtra(ctl, _("Removed managedsave image for domain '%s= '"), name); @@ -4810,10 +4771,7 @@ cmdManagedSaveRemove(vshControl *ctl, const vshCmd *= cmd) vshPrintExtra(ctl, _("Domain '%s' has no manage save image; remova= l skipped"), name); =20 - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -4859,7 +4817,7 @@ cmdManagedSaveEdit(vshControl *ctl, const vshCmd *cmd) =20 dom =3D virshCommandOptDomain(ctl, cmd, NULL); if (dom =3D=3D NULL) - goto cleanup; + return false; =20 #define EDIT_GET_XML virDomainManagedSaveGetXMLDesc(dom, getxml_flags) #define EDIT_NOT_CHANGED \ @@ -4906,7 +4864,6 @@ static const vshCmdOptDef opts_managed_save_dumpxml[]= =3D { static bool cmdManagedSaveDumpxml(vshControl *ctl, const vshCmd *cmd) { - bool ret =3D false; g_autoptr(virshDomain) dom =3D NULL; unsigned int flags =3D 0; g_autofree char *xml =3D NULL; @@ -4915,16 +4872,13 @@ cmdManagedSaveDumpxml(vshControl *ctl, const vshCmd= *cmd) flags |=3D VIR_DOMAIN_XML_SECURE; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) - goto cleanup; + return false; =20 if (!(xml =3D virDomainManagedSaveGetXMLDesc(dom, flags))) - goto cleanup; + return false; =20 vshPrint(ctl, "%s", xml); - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -4961,7 +4915,6 @@ static const vshCmdOptDef opts_managed_save_define[] = =3D { static bool cmdManagedSaveDefine(vshControl *ctl, const vshCmd *cmd) { - bool ret =3D false; g_autoptr(virshDomain) dom =3D NULL; const char *xmlfile =3D NULL; g_autofree char *xml =3D NULL; @@ -4981,20 +4934,17 @@ cmdManagedSaveDefine(vshControl *ctl, const vshCmd = *cmd) return false; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) - goto cleanup; + return false; =20 if (virDomainManagedSaveDefineXML(dom, xml, flags) < 0) { vshError(ctl, _("Failed to update %s XML configuration"), virDomainGetName(dom)); - goto cleanup; + return false; } =20 vshPrintExtra(ctl, _("Managed save state file of domain '%s' updated.\= n"), virDomainGetName(dom)); - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -5264,7 +5214,6 @@ static bool cmdRestore(vshControl *ctl, const vshCmd *cmd) { const char *from =3D NULL; - bool ret =3D false; unsigned int flags =3D 0; const char *xmlfile =3D NULL; g_autofree char *xml =3D NULL; @@ -5285,20 +5234,17 @@ cmdRestore(vshControl *ctl, const vshCmd *cmd) =20 if (xmlfile && virFileReadAll(xmlfile, VSH_MAX_XML_FILE, &xml) < 0) - goto cleanup; + return false; =20 if (((flags || xml) ? virDomainRestoreFlags(priv->conn, from, xml, flags) : virDomainRestore(priv->conn, from)) < 0) { vshError(ctl, _("Failed to restore domain from %s"), from); - goto cleanup; + return false; } =20 vshPrintExtra(ctl, _("Domain restored from %s\n"), from); - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -5451,7 +5397,7 @@ cmdDump(vshControl *ctl, const vshCmd *cmd) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "file", &to) < 0) - goto cleanup; + return false; =20 if (vshCommandOptBool(cmd, "verbose")) verbose =3D true; @@ -5460,18 +5406,18 @@ cmdDump(vshControl *ctl, const vshCmd *cmd) true, doDump, &data) < 0) - goto cleanup; + return false; =20 virshWatchJob(ctl, dom, verbose, eventLoop, &data.ret, 0, NULL, NULL, _("Dump")); =20 virThreadJoin(&workerThread); =20 - if (!data.ret) - vshPrintExtra(ctl, _("\nDomain '%s' dumped to %s\n"), name, to); + if (data.ret) + return false; =20 - cleanup: - return !data.ret; + vshPrintExtra(ctl, _("\nDomain '%s' dumped to %s\n"), name, to); + return true; } =20 static const vshCmdInfo info_screenshot[] =3D { @@ -5751,7 +5697,6 @@ cmdSetUserPassword(vshControl *ctl, const vshCmd *cmd) const char *password =3D NULL; const char *user =3D NULL; unsigned int flags =3D 0; - bool ret =3D false; =20 if (vshCommandOptBool(cmd, "encrypted")) flags =3D VIR_DOMAIN_PASSWORD_ENCRYPTED; @@ -5766,13 +5711,10 @@ cmdSetUserPassword(vshControl *ctl, const vshCmd *c= md) return false; =20 if (virDomainSetUserPassword(dom, user, password, flags) < 0) - goto cleanup; + return false; =20 vshPrintExtra(ctl, _("Password set successfully for %s in %s"), user, = name); - ret =3D true; - - cleanup: - return ret; + return true; } /* * "resume" command @@ -5839,7 +5781,6 @@ static bool cmdShutdown(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; - bool ret =3D false; const char *name; const char *mode =3D NULL; int flags =3D 0; @@ -5872,13 +5813,13 @@ cmdShutdown(vshControl *ctl, const vshCmd *cmd) vshError(ctl, _("Unknown mode %s value, expecting " "'acpi', 'agent', 'initctl', 'signal', " "or 'paravirt'"), mode); - goto cleanup; + return false; } tmp++; } =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) - goto cleanup; + return false; =20 if (flags) rv =3D virDomainShutdownFlags(dom, flags); @@ -5888,12 +5829,10 @@ cmdShutdown(vshControl *ctl, const vshCmd *cmd) vshPrintExtra(ctl, _("Domain '%s' is being shutdown\n"), name); } else { vshError(ctl, _("Failed to shutdown domain '%s'"), name); - goto cleanup; + return false; } =20 - ret =3D true; - cleanup: - return ret; + return true; } =20 /* @@ -5923,7 +5862,6 @@ static bool cmdReboot(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; - bool ret =3D false; const char *name; const char *mode =3D NULL; int flags =3D 0; @@ -5955,24 +5893,22 @@ cmdReboot(vshControl *ctl, const vshCmd *cmd) vshError(ctl, _("Unknown mode %s value, expecting " "'acpi', 'agent', 'initctl', 'signal' " "or 'paravirt'"), mode); - goto cleanup; + return false; } tmp++; } =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, &name))) - goto cleanup; + return false; =20 if (virDomainReboot(dom, flags) =3D=3D 0) { vshPrintExtra(ctl, _("Domain '%s' is being rebooted\n"), name); } else { vshError(ctl, _("Failed to reboot domain '%s'"), name); - goto cleanup; + return false; } =20 - ret =3D true; - cleanup: - return ret; + return true; } =20 /* @@ -6586,7 +6522,6 @@ static bool cmdVcpucount(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; - bool ret =3D false; bool maximum =3D vshCommandOptBool(cmd, "maximum"); bool active =3D vshCommandOptBool(cmd, "active"); bool config =3D vshCommandOptBool(cmd, "config"); @@ -6636,7 +6571,7 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd) VIR_DOMAIN_AFFECT_LIVE, true); =20 if (conf_max =3D=3D -2 || conf_cur =3D=3D -2 || live_max =3D=3D -2= || live_cur =3D=3D -2) - goto cleanup; + return false; =20 #define PRINT_COUNT(VAR, WHICH, STATE) if (VAR > 0) \ vshPrint(ctl, "%-12s %-12s %3d\n", WHICH, STATE, VAR) @@ -6650,15 +6585,12 @@ cmdVcpucount(vshControl *ctl, const vshCmd *cmd) int count =3D virshCPUCountCollect(ctl, dom, flags, false); =20 if (count < 0) - goto cleanup; + return false; =20 vshPrint(ctl, "%d\n", count); } =20 - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -6692,12 +6624,11 @@ virshVcpuinfoPrintAffinity(vshControl *ctl, { g_autofree char *str =3D NULL; size_t i; - int ret =3D -1; =20 vshPrint(ctl, "%-15s ", _("CPU Affinity:")); if (pretty) { if (!(str =3D virBitmapDataFormat(cpumap, VIR_CPU_MAPLEN(maxcpu)))) - goto cleanup; + return -1; vshPrint(ctl, _("%s (out of %d)"), str, maxcpu); } else { for (i =3D 0; i < maxcpu; i++) @@ -6705,10 +6636,7 @@ virshVcpuinfoPrintAffinity(vshControl *ctl, } vshPrint(ctl, "\n"); =20 - ret =3D 0; - - cleanup: - return ret; + return 0; } =20 =20 @@ -6732,11 +6660,11 @@ virshDomainGetVcpuBitmap(vshControl *ctl, flags |=3D VIR_DOMAIN_XML_INACTIVE; =20 if (virshDomainGetXMLFromDom(ctl, dom, flags, &xml, &ctxt) < 0) - goto cleanup; + return NULL; =20 if (virXPathUInt("string(/domain/vcpu)", ctxt, &maxvcpus) < 0) { vshError(ctl, "%s", _("Failed to retrieve maximum vcpu count")); - goto cleanup; + return NULL; } =20 ignore_value(virXPathUInt("string(/domain/vcpu/@current)", ctxt, &curv= cpus)); @@ -6751,7 +6679,7 @@ virshDomainGetVcpuBitmap(vshControl *ctl, for (i =3D 0; i < curvcpus; i++) ignore_value(virBitmapSetBit(ret, i)); =20 - goto cleanup; + return NULL; } =20 for (i =3D 0; i < nnodes; i++) { @@ -6770,10 +6698,9 @@ virshDomainGetVcpuBitmap(vshControl *ctl, if (virBitmapCountBits(ret) !=3D curvcpus) { vshError(ctl, "%s", _("Failed to retrieve vcpu state bitmap")); virBitmapFree(ret); - ret =3D NULL; + return NULL; } =20 - cleanup: return ret; } =20 @@ -6946,7 +6873,6 @@ virshVcpuPinQuery(vshControl *ctl, int cpumaplen; size_t i; int ncpus; - bool ret =3D false; g_autoptr(vshTable) table =3D NULL; =20 if ((ncpus =3D virshCPUCountCollect(ctl, dom, countFlags, true)) < 0) { @@ -6956,7 +6882,7 @@ virshVcpuPinQuery(vshControl *ctl, else vshError(ctl, "%s", _("cannot get vcpupin for transient do= main")); } - goto cleanup; + return false; } =20 if (got_vcpu && vcpu >=3D ncpus) { @@ -6970,7 +6896,7 @@ virshVcpuPinQuery(vshControl *ctl, vshError(ctl, _("vcpu %d is out of range of persistent cpu count %d= "), vcpu, ncpus); - goto cleanup; + return false; } =20 cpumaplen =3D VIR_CPU_MAPLEN(maxcpu); @@ -6979,7 +6905,7 @@ virshVcpuPinQuery(vshControl *ctl, cpumaplen, flags)) >=3D 0) { table =3D vshTableNew(_("VCPU"), _("CPU Affinity"), NULL); if (!table) - goto cleanup; + return false; =20 for (i =3D 0; i < ncpus; i++) { g_autofree char *pinInfo =3D NULL; @@ -6989,20 +6915,18 @@ virshVcpuPinQuery(vshControl *ctl, =20 if (!(pinInfo =3D virBitmapDataFormat(VIR_GET_CPUMAP(cpumap, c= pumaplen, i), cpumaplen))) - goto cleanup; + return false; =20 vcpuStr =3D g_strdup_printf("%zu", i); =20 if (vshTableRowAppend(table, vcpuStr, pinInfo, NULL) < 0) - goto cleanup; + return false; } =20 vshTablePrintToStdout(table, ctl); } =20 - ret =3D true; - cleanup: - return ret; + return true; } =20 =20 @@ -7089,25 +7013,22 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd) /* Query mode: show CPU affinity information then exit.*/ if (!cpulist) { ret =3D virshVcpuPinQuery(ctl, dom, vcpu, got_vcpu, maxcpu, flags); - goto cleanup; + return false; } =20 /* Pin mode: pinning specified vcpu to specified physical cpus */ if (!(cpumap =3D virshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu))) - goto cleanup; + return false; =20 /* use old API without any explicit flags */ if (flags =3D=3D VIR_DOMAIN_AFFECT_CURRENT && !current) { if (virDomainPinVcpu(dom, vcpu, cpumap, cpumaplen) !=3D 0) - goto cleanup; + return false; } else { if (virDomainPinVcpuFlags(dom, vcpu, cpumap, cpumaplen, flags) != =3D 0) - goto cleanup; + return false; } - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -7193,22 +7114,20 @@ cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd) ret =3D virshPrintPinInfo(ctl, cpumap, cpumaplen); vshPrint(ctl, "\n"); } - goto cleanup; + return false; } =20 /* Pin mode: pinning emulator threads to specified physical cpus */ if (!(cpumap =3D virshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu))) - goto cleanup; + return false; =20 if (flags =3D=3D -1) flags =3D VIR_DOMAIN_AFFECT_LIVE; =20 if (virDomainPinEmulator(dom, cpumap, cpumaplen, flags) !=3D 0) - goto cleanup; + return false; =20 - ret =3D true; - cleanup: - return ret; + return true; } =20 /* @@ -7254,7 +7173,6 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; unsigned int count =3D 0; - bool ret =3D false; bool maximum =3D vshCommandOptBool(cmd, "maximum"); bool config =3D vshCommandOptBool(cmd, "config"); bool live =3D vshCommandOptBool(cmd, "live"); @@ -7284,26 +7202,23 @@ cmdSetvcpus(vshControl *ctl, const vshCmd *cmd) return false; =20 if (vshCommandOptUInt(ctl, cmd, "count", &count) < 0) - goto cleanup; + return false; =20 if (count =3D=3D 0) { vshError(ctl, _("Can't set 0 processors for a VM")); - goto cleanup; + return false; } =20 /* none of the options were specified */ if (!current && flags =3D=3D 0) { if (virDomainSetVcpus(dom, count) !=3D 0) - goto cleanup; + return false; } else { if (virDomainSetVcpusFlags(dom, count, flags) < 0) - goto cleanup; + return false; } =20 - ret =3D true; - - cleanup: - return ret; + return true; } =20 =20 @@ -7438,7 +7353,6 @@ cmdSetvcpu(vshControl *ctl, const vshCmd *cmd) bool live =3D vshCommandOptBool(cmd, "live"); const char *vcpulist =3D NULL; int state =3D 0; - bool ret =3D false; unsigned int flags =3D VIR_DOMAIN_AFFECT_CURRENT; =20 VSH_EXCLUSIVE_OPTIONS_VAR(enable, disable); @@ -7466,12 +7380,9 @@ cmdSetvcpu(vshControl *ctl, const vshCmd *cmd) state =3D 1; =20 if (virDomainSetVcpu(dom, vcpulist, state, flags) < 0) - goto cleanup; + return false; =20 - ret =3D true; - - cleanup: - return ret; + return true; } =20 =20 @@ -7511,7 +7422,6 @@ cmdDomblkthreshold(vshControl *ctl, const vshCmd *cmd) unsigned long long threshold; const char *dev =3D NULL; g_autoptr(virshDomain) dom =3D NULL; - bool ret =3D false; =20 if (vshCommandOptStringReq(ctl, cmd, "dev", &dev)) return false; @@ -7524,12 +7434,9 @@ cmdDomblkthreshold(vshControl *ctl, const vshCmd *cm= d) return false; =20 if (virDomainSetBlockThreshold(dom, dev, threshold, 0) < 0) - goto cleanup; + return false; =20 - ret =3D true; - - cleanup: - return ret; + return true; } =20 =20 @@ -7661,7 +7568,6 @@ cmdIOThreadPin(vshControl *ctl, const vshCmd *cmd) bool current =3D vshCommandOptBool(cmd, "current"); unsigned int iothread_id =3D 0; int maxcpu; - bool ret =3D false; g_autofree unsigned char *cpumap =3D NULL; int cpumaplen; unsigned int flags =3D VIR_DOMAIN_AFFECT_CURRENT; @@ -7679,25 +7585,22 @@ cmdIOThreadPin(vshControl *ctl, const vshCmd *cmd) return false; =20 if (vshCommandOptUInt(ctl, cmd, "iothread", &iothread_id) < 0) - goto cleanup; + return false; =20 if (vshCommandOptStringReq(ctl, cmd, "cpulist", &cpulist) < 0) - goto cleanup; + return false; =20 if ((maxcpu =3D virshNodeGetCPUCount(priv->conn)) < 0) - goto cleanup; + return false; =20 if (!(cpumap =3D virshParseCPUList(ctl, &cpumaplen, cpulist, maxcpu))) - goto cleanup; + return false; =20 if (virDomainPinIOThread(dom, iothread_id, cpumap, cpumaplen, flags) !=3D 0) - goto cleanup; + return false; =20 - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -7731,7 +7634,6 @@ cmdIOThreadAdd(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; int iothread_id =3D 0; - bool ret =3D false; bool config =3D vshCommandOptBool(cmd, "config"); bool live =3D vshCommandOptBool(cmd, "live"); bool current =3D vshCommandOptBool(cmd, "current"); @@ -7749,19 +7651,16 @@ cmdIOThreadAdd(vshControl *ctl, const vshCmd *cmd) return false; =20 if (vshCommandOptInt(ctl, cmd, "id", &iothread_id) < 0) - goto cleanup; + return false; if (iothread_id <=3D 0) { vshError(ctl, _("Invalid IOThread id value: '%d'"), iothread_id); - goto cleanup; + return false; } =20 if (virDomainAddIOThread(dom, iothread_id, flags) < 0) - goto cleanup; + return false; =20 - ret =3D true; - - cleanup: - return ret; + return true; } =20 =20 @@ -7900,7 +7799,6 @@ cmdIOThreadDel(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; int iothread_id =3D 0; - bool ret =3D false; bool config =3D vshCommandOptBool(cmd, "config"); bool live =3D vshCommandOptBool(cmd, "live"); bool current =3D vshCommandOptBool(cmd, "current"); @@ -7918,19 +7816,16 @@ cmdIOThreadDel(vshControl *ctl, const vshCmd *cmd) return false; =20 if (vshCommandOptInt(ctl, cmd, "id", &iothread_id) < 0) - goto cleanup; + return false; if (iothread_id <=3D 0) { vshError(ctl, _("Invalid IOThread id value: '%d'"), iothread_id); - goto cleanup; + return false; } =20 if (virDomainDelIOThread(dom, iothread_id, flags) < 0) - goto cleanup; + return false; =20 - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -8159,7 +8054,6 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; const char *from =3D NULL; - bool ret =3D false; g_autofree char *buffer =3D NULL; #ifndef WIN32 bool console =3D vshCommandOptBool(cmd, "console"); @@ -8176,7 +8070,7 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd) return false; =20 if (cmdStartGetFDs(ctl, cmd, &nfds, &fds) < 0) - goto cleanup; + return false; =20 if (vshCommandOptBool(cmd, "paused")) flags |=3D VIR_DOMAIN_START_PAUSED; @@ -8192,7 +8086,7 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd) =20 if (!dom) { vshError(ctl, _("Failed to create domain from %s"), from); - goto cleanup; + return false; } =20 vshPrintExtra(ctl, _("Domain '%s' created from %s\n"), @@ -8201,10 +8095,7 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd) if (console) cmdRunConsole(ctl, dom, NULL, 0); #endif - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -8567,18 +8458,18 @@ cmdMetadata(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptStringReq(ctl, cmd, "uri", &uri) < 0 || vshCommandOptStringReq(ctl, cmd, "key", &key) < 0 || vshCommandOptStringReq(ctl, cmd, "set", &set) < 0) - goto cleanup; + return false; =20 if ((set || edit) && !key) { vshError(ctl, "%s", _("namespace key is required when modifying metadata")); - goto cleanup; + return false; } =20 if (set || rem) { if (virDomainSetMetadata(dom, VIR_DOMAIN_METADATA_ELEMENT, set, key, uri, flags)) - goto cleanup; + return false; =20 if (rem) vshPrintExtra(ctl, "%s\n", _("Metadata removed")); @@ -8605,7 +8496,7 @@ cmdMetadata(vshControl *ctl, const vshCmd *cmd) /* get */ if (!(data =3D virDomainGetMetadata(dom, VIR_DOMAIN_METADATA_ELEME= NT, uri, flags))) - goto cleanup; + return false; =20 vshPrint(ctl, "%s\n", data); } @@ -8698,7 +8589,6 @@ static bool cmdSendKey(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; - bool ret =3D false; const char *codeset_option; int codeset; unsigned int holdtime =3D 0; @@ -8714,7 +8604,7 @@ cmdSendKey(vshControl *ctl, const vshCmd *cmd) codeset_option =3D "linux"; =20 if (vshCommandOptUInt(ctl, cmd, "holdtime", &holdtime) < 0) - goto cleanup; + return false; =20 /* The qnum codeset was originally called rfb, so we need to keep * accepting the old name for backwards compatibility reasons */ @@ -8724,19 +8614,19 @@ cmdSendKey(vshControl *ctl, const vshCmd *cmd) codeset =3D virKeycodeSetTypeFromString(codeset_option); if (codeset < 0) { vshError(ctl, _("unknown codeset: '%s'"), codeset_option); - goto cleanup; + return false; } =20 while ((opt =3D vshCommandOptArgv(ctl, cmd, opt))) { if (count =3D=3D VIR_DOMAIN_SEND_KEY_MAX_KEYS) { vshError(ctl, _("too many keycodes")); - goto cleanup; + return false; } =20 if ((keycode =3D virshKeyCodeGetInt(opt->data)) < 0) { if ((keycode =3D virKeycodeValueFromString(codeset, opt->data)= ) < 0) { vshError(ctl, _("invalid keycode: '%s'"), opt->data); - goto cleanup; + return false; } } =20 @@ -8744,11 +8634,10 @@ cmdSendKey(vshControl *ctl, const vshCmd *cmd) count++; } =20 - if (!(virDomainSendKey(dom, codeset, holdtime, keycodes, count, 0) < 0= )) - ret =3D true; + if (virDomainSendKey(dom, codeset, holdtime, keycodes, count, 0) < 0) + return false; =20 - cleanup: - return ret; + return true; } =20 /* @@ -8882,7 +8771,6 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd) unsigned long long bytes =3D 0; unsigned long long max; unsigned long kibibytes =3D 0; - bool ret =3D false; bool config =3D vshCommandOptBool(cmd, "config"); bool live =3D vshCommandOptBool(cmd, "live"); bool current =3D vshCommandOptBool(cmd, "current"); @@ -8911,15 +8799,13 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd) else max =3D ULONG_MAX; if (vshCommandOptScaledInt(ctl, cmd, "size", &bytes, 1024, max) < 0) - goto cleanup; + return false; kibibytes =3D VIR_DIV_UP(bytes, 1024); =20 if (virDomainSetMemoryFlags(dom, kibibytes, flags) < 0) - goto cleanup; + return false; =20 - ret =3D true; - cleanup: - return ret; + return true; } =20 /* @@ -8959,7 +8845,6 @@ cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd) unsigned long long bytes =3D 0; unsigned long long max; unsigned long kibibytes =3D 0; - bool ret =3D false; bool config =3D vshCommandOptBool(cmd, "config"); bool live =3D vshCommandOptBool(cmd, "live"); bool current =3D vshCommandOptBool(cmd, "current"); @@ -8983,17 +8868,15 @@ cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd) else max =3D ULONG_MAX; if (vshCommandOptScaledInt(ctl, cmd, "size", &bytes, 1024, max) < 0) - goto cleanup; + return false; kibibytes =3D VIR_DIV_UP(bytes, 1024); =20 if (virDomainSetMemoryFlags(dom, kibibytes, flags | VIR_DOMAIN_MEM_MAX= IMUM) < 0) { vshError(ctl, "%s", _("Unable to change MaxMemorySize")); - goto cleanup; + return false; } =20 - ret =3D true; - cleanup: - return ret; + return true; } =20 /* @@ -9888,7 +9771,6 @@ static bool cmdLxcEnterNamespace(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; - bool ret =3D false; const vshCmdOpt *opt =3D NULL; g_autofree char **cmdargv =3D NULL; size_t ncmdargv =3D 0; @@ -9903,7 +9785,7 @@ cmdLxcEnterNamespace(vshControl *ctl, const vshCmd *c= md) =20 dom =3D virshCommandOptDomain(ctl, cmd, NULL); if (dom =3D=3D NULL) - goto cleanup; + return false; =20 if (vshCommandOptBool(cmd, "noseclabel")) setlabel =3D false; @@ -9916,16 +9798,16 @@ cmdLxcEnterNamespace(vshControl *ctl, const vshCmd = *cmd) cmdargv[ncmdargv - 1] =3D NULL; =20 if ((nfdlist =3D virDomainLxcOpenNamespace(dom, &fdlist, 0)) < 0) - goto cleanup; + return false; =20 if (setlabel) { secmodel =3D g_new0(virSecurityModel, 1); seclabel =3D g_new0(virSecurityLabel, 1); =20 if (virNodeGetSecurityModel(priv->conn, secmodel) < 0) - goto cleanup; + return false; if (virDomainGetSecurityLabel(dom, seclabel) < 0) - goto cleanup; + return false; } =20 /* Fork once because we don't want to affect @@ -9933,7 +9815,7 @@ cmdLxcEnterNamespace(vshControl *ctl, const vshCmd *c= md) * can only be changed in single-threaded process */ if ((pid =3D virFork()) < 0) - goto cleanup; + return false; if (pid =3D=3D 0) { int status; =20 @@ -9973,14 +9855,11 @@ cmdLxcEnterNamespace(vshControl *ctl, const vshCmd = *cmd) VIR_FREE(fdlist); if (virProcessWait(pid, NULL, false) < 0) { vshReportError(ctl); - goto cleanup; + return false; } } =20 - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -10136,7 +10015,6 @@ static const vshCmdOptDef opts_domxmltonative[] =3D= { static bool cmdDomXMLToNative(vshControl *ctl, const vshCmd *cmd) { - bool ret =3D false; const char *format =3D NULL; const char *xmlFile =3D NULL; g_autofree char *configData =3D NULL; @@ -10159,26 +10037,22 @@ cmdDomXMLToNative(vshControl *ctl, const vshCmd *= cmd) xmlData =3D virDomainGetXMLDesc(dom, flags); } else if (xmlFile) { if (virFileReadAll(xmlFile, VSH_MAX_XML_FILE, &xmlData) < 0) - goto cleanup; + return false; } else { vshError(ctl, "%s", _("need either domain or domain XML")); - goto cleanup; + return false; } =20 if (!xmlData) { vshError(ctl, "%s", _("failed to retrieve XML")); - goto cleanup; + return false; } =20 - if (!(configData =3D virConnectDomainXMLToNative(priv->conn, format, x= mlData, flags))) { - goto cleanup; - } else { - vshPrint(ctl, "%s", configData); - ret =3D true; - } + if (!(configData =3D virConnectDomainXMLToNative(priv->conn, format, x= mlData, flags))) + return false; =20 - cleanup: - return ret; + vshPrint(ctl, "%s", configData); + return true; } =20 /* @@ -10246,22 +10120,18 @@ cmdDomrename(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; const char *new_name =3D NULL; - bool ret =3D false; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) - return ret; + return false; =20 if (vshCommandOptStringReq(ctl, cmd, "new-name", &new_name) < 0) - goto cleanup; + return false; =20 if (virDomainRename(dom, new_name, 0) < 0) - goto cleanup; + return false; =20 vshPrintExtra(ctl, "Domain successfully renamed\n"); - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -11076,19 +10946,15 @@ cmdMigrateGetMaxDowntime(vshControl *ctl, const v= shCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; unsigned long long downtime; - bool ret =3D false; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (virDomainMigrateGetMaxDowntime(dom, &downtime, 0) < 0) - goto done; + return false; =20 vshPrint(ctl, "%llu\n", downtime); - ret =3D true; - - done: - return ret; + return true; } =20 =20 @@ -11121,7 +10987,6 @@ cmdMigrateCompCache(vshControl *ctl, const vshCmd *= cmd) { g_autoptr(virshDomain) dom =3D NULL; unsigned long long size =3D 0; - bool ret =3D false; const char *unit; double value; int rc; @@ -11131,21 +10996,19 @@ cmdMigrateCompCache(vshControl *ctl, const vshCmd= *cmd) =20 rc =3D vshCommandOptULongLong(ctl, cmd, "size", &size); if (rc < 0) { - goto cleanup; + return false; } else if (rc !=3D 0) { if (virDomainMigrateSetCompressionCache(dom, size, 0) < 0) - goto cleanup; + return false; } =20 if (virDomainMigrateGetCompressionCache(dom, &size, 0) < 0) - goto cleanup; + return false; =20 value =3D vshPrettyCapacity(size, &unit); vshPrint(ctl, _("Compression cache: %.3lf %s"), value, unit); =20 - ret =3D true; - cleanup: - return ret; + return true; } =20 /* @@ -11182,24 +11045,20 @@ cmdMigrateSetMaxSpeed(vshControl *ctl, const vshC= md *cmd) g_autoptr(virshDomain) dom =3D NULL; unsigned long bandwidth =3D 0; unsigned int flags =3D 0; - bool ret =3D false; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptULWrap(ctl, cmd, "bandwidth", &bandwidth) < 0) - goto done; + return false; =20 if (vshCommandOptBool(cmd, "postcopy")) flags |=3D VIR_DOMAIN_MIGRATE_MAX_SPEED_POSTCOPY; =20 if (virDomainMigrateSetMaxSpeed(dom, bandwidth, flags) < 0) - goto done; + return false; =20 - ret =3D true; - - done: - return ret; + return true; } =20 /* @@ -11230,7 +11089,6 @@ cmdMigrateGetMaxSpeed(vshControl *ctl, const vshCmd= *cmd) g_autoptr(virshDomain) dom =3D NULL; unsigned long bandwidth; unsigned int flags =3D 0; - bool ret =3D false; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -11239,14 +11097,11 @@ cmdMigrateGetMaxSpeed(vshControl *ctl, const vshC= md *cmd) flags |=3D VIR_DOMAIN_MIGRATE_MAX_SPEED_POSTCOPY; =20 if (virDomainMigrateGetMaxSpeed(dom, &bandwidth, flags) < 0) - goto done; + return false; =20 vshPrint(ctl, "%lu\n", bandwidth); =20 - ret =3D true; - - done: - return ret; + return true; } =20 /* @@ -11272,18 +11127,14 @@ static bool cmdMigratePostCopy(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; - bool ret =3D false; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (virDomainMigrateStartPostCopy(dom, 0) < 0) - goto cleanup; + return false; =20 - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -11578,7 +11429,6 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd) g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; g_autoptr(virshDomain) dom =3D NULL; - bool ret =3D false; int port =3D 0; g_autofree char *listen_addr =3D NULL; =20 @@ -11588,17 +11438,17 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd) /* Check if the domain is active and don't rely on -1 for this */ if (!virDomainIsActive(dom)) { vshError(ctl, _("Domain is not running")); - goto cleanup; + return false; } =20 if (virshDomainGetXMLFromDom(ctl, dom, 0, &xml, &ctxt) < 0) - goto cleanup; + return false; =20 /* Get the VNC port */ if (virXPathInt("string(/domain/devices/graphics[@type=3D'vnc']/@port)= ", ctxt, &port)) { vshError(ctl, _("Failed to get VNC port. Is this domain using VNC?= ")); - goto cleanup; + return false; } =20 listen_addr =3D virXPathString("string(/domain/devices/graphics" @@ -11620,10 +11470,7 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd) else vshPrint(ctl, "%s:%d\n", listen_addr, port-5900); =20 - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -11649,20 +11496,16 @@ cmdTTYConsole(vshControl *ctl, const vshCmd *cmd) { g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; - bool ret =3D false; g_autofree char *tty =3D NULL; =20 if (virshDomainGetXML(ctl, cmd, 0, &xml, &ctxt) < 0) return false; =20 if (!(tty =3D virXPathString("string(/domain/devices/console/@tty)", c= txt))) - goto cleanup; + return false; =20 vshPrint(ctl, "%s\n", tty); - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -11849,7 +11692,6 @@ cmdDetachDeviceAlias(vshControl *ctl, const vshCmd = *cmd) bool config =3D vshCommandOptBool(cmd, "config"); bool live =3D vshCommandOptBool(cmd, "live"); unsigned int flags =3D VIR_DOMAIN_AFFECT_CURRENT; - bool ret =3D false; =20 VSH_EXCLUSIVE_OPTIONS_VAR(current, live); VSH_EXCLUSIVE_OPTIONS_VAR(current, config); @@ -11863,18 +11705,15 @@ cmdDetachDeviceAlias(vshControl *ctl, const vshCm= d *cmd) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "alias", &alias) < 0) - goto cleanup; + return false; =20 if (virDomainDetachDeviceAlias(dom, alias, flags) < 0) { vshError(ctl, _("Failed to detach device with alias %s"), alias); - goto cleanup; + return false; } =20 vshPrintExtra(ctl, "%s", _("Device detach request sent successfully\n"= )); - ret =3D true; - - cleanup: - return ret; + return true; } =20 =20 @@ -11911,7 +11750,6 @@ cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshDomain) dom =3D NULL; const char *from =3D NULL; g_autofree char *buffer =3D NULL; - bool ret =3D false; unsigned int flags =3D VIR_DOMAIN_AFFECT_CURRENT; bool current =3D vshCommandOptBool(cmd, "current"); bool config =3D vshCommandOptBool(cmd, "config"); @@ -11932,7 +11770,7 @@ cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) - goto cleanup; + return false; =20 if (persistent && virDomainIsActive(dom) =3D=3D 1) @@ -11940,7 +11778,7 @@ cmdUpdateDevice(vshControl *ctl, const vshCmd *cmd) =20 if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) { vshReportError(ctl); - goto cleanup; + return false; } =20 if (vshCommandOptBool(cmd, "force")) @@ -11948,14 +11786,11 @@ cmdUpdateDevice(vshControl *ctl, const vshCmd *cm= d) =20 if (virDomainUpdateDeviceFlags(dom, buffer, flags) < 0) { vshError(ctl, _("Failed to update device from %s"), from); - goto cleanup; + return false; } =20 vshPrintExtra(ctl, "%s", _("Device updated successfully\n")); - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -12179,13 +12014,12 @@ virshFindDisk(const char *doc, g_autoptr(xmlXPathObject) obj =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; xmlNodePtr cur =3D NULL; - xmlNodePtr ret =3D NULL; size_t i; =20 xml =3D virXMLParseStringCtxt(doc, _("(domain_definition)"), &ctxt); if (!xml) { vshError(NULL, "%s", _("Failed to get disk information")); - goto cleanup; + return NULL; } =20 obj =3D xmlXPathEval(BAD_CAST "/domain/devices/disk", ctxt); @@ -12194,7 +12028,7 @@ virshFindDisk(const char *doc, obj->nodesetval =3D=3D NULL || obj->nodesetval->nodeNr =3D=3D 0) { vshError(NULL, "%s", _("Failed to get disk information")); - goto cleanup; + return NULL; } =20 /* search disk using @path */ @@ -12234,10 +12068,10 @@ virshFindDisk(const char *doc, } =20 if (STREQ_NULLABLE(tmp, path)) { - ret =3D xmlCopyNode(obj->nodesetval->nodeTab[i], 1); + xmlNodePtr ret =3D xmlCopyNode(obj->nodesetval->nodeTa= b[i], 1); /* drop backing store since they are not needed here */ virshDiskDropBackingStore(ret); - goto cleanup; + return ret; } } cur =3D cur->next; @@ -12245,9 +12079,7 @@ virshFindDisk(const char *doc, } =20 vshError(NULL, _("No disk found whose source path or target is %s"), p= ath); - - cleanup: - return ret; + return NULL; } =20 typedef enum { @@ -12285,7 +12117,7 @@ virshUpdateDiskXML(xmlNodePtr disk_node, if (!(STREQ_NULLABLE(device_type, "cdrom") || STREQ_NULLABLE(device_type, "floppy"))) { vshError(NULL, _("The disk device '%s' is not removable"), target); - goto cleanup; + return NULL; } =20 /* find the current source subelement */ @@ -12319,7 +12151,7 @@ virshUpdateDiskXML(xmlNodePtr disk_node, if (type =3D=3D VIRSH_UPDATE_DISK_XML_EJECT) { if (!source) { vshError(NULL, _("The disk device '%s' doesn't have media"), t= arget); - goto cleanup; + return NULL; } =20 /* forcibly switch to empty file cdrom */ @@ -12327,7 +12159,7 @@ virshUpdateDiskXML(xmlNodePtr disk_node, new_source =3D NULL; } else if (!new_source) { vshError(NULL, _("New disk media source was not specified")); - goto cleanup; + return NULL; } =20 if (source) { @@ -12339,7 +12171,7 @@ virshUpdateDiskXML(xmlNodePtr disk_node, =20 if (source_path && type =3D=3D VIRSH_UPDATE_DISK_XML_INSERT) { vshError(NULL, _("The disk device '%s' already has media"), ta= rget); - goto cleanup; + return NULL; } =20 startupPolicy =3D virXMLPropString(source, "startupPolicy"); @@ -12387,10 +12219,9 @@ virshUpdateDiskXML(xmlNodePtr disk_node, =20 if (!(ret =3D virXMLNodeToString(NULL, disk_node))) { vshSaveLibvirtError(); - goto cleanup; + return NULL; } =20 - cleanup: return ret; } =20 @@ -13684,29 +13515,25 @@ static bool cmdDomFSTrim(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; - bool ret =3D false; unsigned long long minimum =3D 0; const char *mountPoint =3D NULL; unsigned int flags =3D 0; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) - return ret; + return false; =20 if (vshCommandOptULongLong(ctl, cmd, "minimum", &minimum) < 0) - goto cleanup; + return false; =20 if (vshCommandOptStringReq(ctl, cmd, "mountpoint", &mountPoint) < 0) - goto cleanup; + return false; =20 if (virDomainFSTrim(dom, mountPoint, minimum, flags) < 0) { vshError(ctl, _("Unable to invoke fstrim")); - goto cleanup; + return false; } =20 - ret =3D true; - - cleanup: - return ret; + return true; } =20 static const vshCmdInfo info_domfsfreeze[] =3D { @@ -13914,20 +13741,17 @@ cmdGuestAgentTimeout(vshControl *ctl, const vshCm= d *cmd) g_autoptr(virshDomain) dom =3D NULL; int timeout =3D VIR_DOMAIN_AGENT_RESPONSE_TIMEOUT_BLOCK; const unsigned int flags =3D 0; - bool ret =3D false; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptInt(ctl, cmd, "timeout", &timeout) < 0) - goto cleanup; + return false; =20 if (virDomainAgentSetResponseTimeout(dom, timeout, flags) < 0) - goto cleanup; + return false; =20 - ret =3D true; - cleanup: - return ret; + return true; } =20 /* @@ -14047,25 +13871,22 @@ cmdGetUserSSHKeys(vshControl *ctl, const vshCmd *= cmd) int nkeys =3D 0; size_t i; const unsigned int flags =3D 0; - bool ret =3D false; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "user", &user) < 0) - goto cleanup; + return false; =20 nkeys =3D virDomainAuthorizedSSHKeysGet(dom, user, &keys, flags); if (nkeys < 0) - goto cleanup; + return false; =20 for (i =3D 0; i < nkeys; i++) { vshPrint(ctl, "%s", keys[i]); } =20 - ret =3D true; - cleanup: - return ret; + return true; } =20 =20 @@ -14115,7 +13936,6 @@ cmdSetUserSSHKeys(vshControl *ctl, const vshCmd *cm= d) g_auto(GStrv) keys =3D NULL; int nkeys =3D 0; unsigned int flags =3D 0; - bool ret =3D false; =20 VSH_REQUIRE_OPTION("remove", "file"); VSH_EXCLUSIVE_OPTIONS("reset", "remove"); @@ -14124,10 +13944,10 @@ cmdSetUserSSHKeys(vshControl *ctl, const vshCmd *= cmd) return false; =20 if (vshCommandOptStringReq(ctl, cmd, "user", &user) < 0) - goto cleanup; + return false; =20 if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) - goto cleanup; + return false; =20 if (vshCommandOptBool(cmd, "remove")) { flags |=3D VIR_DOMAIN_AUTHORIZED_SSH_KEYS_SET_REMOVE; @@ -14137,7 +13957,7 @@ cmdSetUserSSHKeys(vshControl *ctl, const vshCmd *cm= d) =20 if (!from) { vshError(ctl, _("Option --file is required")); - goto cleanup; + return false; } } } @@ -14145,27 +13965,25 @@ cmdSetUserSSHKeys(vshControl *ctl, const vshCmd *= cmd) if (from) { if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) { vshSaveLibvirtError(); - goto cleanup; + return false; } =20 if (!(keys =3D g_strsplit(buffer, "\n", -1))) - goto cleanup; + return false; =20 nkeys =3D g_strv_length(keys); if (nkeys =3D=3D 0) { vshError(ctl, _("File %s contains no keys"), from); - goto cleanup; + return false; } } =20 if (virDomainAuthorizedSSHKeysSet(dom, user, (const char **) keys, nkeys, flags) = < 0) { - goto cleanup; + return false; } =20 - ret =3D true; - cleanup: - return ret; + return true; } =20 =20 @@ -14200,23 +14018,19 @@ cmdDomDirtyRateCalc(vshControl *ctl, const vshCmd= *cmd) { g_autoptr(virshDomain) dom =3D NULL; int seconds =3D 1; /* the default value is 1 */ - bool ret =3D false; =20 if (!(dom =3D virshCommandOptDomain(ctl, cmd, NULL))) return false; =20 if (vshCommandOptInt(ctl, cmd, "seconds", &seconds) < 0) - goto cleanup; + return false; =20 if (virDomainStartDirtyRateCalc(dom, seconds, 0) < 0) - goto cleanup; + return false; =20 vshPrintExtra(ctl, _("Start to calculate domain's memory " "dirty rate successfully.\n")); - ret =3D true; - - cleanup: - return ret; + return true; } =20 =20 diff --git a/tools/virsh-host.c b/tools/virsh-host.c index a32af023ae..2b8b953648 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -97,7 +97,6 @@ static const vshCmdOptDef opts_domcapabilities[] =3D { static bool cmdDomCapabilities(vshControl *ctl, const vshCmd *cmd) { - bool ret =3D false; g_autofree char *caps =3D NULL; const char *virttype =3D NULL; const char *emulatorbin =3D NULL; @@ -110,19 +109,17 @@ cmdDomCapabilities(vshControl *ctl, const vshCmd *cmd) vshCommandOptStringReq(ctl, cmd, "emulatorbin", &emulatorbin) < 0 = || vshCommandOptStringReq(ctl, cmd, "arch", &arch) < 0 || vshCommandOptStringReq(ctl, cmd, "machine", &machine) < 0) - return ret; + return false; =20 caps =3D virConnectGetDomainCapabilities(priv->conn, emulatorbin, arch, machine, virttype, flags); if (!caps) { vshError(ctl, "%s", _("failed to get emulator capabilities")); - goto cleanup; + return false; } =20 vshPrint(ctl, "%s\n", caps); - ret =3D true; - cleanup: - return ret; + return true; } =20 /* @@ -154,7 +151,6 @@ static const vshCmdOptDef opts_freecell[] =3D { static bool cmdFreecell(vshControl *ctl, const vshCmd *cmd) { - bool ret =3D false; int cell =3D -1; unsigned long long memory =3D 0; g_autofree xmlNodePtr *nodes =3D NULL; @@ -177,13 +173,13 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd) if (all) { if (!(cap_xml =3D virConnectGetCapabilities(priv->conn))) { vshError(ctl, "%s", _("unable to get node capabilities")); - goto cleanup; + return false; } =20 xml =3D virXMLParseStringCtxt(cap_xml, _("(capabilities)"), &ctxt); if (!xml) { vshError(ctl, "%s", _("unable to get node capabilities")); - goto cleanup; + return false; } =20 nodes_cnt =3D virXPathNodeSet("/capabilities/host/topology/cells/c= ell", @@ -192,7 +188,7 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd) if (nodes_cnt =3D=3D -1) { vshError(ctl, "%s", _("could not get information about " "NUMA topology")); - goto cleanup; + return false; } =20 nodes_free =3D g_new0(unsigned long long, nodes_cnt); @@ -203,14 +199,14 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd) g_autofree char *val =3D virXMLPropString(nodes[i], "id"); if (virStrToLong_ulp(val, NULL, 10, &id)) { vshError(ctl, "%s", _("conversion from string failed")); - goto cleanup; + return false; } nodes_id[i] =3D id; if (virNodeGetCellsFreeMemory(priv->conn, &(nodes_free[i]), id, 1) !=3D 1) { vshError(ctl, _("failed to get free memory for NUMA node " "number: %lu"), id); - goto cleanup; + return false; } } =20 @@ -225,21 +221,18 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd) } else { if (cellno) { if (virNodeGetCellsFreeMemory(priv->conn, &memory, cell, 1) != =3D 1) - goto cleanup; + return false; =20 vshPrint(ctl, "%d: %llu KiB\n", cell, (memory/1024)); } else { if ((memory =3D virNodeGetFreeMemory(priv->conn)) =3D=3D 0) - goto cleanup; + return false; =20 vshPrint(ctl, "%s: %llu KiB\n", _("Total"), (memory/1024)); } } =20 - ret =3D true; - - cleanup: - return ret; + return true; } =20 =20 @@ -476,7 +469,6 @@ static const vshCmdOptDef opts_allocpages[] =3D { static bool cmdAllocpages(vshControl *ctl, const vshCmd *cmd) { - bool ret =3D false; bool add =3D vshCommandOptBool(cmd, "add"); bool all =3D vshCommandOptBool(cmd, "all"); bool cellno =3D vshCommandOptBool(cmd, "cellno"); @@ -511,13 +503,13 @@ cmdAllocpages(vshControl *ctl, const vshCmd *cmd) =20 if (!(cap_xml =3D virConnectGetCapabilities(priv->conn))) { vshError(ctl, "%s", _("unable to get node capabilities")); - goto cleanup; + return false; } =20 xml =3D virXMLParseStringCtxt(cap_xml, _("(capabilities)"), &ctxt); if (!xml) { vshError(ctl, "%s", _("unable to get node capabilities")); - goto cleanup; + return false; } =20 nodes_cnt =3D virXPathNodeSet("/capabilities/host/topology/cells/c= ell", @@ -526,7 +518,7 @@ cmdAllocpages(vshControl *ctl, const vshCmd *cmd) if (nodes_cnt =3D=3D -1) { vshError(ctl, "%s", _("could not get information about " "NUMA topology")); - goto cleanup; + return false; } =20 for (i =3D 0; i < nodes_cnt; i++) { @@ -534,22 +526,20 @@ cmdAllocpages(vshControl *ctl, const vshCmd *cmd) g_autofree char *val =3D virXMLPropString(nodes[i], "id"); if (virStrToLong_ulp(val, NULL, 10, &id)) { vshError(ctl, "%s", _("conversion from string failed")); - goto cleanup; + return false; } =20 if (virNodeAllocPages(priv->conn, 1, pageSizes, pageCounts, id, 1, flags) < 0) - goto cleanup; + return false; } } else { if (virNodeAllocPages(priv->conn, 1, pageSizes, pageCounts, startCell, cellCount, flags) < 0) - goto cleanup; + return false; } =20 - ret =3D true; - cleanup: - return ret; + return true; } =20 =20 @@ -583,7 +573,6 @@ cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd) g_autoptr(xmlDoc) xml =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; virshControl *priv =3D ctl->privData; - bool ret =3D false; =20 if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0) return false; @@ -591,7 +580,7 @@ cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd) if ((caps =3D virConnectGetDomainCapabilities(priv->conn, NULL, NULL, = NULL, type, 0))) { if (!(xml =3D virXMLParseStringCtxt(caps, _("(domainCapabilities)"= ), &ctxt))) - goto cleanup; + return false; =20 ignore_value(virXPathInt("string(./vcpu[1]/@max)", ctxt, &vcpus)); } else { @@ -599,13 +588,10 @@ cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd) } =20 if (vcpus < 0 && (vcpus =3D virConnectGetMaxVcpus(priv->conn, type)) <= 0) - goto cleanup; + return false; =20 vshPrint(ctl, "%d\n", vcpus); - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -673,13 +659,12 @@ cmdNodeCpuMap(vshControl *ctl, const vshCmd *cmd G_GN= UC_UNUSED) g_autofree unsigned char *cpumap =3D NULL; unsigned int online; bool pretty =3D vshCommandOptBool(cmd, "pretty"); - bool ret =3D false; virshControl *priv =3D ctl->privData; =20 cpunum =3D virNodeGetCPUMap(priv->conn, &cpumap, &online, 0); if (cpunum < 0) { vshError(ctl, "%s", _("Unable to get cpu map")); - goto cleanup; + return false; } =20 vshPrint(ctl, "%-15s %d\n", _("CPUs present:"), cpunum); @@ -690,7 +675,7 @@ cmdNodeCpuMap(vshControl *ctl, const vshCmd *cmd G_GNUC= _UNUSED) g_autofree char *str =3D virBitmapDataFormat(cpumap, VIR_CPU_MAPLE= N(cpunum)); =20 if (!str) - goto cleanup; + return false; vshPrint(ctl, "%s", str); } else { for (cpu =3D 0; cpu < cpunum; cpu++) @@ -698,10 +683,7 @@ cmdNodeCpuMap(vshControl *ctl, const vshCmd *cmd G_GNU= C_UNUSED) } vshPrint(ctl, "\n"); =20 - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -767,7 +749,6 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd) int cpuNum =3D VIR_NODE_CPU_STATS_ALL_CPUS; g_autofree virNodeCPUStatsPtr params =3D NULL; int nparams =3D 0; - bool ret =3D false; unsigned long long cpu_stats[VIRSH_CPU_LAST] =3D { 0 }; bool present[VIRSH_CPU_LAST] =3D { false }; virshControl *priv =3D ctl->privData; @@ -791,7 +772,7 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd) for (i =3D 0; i < 2; i++) { if (virNodeGetCPUStats(priv->conn, cpuNum, params, &nparams, 0) != =3D 0) { vshError(ctl, "%s", _("Unable to get node cpu stats")); - goto cleanup; + return false; } =20 for (j =3D 0; j < nparams; j++) { @@ -845,10 +826,7 @@ cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd) } } =20 - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* @@ -879,7 +857,6 @@ cmdNodeMemStats(vshControl *ctl, const vshCmd *cmd) size_t i; int cellNum =3D VIR_NODE_MEMORY_STATS_ALL_CELLS; g_autofree virNodeMemoryStatsPtr params =3D NULL; - bool ret =3D false; virshControl *priv =3D ctl->privData; =20 if (vshCommandOptInt(ctl, cmd, "cell", &cellNum) < 0) @@ -889,29 +866,25 @@ cmdNodeMemStats(vshControl *ctl, const vshCmd *cmd) if (virNodeGetMemoryStats(priv->conn, cellNum, NULL, &nparams, 0) !=3D= 0) { vshError(ctl, "%s", _("Unable to get number of memory stats")); - goto cleanup; + return false; } =20 if (nparams =3D=3D 0) { /* nothing to output */ - ret =3D true; - goto cleanup; + return true; } =20 /* now go get all the memory parameters */ params =3D g_new0(virNodeMemoryStats, nparams); if (virNodeGetMemoryStats(priv->conn, cellNum, params, &nparams, 0) != =3D 0) { vshError(ctl, "%s", _("Unable to get memory stats")); - goto cleanup; + return false; } =20 for (i =3D 0; i < nparams; i++) vshPrint(ctl, "%-7s: %20llu KiB\n", params[i].field, params[i].val= ue); =20 - ret =3D true; - - cleanup: - return ret; + return true; } =20 /* diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index c4b1d556ca..945ccc7f45 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -122,11 +122,11 @@ vshFindNodeDevice(vshControl *ctl, const char *value) narr =3D vshStringToArray(value, &arr); if (narr !=3D 2) { vshError(ctl, _("Malformed device value '%s'"), value); - goto cleanup; + return NULL; } =20 if (!virValidateWWN(arr[0]) || !virValidateWWN(arr[1])) - goto cleanup; + return NULL; =20 dev =3D virNodeDeviceLookupSCSIHostByWWN(priv->conn, arr[0], arr[1= ], 0); } else { @@ -135,10 +135,9 @@ vshFindNodeDevice(vshControl *ctl, const char *value) =20 if (!dev) { vshError(ctl, "%s '%s'", _("Could not find matching device"), valu= e); - goto cleanup; + return NULL; } =20 - cleanup: return dev; } =20 diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index b4dfcc2f7a..c51dc023e3 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -529,17 +529,16 @@ virshMakeCloneXML(const char *origxml, const char *ne= wname) =20 doc =3D virXMLParseStringCtxt(origxml, _("(volume_definition)"), &ctxt= ); if (!doc) - goto cleanup; + return NULL; =20 obj =3D xmlXPathEval(BAD_CAST "/volume/name", ctxt); if (obj =3D=3D NULL || obj->nodesetval =3D=3D NULL || obj->nodesetval->nodeTab =3D=3D NULL) - goto cleanup; + return NULL; =20 xmlNodeSetContent(obj->nodesetval->nodeTab[0], (const xmlChar *)newnam= e); xmlDocDumpMemory(doc, &newxml, &size); =20 - cleanup: return newxml; } =20 diff --git a/tools/vsh.c b/tools/vsh.c index f9600bafba..4356bc391d 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -432,7 +432,6 @@ vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cm= d, const char *name, bool report) { size_t i; - const vshCmdOptDef *ret =3D NULL; g_autofree char *alias =3D NULL; =20 if (STREQ(name, helpopt.name)) @@ -457,7 +456,7 @@ vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cm= d, const char *name, if (report) vshError(ctl, _("invalid '=3D' after option --= %s"), opt->name); - goto cleanup; + return NULL; } *optstr =3D g_strdup(value + 1); } @@ -466,12 +465,11 @@ vshCmddefGetOption(vshControl *ctl, const vshCmdDef *= cmd, const char *name, if ((*opts_seen & (1ULL << i)) && opt->type !=3D VSH_OT_ARGV) { if (report) vshError(ctl, _("option --%s already seen"), name); - goto cleanup; + return NULL; } *opts_seen |=3D 1ULL << i; *opt_index =3D i; - ret =3D opt; - goto cleanup; + return opt; } } =20 @@ -479,8 +477,7 @@ vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cm= d, const char *name, vshError(ctl, _("command '%s' doesn't support option --%s"), cmd->name, name); } - cleanup: - return ret; + return NULL; } =20 static const vshCmdOptDef * --=20 2.31.1 From nobody Sun May 5 17:07:13 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=1628767975; cv=none; d=zohomail.com; s=zohoarc; b=F6qdsCPmWwyOd4BDqqqTtS5nBhiwfLHAT9SZvbNRycbV3Q9t1SBJtRcn3JaifJ+cGbZ0X9C/KeyTFP+B+Y0WzTl9KrK+lVEJyC+ke0UjfvV5QNyQ8C2g+FTT/UvnARZq4asO6N/Y3nn/bwOlxKIyIXxEc0al+o3yDJT721zBYow= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1628767975; 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=YHAOEsNMGRk28hZa9bBsydfNtUcQR36ZDI9N41SVvus=; b=aZ51w2WxNinlJdMO6RV+JMiZtqyXhL36q18KHi5ld1O9pg/Bzz4XvUeahCV+0tGj6XvIl7MLTBdSDknrOMq5ww6vICVRaSxL9vbYmpEZSY8mjhKY48VtTtLqLY+yr1C+sOwJa4TwbQ70Z0rTbNqc9KcAYqgGmhjXEEYAQI/CiE4= 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) 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 1628767975908983.2000949896837; Thu, 12 Aug 2021 04:32:55 -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-381-3jPnXZU2OhK5Au0GezNRhQ-1; Thu, 12 Aug 2021 07:32:53 -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 25A9B107ACF5; Thu, 12 Aug 2021 11:32:47 +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 9B9A360BF1; Thu, 12 Aug 2021 11:32:46 +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 4B7CC181A2A6; Thu, 12 Aug 2021 11:32:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17CBWg72020922 for ; Thu, 12 Aug 2021 07:32:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5B8005B826; Thu, 12 Aug 2021 11:32:42 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id D8AF669FAD for ; Thu, 12 Aug 2021 11:32:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1628767974; 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=YHAOEsNMGRk28hZa9bBsydfNtUcQR36ZDI9N41SVvus=; b=f4jTJswKCx+hhdwdrbfdLdToUk/KkeGPLuQxa/4BtkE4/0rsFBclFrHD/KkFWbSo6H/G9I 8MzTyPvelcUB8g48yogkQQH0zhj307miVtYDOyZChDniMOyevZwtR6rme56qcLou4Gan93 T99pSMEQ/Wi27gbj6vIfSlw+pTnf7kI= X-MC-Unique: 3jPnXZU2OhK5Au0GezNRhQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 13/12] fixup Date: Thu, 12 Aug 2021 13:32:31 +0200 Message-Id: <583e0a2daddcd7ca8883827eab0709e36b4a05f4.1628767776.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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) X-ZM-MESSAGEID: 1628767976457100001 fixup /=CB=88f=C9=AAks=CA=8Cp/ n. the next best thing after getting it right the first time Signed-off-by: J=C3=A1n Tomko Reviewed-by: Martin Kletzander --- tools/virsh-domain.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index d06c24cc74..e985090992 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -6970,7 +6970,6 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd) g_autoptr(virshDomain) dom =3D NULL; unsigned int vcpu =3D 0; const char *cpulist =3D NULL; - bool ret =3D false; g_autofree unsigned char *cpumap =3D NULL; int cpumaplen; int maxcpu; @@ -7012,8 +7011,7 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd) =20 /* Query mode: show CPU affinity information then exit.*/ if (!cpulist) { - ret =3D virshVcpuPinQuery(ctl, dom, vcpu, got_vcpu, maxcpu, flags); - return false; + return virshVcpuPinQuery(ctl, dom, vcpu, got_vcpu, maxcpu, flags); } =20 /* Pin mode: pinning specified vcpu to specified physical cpus */ @@ -7063,7 +7061,6 @@ cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd) { g_autoptr(virshDomain) dom =3D NULL; const char *cpulist =3D NULL; - bool ret =3D false; g_autofree unsigned char *cpumap =3D NULL; int cpumaplen; int maxcpu; @@ -7099,6 +7096,8 @@ cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd) =20 /* Query mode: show CPU affinity information then exit.*/ if (query) { + bool ret =3D false; + /* When query mode and neither "live", "config" nor "current" * is specified, set VIR_DOMAIN_AFFECT_CURRENT as flags */ if (flags =3D=3D -1) @@ -7114,7 +7113,7 @@ cmdEmulatorPin(vshControl *ctl, const vshCmd *cmd) ret =3D virshPrintPinInfo(ctl, cpumap, cpumaplen); vshPrint(ctl, "\n"); } - return false; + return ret; } =20 /* Pin mode: pinning emulator threads to specified physical cpus */ --=20 2.31.1