On Wed, Aug 17, 2016 at 11:26:51AM +0200, Markus Armbruster wrote: > Peter Xu <pet...@redhat.com> 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