From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53468) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZxDV-00022U-Nv for qemu-devel@nongnu.org; Wed, 17 Aug 2016 05:32:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bZxDR-0001cQ-Um for qemu-devel@nongnu.org; Wed, 17 Aug 2016 05:32:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51826) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZxDR-0001bm-PQ for qemu-devel@nongnu.org; Wed, 17 Aug 2016 05:32:53 -0400 Date: Wed, 17 Aug 2016 17:32:49 +0800 From: Peter Xu Message-ID: <20160817093249.GK14217@pxdev.xzpeter.org> 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> <874m6jpwys.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <874m6jpwys.fsf@dusky.pond.sub.org> 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: Markus Armbruster Cc: Marcel Apfelbaum , peter.maydell@linaro.org, pbonzini@redhat.com, fam@pxdev.xzpeter.org, qemu-devel@nongnu.org On Wed, Aug 17, 2016 at 11:26:51AM +0200, Markus Armbruster wrote: > 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. I see. Then let me keep them functions. Thanks, -- peterx