All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: John Snow <jsnow@redhat.com>, Eric Blake <eblake@redhat.com>,
	Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/4] hw/block/fdc: Replace error_setg(&error_abort) by error_report() + abort()
Date: Thu, 07 Jun 2018 15:41:35 +0200	[thread overview]
Message-ID: <87po12vhm8.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <5374cfa5-e314-0c4f-92e9-b3ec3bf3bd95@amsat.org> ("Philippe Mathieu-Daudé"'s message of "Wed, 30 May 2018 18:30:58 -0300")

Philippe Mathieu-Daudé <f4bug@amsat.org> writes:

> On 05/30/2018 05:23 PM, John Snow wrote:
>> On 05/29/2018 01:48 PM, Philippe Mathieu-Daudé wrote:
>>> Use error_report() + abort() instead of error_setg(&error_abort),
>>> as suggested by the "qapi/error.h" documentation:
>>>
>>>     Please don't error_setg(&error_fatal, ...), use error_report() and
>>>     exit(), because that's more obvious.
>>>     Likewise, don't error_setg(&error_abort, ...), use assert().
>>>
>> 
>> Didn't realize this was bad form (Why do we have it?)

Because &error_abort has other uses, and I can't see how we can get rid
of just error_setg(&error_abort, ...).  Open to ideas.

>>> Use abort() instead of the suggested assert() because the error message
>>> already got displayed.
>>>
>> 
>> Update the suggestion?
>
> Fair enough.

No.  I intentionally pointed to assert(), because ...

>>> Suggested-by: Eric Blake <eblake@redhat.com>
>>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> 
>> Reviewed-by: John Snow <jsnow@redhat.com>
>> Acked-by: John Snow <jsnow@redhat.com>
>
> Thanks!
>
>>> ---
>>>  hw/block/fdc.c | 7 ++++---
>>>  1 file changed, 4 insertions(+), 3 deletions(-)
>>> 
>>> diff --git a/hw/block/fdc.c b/hw/block/fdc.c
>>> index cd29e27d8f..048467c00b 100644
>>> --- a/hw/block/fdc.c
>>> +++ b/hw/block/fdc.c
>>> @@ -401,9 +401,10 @@ static int pick_geometry(FDrive *drv)
>>>  
>>>      /* No match of any kind found -- fd_format is misconfigured, abort. */
>>>      if (match == -1) {
>>> -        error_setg(&error_abort, "No candidate geometries present in table "
>>> -                   " for floppy drive type '%s'",
>>> -                   FloppyDriveType_str(drv->drive));
>>> +        error_report("No candidate geometries present in table "
>>> +                     " for floppy drive type '%s'",
>>> +                     FloppyDriveType_str(drv->drive));
>>> +        abort();

... no matter how "nice" you make the message before an abort, it's
still an abort.  It should not happen (or else aborting would be wrong),
and when it does, somebody will have to stare at the code anyway.  I
recommend not to bother with niceties there.

Pig:

    hw/block/fdc.c:403:pick_geometry: assertion failed: (match != -1)
    Aborted (core dumped)

Pig with lipstick on:

    No candidate geometries present in table for floppy drive type 'FOO'
    Aborted (core dumped)

Now, if you're really, really into lipstick: to each his own.  But
please return the courtesy and keep it out of the stuff I maintain :)

>>>      }
>>>  
>>>      parse = &(fd_formats[match]);
>>> -- 
>>> 2.17.0

  reply	other threads:[~2018-06-07 13:41 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-29 17:48 [Qemu-devel] [PATCH 0/4] qapi/error: converts error_setg(&error_fatal) to error_report() + exit() Philippe Mathieu-Daudé
2018-05-29 17:48 ` Philippe Mathieu-Daudé
2018-05-29 17:48 ` [Qemu-devel] [PATCH 1/4] hw/block/fdc: Replace error_setg(&error_abort) by error_report() + abort() Philippe Mathieu-Daudé
2018-05-30 20:23   ` John Snow
2018-05-30 21:30     ` Philippe Mathieu-Daudé
2018-06-07 13:41       ` Markus Armbruster [this message]
2018-06-07 14:27         ` Philippe Mathieu-Daudé
2018-05-29 17:48 ` [Qemu-devel] [PATCH 2/4] hw/ppc/spapr_drc: " Philippe Mathieu-Daudé
2018-06-04  1:25   ` David Gibson
2018-05-29 17:48 ` [Qemu-arm] [PATCH 3/4] hw/arm/sysbus-fdt: Replace error_setg(&error_fatal) by error_report() + exit() Philippe Mathieu-Daudé
2018-05-29 17:48   ` [Qemu-devel] " Philippe Mathieu-Daudé
2018-06-07 13:53   ` [Qemu-arm] " Markus Armbruster
2018-06-07 13:53     ` Markus Armbruster
2018-05-29 17:48 ` [Qemu-devel] [PATCH 4/4] device_tree: " Philippe Mathieu-Daudé
2018-06-07 13:50   ` Markus Armbruster
2018-05-29 19:38 ` [Qemu-devel] [PATCH 0/4] qapi/error: converts error_setg(&error_fatal) to " Auger Eric
2018-05-29 19:38   ` Auger Eric
2018-06-07 13:48 ` [Qemu-arm] " Markus Armbruster
2018-06-07 13:48   ` Markus Armbruster
2018-06-07 14:49   ` [Qemu-arm] " Philippe Mathieu-Daudé
2018-06-07 14:49     ` [Qemu-devel] [Qemu-arm] " Philippe Mathieu-Daudé

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=87po12vhm8.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.