From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52232) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZx7k-000710-Ec for qemu-devel@nongnu.org; Wed, 17 Aug 2016 05:27:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bZx7g-00006L-4B for qemu-devel@nongnu.org; Wed, 17 Aug 2016 05:26:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42318) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZx7f-00006H-Un for qemu-devel@nongnu.org; Wed, 17 Aug 2016 05:26:56 -0400 From: Markus Armbruster References: <1470901038-9409-1-git-send-email-peterx@redhat.com> <1470901038-9409-2-git-send-email-peterx@redhat.com> <87eg5p6kk0.fsf@dusky.pond.sub.org> <20160816115351.GB27853@al.usersys.redhat.com> <20160816121708.GD9866@pxdev.xzpeter.org> <20160817081706.GH14217@pxdev.xzpeter.org> Date: Wed, 17 Aug 2016 11:26:51 +0200 In-Reply-To: <20160817081706.GH14217@pxdev.xzpeter.org> (Peter Xu's message of "Wed, 17 Aug 2016 16:17:06 +0800") Message-ID: <874m6jpwys.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 1/2] error-report: provide error_report_exit() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Xu Cc: Marcel Apfelbaum , peter.maydell@linaro.org, pbonzini@redhat.com, fam@pxdev.xzpeter.org, qemu-devel@nongnu.org Peter Xu writes: > On Tue, Aug 16, 2016 at 08:17:08PM +0800, Peter Xu wrote: >> > > >> > > Also, please make it a function, not a macro: >> > > >> > > void error_report_fatal(const char *fmt, ...) >> > > { >> > > va_list ap; >> > > >> > > va_start(ap, fmt); >> > > error_vreport(fmt, ap); >> > > va_end(ap); >> > > exit(1); >> > > } > > Marcel (and reviewers), > > Now if we are having both error_report_fatal() and > error_report_abort(), we'll write error_report() three times if we all > take them as functions. Yes, but all we duplicate is the usual var-arg boilerplate. > How about we still use macro this time but leverage error_setg() > macro as mentioned by Fam, like: > > +#define error_report_fatal(...) error_setg(&error_fatal, __VA_ARGS__) > +#define error_report_abort(...) error_setg(&error_abort, __VA_ARGS__) > > In this case, we avoided calling exit() directly in the macro, and is > much cleaner than writting error_report() content for three times. I'm afraid that destroys the layering. Currently, Error objects (util/error.c) use error reporting (util/qemu-error.c), but not vice versa. Their headers (include/qapi/error.h and include/qemu/error-report.h) are idependent. I like it that way.