From nobody Sat Feb 7 10:44:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 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=1571161743; cv=none; d=zoho.com; s=zohoarc; b=HYHJd8/+WndO8O5hH4jbPxBWfVMv4WwBhPb7xVAHUwu+2QXWfIUCNvGl8REVNbJP9aqJhchvz5i5mpKa1TkaI8Jk2KtVJpaH0KT1DO3sJEx8mGE6jB9sEvX2zDSTT1SytSEDrAlL7O0FwzIY28OYxeSva8PKV50/OZH+TgqFfsw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571161743; 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=WhYaOWGJcZyEEUjfYw5BTSbmnsFg9M2tglaAE/wEMvA=; b=UZwTaucNpjdhuoq8cuW3/DGQVQXlFqUq94c+yHtM+swqIG+7OFODRl8C4+/g2tdqf93HhIQc0HpNsmk9nORR4VzKFkOnCqaXlGFggH1GT2LZQp8uNq2Z6Lmmv80NFEbS38uUASOPTW0X/XGw8Q50RIWXgXUSFqKE2f1Tu+3f8Dw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1571161743895457.4486988829706; Tue, 15 Oct 2019 10:49:03 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 33CB818C427D; Tue, 15 Oct 2019 17:49:02 +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 0DDA160852; Tue, 15 Oct 2019 17:49:02 +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 C05804EE69; Tue, 15 Oct 2019 17:49:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9FHbd4k001272 for ; Tue, 15 Oct 2019 13:37:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id CBEE05DA8C; Tue, 15 Oct 2019 17:37:39 +0000 (UTC) Received: from unknown0050b6a41c42.attlocal.com (ovpn-116-31.phx2.redhat.com [10.3.116.31]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8BF455D9E2 for ; Tue, 15 Oct 2019 17:37:39 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 15 Oct 2019 13:37:28 -0400 Message-Id: <20191015173728.1633-11-jferlan@redhat.com> In-Reply-To: <20191015173728.1633-1-jferlan@redhat.com> References: <20191015173728.1633-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 10/10] tools: Use consistent error preservation and restoration calls 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.62]); Tue, 15 Oct 2019 17:49:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Provide some consistency over error message variable name and usage when saving error messages across possible other errors or possibility of resetting of the last error. Instead of virSaveLastError paired up with virSetError and virFreeError, we should use the newer virErrorPreserveLast and virRestoreError. Signed-off-by: John Ferlan --- tools/virsh.c | 7 ++----- tools/virt-admin.c | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index 4aae877160..a3553ddd36 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -93,7 +93,7 @@ virshCatchDisconnect(virConnectPtr conn, virErrorPtr error; char *uri; =20 - error =3D virSaveLastError(); + virErrorPreserveLast(&error); uri =3D virConnectGetURI(conn); =20 switch ((virConnectCloseReason) reason) { @@ -114,10 +114,7 @@ virshCatchDisconnect(virConnectPtr conn, vshError(ctl, _(str), NULLSTR(uri)); VIR_FREE(uri); =20 - if (error) { - virSetError(error); - virFreeError(error); - } + virErrorRestore(&error); disconnected++; vshEventDone(ctl); } diff --git a/tools/virt-admin.c b/tools/virt-admin.c index c0cc0999cb..a820e7241d 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -124,7 +124,7 @@ vshAdmCatchDisconnect(virAdmConnectPtr conn G_GNUC_UNUS= ED, if (reason =3D=3D VIR_CONNECT_CLOSE_REASON_CLIENT) return; =20 - error =3D virSaveLastError(); + virErrorPreserveLast(&error); uri =3D virAdmConnectGetURI(conn); =20 switch ((virConnectCloseReason) reason) { @@ -146,10 +146,7 @@ vshAdmCatchDisconnect(virAdmConnectPtr conn G_GNUC_UNU= SED, vshError(ctl, _(str), NULLSTR(uri)); VIR_FREE(uri); =20 - if (error) { - virSetError(error); - virFreeError(error); - } + virErrorRestore(&error); } =20 static int --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list