All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Alistair Francis <alistair.francis@xilinx.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Thomas Huth <thuth@redhat.com>,
	QEMU Trivial <qemu-trivial@nongnu.org>,
	"qemu-devel\@nongnu.org Developers" <qemu-devel@nongnu.org>,
	qemu-arm <qemu-arm@nongnu.org>
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH v6 04/29] hw/arm: Replace fprintf(stderr, "*\n" with error_report()
Date: Tue, 02 Jan 2018 13:59:26 +0100	[thread overview]
Message-ID: <87608k4dsh.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <CAKmqyKO5sKdiZJ65teDxa16PCE71WCLay7cOAQJQdyS-EVNOJg@mail.gmail.com> (Alistair Francis's message of "Fri, 22 Dec 2017 12:58:53 -0800")

Alistair Francis <alistair.francis@xilinx.com> writes:

> On Fri, Dec 22, 2017 at 12:30 PM, Markus Armbruster <armbru@redhat.com> wrote:
>> Alistair Francis <alistair.francis@xilinx.com> writes:
>>
>>> On Fri, Dec 22, 2017 at 9:17 AM, Thomas Huth <thuth@redhat.com> wrote:
>>>> On 22.12.2017 16:37, Markus Armbruster wrote:
>>>>> Second thoughts...
>>>>>
>>>>> Alistair Francis <alistair.francis@xilinx.com> writes:
>>>> [...]
>>>>>>  #include "qemu/osdep.h"
>>>>>> +#include "qemu/error-report.h"
>>>>>>  #include "qapi/error.h"
>>>>>>  #include "qemu-common.h"
>>>>>>  #include "cpu.h"
>>>>>> @@ -1311,8 +1312,8 @@ static void omap_prcm_apll_update(struct omap_prcm_s *s)
>>>>>>      /* TODO: update clocks */
>>>>>>
>>>>>>      if (mode[0] == 1 || mode[0] == 2 || mode[1] == 1 || mode[1] == 2)
>>>>>> -        fprintf(stderr, "%s: bad EN_54M_PLL or bad EN_96M_PLL\n",
>>>>>> -                        __func__);
>>>>>> +        error_report("%s: bad EN_54M_PLL or bad EN_96M_PLL",
>>>>>> +                     __func__);
>>>>>>  }
>>>>>
>>>>> This one's different: we neither exit() nor return a "failed" status to
>>>>> the caller.
>>>>>
>>>>> We get here when the guest writes something funny to a certain
>>>>> memory-mapped I/O register.  In other words, it's guest misbehavior, not
>>>>> a user error.  I doubt it should be reported with error_report().
>>>>> Peter, do we have a canonical way to report or log  guest misbehavior?
>>>>
>>>> qemu_log_mask(LOG_GUEST_ERROR, ...) ?
>>>
>>> That seems like the best option to me.
>>
>> Suggest:
>>
>> 1. Keep converting fatal errors (the ones that exit())
>>
>> 2. Keep converting recoverable errors (the ones that return failure)
>>
>> 3. You can leave the prints that are neither alone.  You can also
>>    convert to logging or tracing, as appropriate, but that requires
>>    understanding the code.
>>
>> Makes sense?
>
> Does this apply to new patches after this series or to this series as
> well? The series is mostly just mechanical find/replace. I really
> don't want to have to dig through every patch to figure out what to
> change/not change.

I understand your reluctance to sort patch hunks into buckets 1., 2. and
3. manually: there's an awful lot of hunks to sort.

We know we have many fprintf() that should be error_report(),
error_setg(), logging or tracing.

We know we have error_report() that should be error_setg().

Converting fprintf() to error_report() where we should really use
something else makes the situation worse, I'm afraid.

Since we need to sort, and sorting manually isn't practical, we need to
automate.

The patterns to recognize are 1. fprintf() followed by exit() and
2. fprintf() followed by return failure.

Recognizing the patterns when there's stuff between fprintf() and exit()
/ return may exceed sed's power.  Feels like a Coccinelle job to me.
Let's focus on the common case where exit() / return follows fprintf()
immediately.

Let's start with the easiest case: exit().  I figure that's still in
reach of your find + sed tooling.

Recognizing "return failure" is slightly harder, because error values
aren't always obvious.  Common ones are return NULL, return -1, return
-EFOO.

I hope that peeling off truly simple cases like this will reduce the
remaining hunks sufficiently to permit manual review.  If it doesn't, we
should still get a major part of your work without making the situation
worse.


WARNING: multiple messages have this Message-ID (diff)
From: Markus Armbruster <armbru@redhat.com>
To: Alistair Francis <alistair.francis@xilinx.com>
Cc: QEMU Trivial <qemu-trivial@nongnu.org>,
	Peter Maydell <peter.maydell@linaro.org>,
	Thomas Huth <thuth@redhat.com>, qemu-arm <qemu-arm@nongnu.org>,
	"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-arm] [Qemu-devel] [PATCH v6 04/29] hw/arm: Replace fprintf(stderr, "*\n" with error_report()
Date: Tue, 02 Jan 2018 13:59:26 +0100	[thread overview]
Message-ID: <87608k4dsh.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <CAKmqyKO5sKdiZJ65teDxa16PCE71WCLay7cOAQJQdyS-EVNOJg@mail.gmail.com> (Alistair Francis's message of "Fri, 22 Dec 2017 12:58:53 -0800")

Alistair Francis <alistair.francis@xilinx.com> writes:

> On Fri, Dec 22, 2017 at 12:30 PM, Markus Armbruster <armbru@redhat.com> wrote:
>> Alistair Francis <alistair.francis@xilinx.com> writes:
>>
>>> On Fri, Dec 22, 2017 at 9:17 AM, Thomas Huth <thuth@redhat.com> wrote:
>>>> On 22.12.2017 16:37, Markus Armbruster wrote:
>>>>> Second thoughts...
>>>>>
>>>>> Alistair Francis <alistair.francis@xilinx.com> writes:
>>>> [...]
>>>>>>  #include "qemu/osdep.h"
>>>>>> +#include "qemu/error-report.h"
>>>>>>  #include "qapi/error.h"
>>>>>>  #include "qemu-common.h"
>>>>>>  #include "cpu.h"
>>>>>> @@ -1311,8 +1312,8 @@ static void omap_prcm_apll_update(struct omap_prcm_s *s)
>>>>>>      /* TODO: update clocks */
>>>>>>
>>>>>>      if (mode[0] == 1 || mode[0] == 2 || mode[1] == 1 || mode[1] == 2)
>>>>>> -        fprintf(stderr, "%s: bad EN_54M_PLL or bad EN_96M_PLL\n",
>>>>>> -                        __func__);
>>>>>> +        error_report("%s: bad EN_54M_PLL or bad EN_96M_PLL",
>>>>>> +                     __func__);
>>>>>>  }
>>>>>
>>>>> This one's different: we neither exit() nor return a "failed" status to
>>>>> the caller.
>>>>>
>>>>> We get here when the guest writes something funny to a certain
>>>>> memory-mapped I/O register.  In other words, it's guest misbehavior, not
>>>>> a user error.  I doubt it should be reported with error_report().
>>>>> Peter, do we have a canonical way to report or log  guest misbehavior?
>>>>
>>>> qemu_log_mask(LOG_GUEST_ERROR, ...) ?
>>>
>>> That seems like the best option to me.
>>
>> Suggest:
>>
>> 1. Keep converting fatal errors (the ones that exit())
>>
>> 2. Keep converting recoverable errors (the ones that return failure)
>>
>> 3. You can leave the prints that are neither alone.  You can also
>>    convert to logging or tracing, as appropriate, but that requires
>>    understanding the code.
>>
>> Makes sense?
>
> Does this apply to new patches after this series or to this series as
> well? The series is mostly just mechanical find/replace. I really
> don't want to have to dig through every patch to figure out what to
> change/not change.

I understand your reluctance to sort patch hunks into buckets 1., 2. and
3. manually: there's an awful lot of hunks to sort.

We know we have many fprintf() that should be error_report(),
error_setg(), logging or tracing.

We know we have error_report() that should be error_setg().

Converting fprintf() to error_report() where we should really use
something else makes the situation worse, I'm afraid.

Since we need to sort, and sorting manually isn't practical, we need to
automate.

The patterns to recognize are 1. fprintf() followed by exit() and
2. fprintf() followed by return failure.

Recognizing the patterns when there's stuff between fprintf() and exit()
/ return may exceed sed's power.  Feels like a Coccinelle job to me.
Let's focus on the common case where exit() / return follows fprintf()
immediately.

Let's start with the easiest case: exit().  I figure that's still in
reach of your find + sed tooling.

Recognizing "return failure" is slightly harder, because error values
aren't always obvious.  Common ones are return NULL, return -1, return
-EFOO.

I hope that peeling off truly simple cases like this will reduce the
remaining hunks sufficiently to permit manual review.  If it doesn't, we
should still get a major part of your work without making the situation
worse.

WARNING: multiple messages have this Message-ID (diff)
From: Markus Armbruster <armbru@redhat.com>
To: Alistair Francis <alistair.francis@xilinx.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Thomas Huth <thuth@redhat.com>,
	QEMU Trivial <qemu-trivial@nongnu.org>,
	"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
	qemu-arm <qemu-arm@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v6 04/29] hw/arm: Replace fprintf(stderr, "*\n" with error_report()
Date: Tue, 02 Jan 2018 13:59:26 +0100	[thread overview]
Message-ID: <87608k4dsh.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <CAKmqyKO5sKdiZJ65teDxa16PCE71WCLay7cOAQJQdyS-EVNOJg@mail.gmail.com> (Alistair Francis's message of "Fri, 22 Dec 2017 12:58:53 -0800")

Alistair Francis <alistair.francis@xilinx.com> writes:

> On Fri, Dec 22, 2017 at 12:30 PM, Markus Armbruster <armbru@redhat.com> wrote:
>> Alistair Francis <alistair.francis@xilinx.com> writes:
>>
>>> On Fri, Dec 22, 2017 at 9:17 AM, Thomas Huth <thuth@redhat.com> wrote:
>>>> On 22.12.2017 16:37, Markus Armbruster wrote:
>>>>> Second thoughts...
>>>>>
>>>>> Alistair Francis <alistair.francis@xilinx.com> writes:
>>>> [...]
>>>>>>  #include "qemu/osdep.h"
>>>>>> +#include "qemu/error-report.h"
>>>>>>  #include "qapi/error.h"
>>>>>>  #include "qemu-common.h"
>>>>>>  #include "cpu.h"
>>>>>> @@ -1311,8 +1312,8 @@ static void omap_prcm_apll_update(struct omap_prcm_s *s)
>>>>>>      /* TODO: update clocks */
>>>>>>
>>>>>>      if (mode[0] == 1 || mode[0] == 2 || mode[1] == 1 || mode[1] == 2)
>>>>>> -        fprintf(stderr, "%s: bad EN_54M_PLL or bad EN_96M_PLL\n",
>>>>>> -                        __func__);
>>>>>> +        error_report("%s: bad EN_54M_PLL or bad EN_96M_PLL",
>>>>>> +                     __func__);
>>>>>>  }
>>>>>
>>>>> This one's different: we neither exit() nor return a "failed" status to
>>>>> the caller.
>>>>>
>>>>> We get here when the guest writes something funny to a certain
>>>>> memory-mapped I/O register.  In other words, it's guest misbehavior, not
>>>>> a user error.  I doubt it should be reported with error_report().
>>>>> Peter, do we have a canonical way to report or log  guest misbehavior?
>>>>
>>>> qemu_log_mask(LOG_GUEST_ERROR, ...) ?
>>>
>>> That seems like the best option to me.
>>
>> Suggest:
>>
>> 1. Keep converting fatal errors (the ones that exit())
>>
>> 2. Keep converting recoverable errors (the ones that return failure)
>>
>> 3. You can leave the prints that are neither alone.  You can also
>>    convert to logging or tracing, as appropriate, but that requires
>>    understanding the code.
>>
>> Makes sense?
>
> Does this apply to new patches after this series or to this series as
> well? The series is mostly just mechanical find/replace. I really
> don't want to have to dig through every patch to figure out what to
> change/not change.

I understand your reluctance to sort patch hunks into buckets 1., 2. and
3. manually: there's an awful lot of hunks to sort.

We know we have many fprintf() that should be error_report(),
error_setg(), logging or tracing.

We know we have error_report() that should be error_setg().

Converting fprintf() to error_report() where we should really use
something else makes the situation worse, I'm afraid.

Since we need to sort, and sorting manually isn't practical, we need to
automate.

The patterns to recognize are 1. fprintf() followed by exit() and
2. fprintf() followed by return failure.

Recognizing the patterns when there's stuff between fprintf() and exit()
/ return may exceed sed's power.  Feels like a Coccinelle job to me.
Let's focus on the common case where exit() / return follows fprintf()
immediately.

Let's start with the easiest case: exit().  I figure that's still in
reach of your find + sed tooling.

Recognizing "return failure" is slightly harder, because error values
aren't always obvious.  Common ones are return NULL, return -1, return
-EFOO.

I hope that peeling off truly simple cases like this will reduce the
remaining hunks sufficiently to permit manual review.  If it doesn't, we
should still get a major part of your work without making the situation
worse.

  reply	other threads:[~2018-01-02 12:59 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-20 17:22 [Qemu-trivial] [PATCH v6 00/29] Remove some of the fprintf(stderr, "* Alistair Francis
2017-12-20 17:22 ` [Qemu-devel] " Alistair Francis
2017-12-20 17:22 ` [Qemu-trivial] [PATCH v6 01/29] audio: Replace AUDIO_FUNC with __func__ Alistair Francis
2017-12-20 17:22   ` [Qemu-devel] " Alistair Francis
2017-12-20 17:22 ` [Qemu-trivial] [PATCH v6 02/29] Replace all occurances of __FUNCTION__ " Alistair Francis
2017-12-20 17:22   ` [Qemu-devel] " Alistair Francis
2017-12-20 17:22   ` Alistair Francis
2017-12-20 17:22   ` [Qemu-arm] " Alistair Francis
2017-12-20 17:22 ` [Qemu-trivial] [PATCH v6 03/29] Fixes after renaming __FUNCTION__ to __func__ Alistair Francis
2017-12-20 17:22   ` [Qemu-devel] " Alistair Francis
2017-12-20 17:23 ` [Qemu-trivial] [PATCH v6 04/29] hw/arm: Replace fprintf(stderr, "*\n" with error_report() Alistair Francis
2017-12-20 17:23   ` [Qemu-devel] " Alistair Francis
2017-12-20 17:23   ` [Qemu-arm] " Alistair Francis
2017-12-22 15:21   ` [Qemu-trivial] [Qemu-devel] " Markus Armbruster
2017-12-22 15:21     ` Markus Armbruster
2017-12-22 15:21     ` [Qemu-arm] " Markus Armbruster
2017-12-22 15:37   ` [Qemu-trivial] " Markus Armbruster
2017-12-22 15:37     ` Markus Armbruster
2017-12-22 15:37     ` [Qemu-arm] " Markus Armbruster
2017-12-22 17:17     ` [Qemu-trivial] " Thomas Huth
2017-12-22 17:17       ` Thomas Huth
2017-12-22 17:17       ` [Qemu-arm] " Thomas Huth
2017-12-22 19:57       ` [Qemu-trivial] " Alistair Francis
2017-12-22 19:57         ` Alistair Francis
2017-12-22 19:57         ` [Qemu-arm] " Alistair Francis
2017-12-22 20:30         ` [Qemu-trivial] " Markus Armbruster
2017-12-22 20:30           ` Markus Armbruster
2017-12-22 20:30           ` [Qemu-arm] " Markus Armbruster
2017-12-22 20:58           ` [Qemu-trivial] " Alistair Francis
2017-12-22 20:58             ` Alistair Francis
2017-12-22 20:58             ` [Qemu-arm] " Alistair Francis
2018-01-02 12:59             ` Markus Armbruster [this message]
2018-01-02 12:59               ` Markus Armbruster
2018-01-02 12:59               ` [Qemu-arm] " Markus Armbruster
2018-01-09  0:32               ` [Qemu-trivial] " Alistair Francis
2018-01-09  0:32                 ` Alistair Francis
2018-01-09  0:32                 ` Alistair Francis
2018-01-09 15:31                 ` [Qemu-trivial] " Thomas Huth
2018-01-09 15:31                   ` Thomas Huth
2018-01-09 15:31                   ` [Qemu-arm] " Thomas Huth
2017-12-20 17:23 ` [Qemu-trivial] [PATCH v6 05/29] hw/dma: " Alistair Francis
2017-12-20 17:23   ` [Qemu-devel] " Alistair Francis
2017-12-22 15:21   ` [Qemu-trivial] " Markus Armbruster
2017-12-22 15:21     ` Markus Armbruster
2017-12-20 17:23 ` [Qemu-trivial] [PATCH v6 06/29] hw/gpio: " Alistair Francis
2017-12-20 17:23   ` [Qemu-devel] " Alistair Francis
2017-12-20 17:23 ` [Qemu-trivial] [PATCH v6 07/29] hw/i2c: " Alistair Francis
2017-12-20 17:23   ` [Qemu-devel] " Alistair Francis
2017-12-20 17:23 ` [Qemu-trivial] [PATCH v6 09/29] hw/ide: " Alistair Francis
2017-12-20 17:23   ` [Qemu-devel] " Alistair Francis
2017-12-20 17:23 ` [Qemu-trivial] [PATCH v6 10/29] hw/intc: " Alistair Francis
2017-12-20 17:23   ` [Qemu-devel] " Alistair Francis
2017-12-20 17:23 ` [Qemu-trivial] [PATCH v6 11/29] hw/ipmi: " Alistair Francis
2017-12-20 17:23   ` [Qemu-devel] " Alistair Francis
2017-12-20 17:23 ` [Qemu-trivial] [PATCH v6 12/29] hw/isa: " Alistair Francis
2017-12-20 17:23   ` [Qemu-devel] " Alistair Francis
2017-12-20 17:24 ` [Qemu-trivial] [PATCH v6 13/29] hw/lm32: " Alistair Francis
2017-12-20 17:24   ` [Qemu-devel] " Alistair Francis
2017-12-20 17:24 ` [Qemu-trivial] [PATCH v6 14/29] hw/mips: " Alistair Francis
2017-12-20 17:24   ` [Qemu-devel] " Alistair Francis
2017-12-20 17:24 ` [Qemu-trivial] [PATCH v6 15/29] hw/moxie: " Alistair Francis
2017-12-20 17:24   ` [Qemu-devel] " Alistair Francis
2017-12-20 17:24 ` [Qemu-trivial] [PATCH v6 16/29] hw/nios2: " Alistair Francis
2017-12-20 17:24   ` [Qemu-devel] " Alistair Francis
2017-12-20 17:24 ` [Qemu-trivial] [PATCH v6 17/29] hw/nvram: " Alistair Francis
2017-12-20 17:24   ` [Qemu-devel] " Alistair Francis
2017-12-20 17:24 ` [Qemu-trivial] [PATCH v6 18/29] hw/openrisc: " Alistair Francis
2017-12-20 17:24   ` [Qemu-devel] " Alistair Francis
2017-12-20 17:24 ` [Qemu-trivial] [PATCH v6 19/29] hw/pci*: " Alistair Francis
2017-12-20 17:24   ` [Qemu-devel] " Alistair Francis
2017-12-20 17:24 ` [Qemu-trivial] [PATCH v6 20/29] hw/ppc: " Alistair Francis
2017-12-20 17:24   ` [Qemu-devel] " Alistair Francis
2017-12-20 17:24 ` [Qemu-trivial] [PATCH v6 21/29] hw/s390x: " Alistair Francis
2017-12-20 17:24   ` [Qemu-devel] " Alistair Francis
2018-01-09 17:45   ` [Qemu-trivial] " Cornelia Huck
2018-01-09 17:45     ` Cornelia Huck
2018-01-09 18:09     ` [Qemu-trivial] " Alistair Francis
2018-01-09 18:09       ` Alistair Francis
2017-12-20 17:24 ` [Qemu-trivial] [PATCH v6 23/29] hw/sd: " Alistair Francis
2017-12-20 17:24   ` [Qemu-devel] " Alistair Francis
2017-12-20 17:24 ` [Qemu-trivial] [PATCH v6 24/29] hw/sparc*: " Alistair Francis
2017-12-20 17:24   ` [Qemu-devel] " Alistair Francis
2017-12-20 17:24 ` [Qemu-trivial] [PATCH v6 25/29] hw/ssi: " Alistair Francis
2017-12-20 17:24   ` [Qemu-devel] " Alistair Francis
2017-12-20 17:24 ` [Qemu-trivial] [PATCH v6 26/29] hw/timer: " Alistair Francis
2017-12-20 17:24   ` [Qemu-devel] " Alistair Francis
2017-12-20 17:25 ` [Qemu-trivial] [PATCH v6 27/29] hw/xen*: " Alistair Francis
2017-12-20 17:25   ` [Qemu-devel] " Alistair Francis
2017-12-20 17:25 ` [Qemu-trivial] [PATCH v6 28/29] tcg: " Alistair Francis
2017-12-20 17:25   ` [Qemu-devel] " Alistair Francis
2017-12-20 17:25 ` [Qemu-trivial] [PATCH v6 29/29] target: Use qemu_log() instead of fprintf(stderr, ...) Alistair Francis
2017-12-20 17:25   ` [Qemu-devel] " Alistair Francis
     [not found] ` <97bff6488fbc4c6b2c10879798aa149a43426fd9.1513790495.git.alistair.francis@xilinx.com>
2017-12-20 22:10   ` [Qemu-trivial] [PATCH v6 08/29] hw/i386: Replace fprintf(stderr, "*\n" with error_report() Eduardo Habkost
2017-12-20 22:10     ` [Qemu-devel] " Eduardo Habkost

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=87608k4dsh.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=alistair.francis@xilinx.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=thuth@redhat.com \
    /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.