From patchwork Mon Sep 23 16:12:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 1166142 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46cVJ30VFsz9s00 for ; Tue, 24 Sep 2019 02:33:39 +1000 (AEST) Received: from localhost ([::1]:59414 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCRHM-00081U-Bp for incoming@patchwork.ozlabs.org; Mon, 23 Sep 2019 12:33:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57117) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCQxP-0002RS-7G for qemu-devel@nongnu.org; Mon, 23 Sep 2019 12:13:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCQxN-0003k8-7o for qemu-devel@nongnu.org; Mon, 23 Sep 2019 12:12:58 -0400 Received: from relay.sw.ru ([185.231.240.75]:39508) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iCQxM-0003a8-Tg; Mon, 23 Sep 2019 12:12:57 -0400 Received: from [10.94.3.0] (helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.2) (envelope-from ) id 1iCQwy-0001Fp-Od; Mon, 23 Sep 2019 19:12:32 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Subject: [RFC v2 2/9] qapi/error: add (Error **errp) cleaning APIs Date: Mon, 23 Sep 2019 19:12:24 +0300 Message-Id: <20190923161231.22028-3-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190923161231.22028-1-vsementsov@virtuozzo.com> References: <20190923161231.22028-1-vsementsov@virtuozzo.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 X-Mailman-Approved-At: Mon, 23 Sep 2019 12:26:10 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stefanha@redhat.com, codyprime@gmail.com, jan.kiszka@siemens.com, berto@igalia.com, zhang.zhanghailiang@huawei.com, qemu-block@nongnu.org, arikalo@wavecomp.com, pasic@linux.ibm.com, hpoussin@reactos.org, anthony.perard@citrix.com, samuel.thibault@ens-lyon.org, philmd@redhat.com, green@moxielogic.com, lvivier@redhat.com, ehabkost@redhat.com, xiechanglong.d@gmail.com, pl@kamp.de, dgilbert@redhat.com, b.galvani@gmail.com, eric.auger@redhat.com, alex.williamson@redhat.com, ronniesahlberg@gmail.com, jsnow@redhat.com, rth@twiddle.net, kwolf@redhat.com, vsementsov@virtuozzo.com, andrew@aj.id.au, crwulff@gmail.com, sundeep.lkml@gmail.com, michael@walle.cc, qemu-ppc@nongnu.org, kbastian@mail.uni-paderborn.de, imammedo@redhat.com, fam@euphon.net, peter.maydell@linaro.org, sheepdog@lists.wpkg.org, david@redhat.com, palmer@sifive.com, thuth@redhat.com, jcmvbkbc@gmail.com, den@openvz.org, hare@suse.com, sstabellini@kernel.org, arei.gonglei@huawei.com, namei.unix@gmail.com, atar4qemu@gmail.com, farman@linux.ibm.com, amit@kernel.org, sw@weilnetz.de, groug@kaod.org, qemu-s390x@nongnu.org, qemu-arm@nongnu.org, peter.chubb@nicta.com.au, clg@kaod.org, shorne@gmail.com, qemu-riscv@nongnu.org, cohuck@redhat.com, amarkovic@wavecomp.com, aurelien@aurel32.net, pburton@wavecomp.com, sagark@eecs.berkeley.edu, jasowang@redhat.com, kraxel@redhat.com, edgar.iglesias@gmail.com, gxt@mprc.pku.edu.cn, ari@tuxera.com, quintela@redhat.com, mdroth@linux.vnet.ibm.com, lersek@redhat.com, borntraeger@de.ibm.com, antonynpavlov@gmail.com, dillaman@redhat.com, joel@jms.id.au, xen-devel@lists.xenproject.org, integration@gluster.org, rjones@redhat.com, Andrew.Baumann@microsoft.com, mreitz@redhat.com, walling@linux.ibm.com, mst@redhat.com, mark.cave-ayland@ilande.co.uk, v.maffione@gmail.com, marex@denx.de, armbru@redhat.com, marcandre.lureau@redhat.com, alistair@alistair23.me, paul.durrant@citrix.com, pavel.dovgaluk@ispras.ru, g.lettieri@iet.unipi.it, rizzo@iet.unipi.it, david@gibson.dropbear.id.au, akrowiak@linux.ibm.com, berrange@redhat.com, xiaoguangrong.eric@gmail.com, pmorel@linux.ibm.com, wencongyang2@huawei.com, jcd@tribudubois.net, pbonzini@redhat.com, stefanb@linux.ibm.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/qapi/error.h | 22 ++++++++++++++++++++++ util/error.c | 6 +++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/include/qapi/error.h b/include/qapi/error.h index f6f4fa0fac..551385aa91 100644 --- a/include/qapi/error.h +++ b/include/qapi/error.h @@ -297,6 +297,28 @@ void warn_report_err(Error *err); */ void error_report_err(Error *err); +/* + * Functions to clean Error **errp: call corresponding Error *err cleaning + * function an set pointer to NULL + */ +static inline void error_free_errp(Error **errp) +{ + error_free(*errp_in); + *errp_in = NULL; +} + +static inline void error_report_errp(Error **errp) +{ + error_report_err(*errp_in); + *errp_in = NULL; +} + +static inline void warn_report_errp(Error **errp) +{ + warn_report_err(*errp_in); + *errp_in = NULL; +} + /* * Convenience function to error_prepend(), warn_report() and free @err. */ diff --git a/util/error.c b/util/error.c index d4532ce318..dfba091757 100644 --- a/util/error.c +++ b/util/error.c @@ -273,9 +273,9 @@ void error_free(Error *err) void error_free_or_abort(Error **errp) { - assert(errp && *errp); - error_free(*errp); - *errp = NULL; + assert(errp_in && *errp_in); + error_free(*errp_in); + *errp_in = NULL; } void error_propagate(Error **dst_errp, Error *local_err)