From nobody Sun Feb 8 17:37:36 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=1571161080; cv=none; d=zoho.com; s=zohoarc; b=eAntl1WwZyNJiP+jT6AxsgjcJa4y6fbhAC8JMu+QvJ5VZR33+xyo2bYsA9omXdn426inoTUvqcMlhxwVt0lJKHmH6u60zJR34o0juyd8BY1nVPCjGlKnEpGGtaeQSwU4KlCVfKQk3Aw5VJOJPKmXa+EkDM2E5WMUDK4JYwzM590= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571161080; 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=AmIgd3PEpDSZt7IyItiunp1wf1RsGA95nfzrg9hu3vY=; b=EzvjQoSLNeK46tHNNHf0/iCqaKdaDIQea1+0rJHG369RcGZR3ZSM4cLwK7wc2l1BuEwUS+DJwc6Uv1wf+si2vwJP4pAevQvES5ErxJAf2v2jiso0yN5pYExX6jDbL8n0wxGrujtfVZNfzpocNn7fTVE/Ff7PqCbZENTIai6CRv4= 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 1571161080174390.817165613253; Tue, 15 Oct 2019 10:38:00 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 130663175281; Tue, 15 Oct 2019 17:37:58 +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 E3EB5100EBD5; Tue, 15 Oct 2019 17:37:57 +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 AD3054EE71; Tue, 15 Oct 2019 17:37:57 +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 x9FHbc29001260 for ; Tue, 15 Oct 2019 13:37:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id F037B5DA8C; Tue, 15 Oct 2019 17:37:38 +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 AFF6E5D9E2 for ; Tue, 15 Oct 2019 17:37:38 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 15 Oct 2019 13:37:26 -0400 Message-Id: <20191015173728.1633-9-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 08/10] util: 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 15 Oct 2019 17:37:59 +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 --- src/util/vircgroup.c | 18 ++++++++---------- src/util/virfirewall.c | 6 ++++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index c6e4cf2dde..4c83e37ec4 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1168,13 +1168,12 @@ virCgroupNewMachineSystemd(const char *name, } =20 if (virCgroupAddProcess(*group, pidleader) < 0) { - virErrorPtr saved =3D virSaveLastError(); + virErrorPtr saved; + + virErrorPreserveLast(&saved); virCgroupRemove(*group); virCgroupFree(group); - if (saved) { - virSetError(saved); - virFreeError(saved); - } + virErrorRestore(&saved); } =20 return 0; @@ -1220,13 +1219,12 @@ virCgroupNewMachineManual(const char *name, goto cleanup; =20 if (virCgroupAddProcess(*group, pidleader) < 0) { - virErrorPtr saved =3D virSaveLastError(); + virErrorPtr saved; + + virErrorPreserveLast(&saved); virCgroupRemove(*group); virCgroupFree(group); - if (saved) { - virSetError(saved); - virFreeError(saved); - } + virErrorRestore(&saved); } =20 done: diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index 0d4bfae8f8..62f404afd6 100644 --- a/src/util/virfirewall.c +++ b/src/util/virfirewall.c @@ -838,7 +838,9 @@ virFirewallApply(virFirewallPtr firewall) if (virFirewallApplyGroup(firewall, i) < 0) { VIR_DEBUG("Rolling back groups up to %zu for %p", i, firewall); size_t first =3D i; - VIR_AUTOPTR(virError) saved_error =3D virSaveLastError(); + virErrorPtr saved_error; + + virErrorPreserveLast(&saved_error); =20 /* * Look at any inheritance markers to figure out @@ -858,7 +860,7 @@ virFirewallApply(virFirewallPtr firewall) virFirewallRollbackGroup(firewall, j); } =20 - virSetError(saved_error); + virErrorRestore(&saved_error); VIR_DEBUG("Done rolling back groups for %p", firewall); goto cleanup; } --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list