qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/2] error-report: provide error_report_exit()


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH 1/2] error-report: provide error_report_exit()
Date: Wed, 17 Aug 2016 11:26:51 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Peter Xu <address@hidden> 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]