From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54389) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLtuB-0002nQ-C2 for qemu-devel@nongnu.org; Thu, 12 Feb 2015 08:34:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YLtu8-0002TR-JF for qemu-devel@nongnu.org; Thu, 12 Feb 2015 08:34:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40931) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLtu8-0002TB-CF for qemu-devel@nongnu.org; Thu, 12 Feb 2015 08:34:04 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1CDY3Wc025145 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 12 Feb 2015 08:34:03 -0500 Received: from blackfin.pond.sub.org (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t1CDY0x0025393 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 12 Feb 2015 08:34:02 -0500 From: Markus Armbruster Date: Thu, 12 Feb 2015 14:33:51 +0100 Message-Id: <1423748040-3448-2-git-send-email-armbru@redhat.com> In-Reply-To: <1423748040-3448-1-git-send-email-armbru@redhat.com> References: <1423748040-3448-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH v2 01/10] error: New convenience function error_report_err() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org I've typed error_report("%s", error_get_pretty(ERR)) too many times already, and I've fixed too many instances of qerror_report_err(ERR) to error_report("%s", error_get_pretty(ERR)) as well. Capture the pattern in a convenience function. Since it's almost invariably followed by error_free(), stuff that into the convenience function as well. The next patch will put it to use. Signed-off-by: Markus Armbruster --- include/qapi/error.h | 5 +++++ util/error.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/include/qapi/error.h b/include/qapi/error.h index d712089..f44c451 100644 --- a/include/qapi/error.h +++ b/include/qapi/error.h @@ -83,6 +83,11 @@ Error *error_copy(const Error *err); const char *error_get_pretty(Error *err); /** + * Convenience function to error_report() and free an error object. + */ +void error_report_err(Error *); + +/** * Propagate an error to an indirect pointer to an error. This function will * always transfer ownership of the error reference and handles the case where * dst_err is NULL correctly. Errors after the first are discarded. diff --git a/util/error.c b/util/error.c index 2ace0d8..1ff6ae5 100644 --- a/util/error.c +++ b/util/error.c @@ -152,6 +152,12 @@ const char *error_get_pretty(Error *err) return err->msg; } +void error_report_err(Error *err) +{ + error_report("%s", error_get_pretty(err)); + error_free(err); +} + void error_free(Error *err) { if (err) { -- 1.9.3