From patchwork Fri Jan 10 19:41:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vladimir Sementsov-Ogievskiy X-Patchwork-Id: 11328391 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A028A930 for ; Fri, 10 Jan 2020 19:44:04 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 86DFE20842 for ; Fri, 10 Jan 2020 19:44:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 86DFE20842 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iq0BJ-0003r9-IQ; Fri, 10 Jan 2020 19:42:53 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iq0BI-0003qs-Nq for xen-devel@lists.xenproject.org; Fri, 10 Jan 2020 19:42:52 +0000 X-Inumbo-ID: 58f8f8c8-33e1-11ea-ac27-bc764e2007e4 Received: from relay.sw.ru (unknown [185.231.240.75]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 58f8f8c8-33e1-11ea-ac27-bc764e2007e4; Fri, 10 Jan 2020 19:42:34 +0000 (UTC) Received: from vovaso.qa.sw.ru ([10.94.3.0] helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.92.3) (envelope-from ) id 1iq0AT-0008Ob-Ta; Fri, 10 Jan 2020 22:42:02 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org Date: Fri, 10 Jan 2020 22:41:48 +0300 Message-Id: <20200110194158.14190-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200110194158.14190-1-vsementsov@virtuozzo.com> References: <20200110194158.14190-1-vsementsov@virtuozzo.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v6 01/11] qapi/error: add (Error **errp) cleaning APIs X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , Laszlo Ersek , qemu-block@nongnu.org, Paul Durrant , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Cornelia Huck , Greg Kurz , Max Reitz , Stefano Stabellini , Gerd Hoffmann , Stefan Hajnoczi , Anthony Perard , xen-devel@lists.xenproject.org, Eric Blake , Michael Roth , Markus Armbruster , Stefan Berger Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Greg Kurz Reviewed-by: Eric Blake --- CC: Cornelia Huck CC: Eric Blake CC: Kevin Wolf CC: Max Reitz CC: Greg Kurz CC: Stefan Hajnoczi CC: Stefano Stabellini CC: Anthony Perard CC: Paul Durrant CC: "Philippe Mathieu-Daudé" CC: Laszlo Ersek CC: Gerd Hoffmann CC: Stefan Berger CC: Markus Armbruster CC: Michael Roth CC: qemu-block@nongnu.org CC: xen-devel@lists.xenproject.org include/qapi/error.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/include/qapi/error.h b/include/qapi/error.h index ad5b6e896d..fa8d51fd6d 100644 --- a/include/qapi/error.h +++ b/include/qapi/error.h @@ -309,6 +309,32 @@ void warn_reportf_err(Error *err, const char *fmt, ...) void error_reportf_err(Error *err, const char *fmt, ...) GCC_FMT_ATTR(2, 3); +/* + * Functions to clean Error **errp: call corresponding Error *err cleaning + * function an set pointer to NULL + */ +static inline void error_free_errp(Error **errp) +{ + assert(errp && *errp); + error_free(*errp); + *errp = NULL; +} + +static inline void error_report_errp(Error **errp) +{ + assert(errp && *errp); + error_report_err(*errp); + *errp = NULL; +} + +static inline void warn_report_errp(Error **errp) +{ + assert(errp && *errp); + warn_report_err(*errp); + *errp = NULL; +} + + /* * Just like error_setg(), except you get to specify the error class. * Note: use of error classes other than ERROR_CLASS_GENERIC_ERROR is