From: Thomas Huth <thuth@redhat.com>
To: "Markus Armbruster" <armbru@redhat.com>,
"Lluís Vilanova" <vilanova@ac.upc.edu>
Cc: Stefan Hajnoczi <stefanha@gmail.com>,
qemu-devel@nongnu.org,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [Qemu-devel] [PATCH v6 1/5] util: Introduce error reporting functions with fatal/abort
Date: Wed, 3 Feb 2016 10:58:52 +0100 [thread overview]
Message-ID: <56B1CF5C.7040007@redhat.com> (raw)
In-Reply-To: <87bn7yxgxm.fsf@blackfin.pond.sub.org>
On 03.02.2016 10:48, Markus Armbruster wrote:
> David Gibson <david@gibson.dropbear.id.au> writes:
>
>> On Tue, Feb 02, 2016 at 10:47:35PM +0100, Thomas Huth wrote:
>>> On 02.02.2016 19:53, Markus Armbruster wrote:
>>>> Lluís Vilanova <vilanova@ac.upc.edu> writes:
>>> ...
>>>
>>>>> diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h
>>>>> index 7ab2355..6c2f142 100644
>>>>> --- a/include/qemu/error-report.h
>>>>> +++ b/include/qemu/error-report.h
>>>>> @@ -43,4 +43,23 @@ void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
>>>>> const char *error_get_progname(void);
>>>>> extern bool enable_timestamp_msg;
>>>>>
>>>>> +/* Report message and exit with error */
>>>>> +void QEMU_NORETURN error_vreport_fatal(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0);
>>>>> +void QEMU_NORETURN error_report_fatal(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
>>>>
>>>> This lets people write things like
>>>>
>>>> error_report_fatal("The sky is falling");
>>>>
>>>> instead of
>>>>
>>>> error_report("The sky is falling");
>>>> exit(1);
>>>>
>>>> or
>>>>
>>>> fprintf(stderr, "The sky is falling\n");
>>>> exit(1);
>>>>
>>>> I don't think that's an improvement in clarity.
>>>
>>> The problem is not the existing code, but that in a couple of new
>>> patches, I've now already seen that people are trying to use
>>>
>>> error_setg(&error_fatal, ... );
>>
>> So, I don't actually see any real advantage to error_report_fatal(...)
>> over error_setg(&error_fatal, ...).
>
> I do. Compare:
>
> (a) error_report(...);
> exit(1);
>
> (b) error_report_fatal(...);
>
> (c) error_setg(&error_fatal, ...);
>
> In my opinion, (a) is clearest: even a relatively clueless reader will
> know what exit(1) does, can guess what error_report() approximately
> does, and doesn't need to know what it does exactly. (b) is slightly
> less obvious, and (c) is positively opaque.
>
> Let's stick to the obvious (a) and be done with it.
Ok, (a) is fine for me too, as long as we avoid (c). Lluís, could you
maybe add that information to your patch that updates the HACKING text?
(and sorry for the fuzz with error_report_fatal() ... I thought it would
be a good solution to avoid (c), but if (a) is preferred instead, then
we should go with that solution instead).
And, by the way, what about the spots that currently already use
error_setg(&error_abort, ....) ? Should they be turned into
error_report() + abort() instead? Or only abort(), without error
message, since abort() is only about programming errors?
Thomas
next prev parent reply other threads:[~2016-02-03 9:59 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-02 16:13 [Qemu-devel] [RFC][PATCH v6 0/5] utils: Improve and document error reporting Lluís Vilanova
2016-02-02 16:13 ` [Qemu-devel] [PATCH v6 1/5] util: Introduce error reporting functions with fatal/abort Lluís Vilanova
2016-02-02 18:53 ` Markus Armbruster
2016-02-02 21:47 ` Thomas Huth
2016-02-03 5:04 ` David Gibson
2016-02-03 9:48 ` Markus Armbruster
2016-02-03 9:58 ` Thomas Huth [this message]
2016-02-03 10:38 ` Markus Armbruster
2016-02-03 13:42 ` Lluís Vilanova
2016-02-03 14:34 ` Markus Armbruster
2016-02-03 15:11 ` Lluís Vilanova
2016-02-03 18:06 ` Markus Armbruster
2016-02-03 22:23 ` David Gibson
2016-02-03 7:26 ` Markus Armbruster
2016-02-03 17:59 ` Lluís Vilanova
2016-02-02 16:14 ` [Qemu-devel] [PATCH v6 2/5] util: Use new error_report_fatal/abort instead of error_setg(&error_fatal/abort) Lluís Vilanova
2016-02-02 20:16 ` John Snow
2016-02-02 16:14 ` [Qemu-devel] [PATCH v6 3/5] util: [ppc] Use new error_report_fatal() instead of exit() Lluís Vilanova
2016-02-02 16:14 ` [Qemu-devel] [PATCH v6 4/5] util: [ppc] Use new error_report_abort() instead of abort() Lluís Vilanova
2016-02-02 19:34 ` Eric Blake
2016-02-03 5:06 ` David Gibson
2016-02-02 16:14 ` [Qemu-devel] [PATCH v6 5/5] doc: Introduce coding style for errors Lluís Vilanova
2016-02-02 19:10 ` Markus Armbruster
2016-02-03 13:47 ` Lluís Vilanova
2016-02-03 14:41 ` Markus Armbruster
2016-02-03 15:17 ` Lluís Vilanova
2016-02-03 15:53 ` Markus Armbruster
2016-02-03 16:58 ` Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56B1CF5C.7040007@redhat.com \
--to=thuth@redhat.com \
--cc=armbru@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=dgilbert@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
--cc=vilanova@ac.upc.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).