qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>,
	Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org, "Thomas Huth" <thuth@redhat.com>,
	qemu-s390x@nongnu.org, qemu-ppc@nongnu.org,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Helge Deller" <deller@gmx.de>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Eduardo Habkost" <eduardo@habkost.net>,
	"Laurent Vivier" <laurent@vivier.eu>,
	"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
	"Cédric Le Goater" <clg@kaod.org>,
	"Nicholas Piggin" <npiggin@gmail.com>,
	"Frédéric Barrat" <fbarrat@linux.ibm.com>,
	"Daniel Henrique Barboza" <danielhb413@gmail.com>,
	"David Gibson" <david@gibson.dropbear.id.au>,
	"Harsh Prateek Bora" <harshpb@linux.ibm.com>,
	"Halil Pasic" <pasic@linux.ibm.com>,
	"Eric Farman" <farman@linux.ibm.com>,
	"David Hildenbrand" <david@redhat.com>,
	"Ilya Leoshkevich" <iii@linux.ibm.com>
Subject: Re: [PATCH 3/4] hw/nmi: Remove @cpu_index argument from NMIClass::nmi_handler()
Date: Wed, 20 Mar 2024 17:47:14 +0100	[thread overview]
Message-ID: <52f35af0-4b18-48c8-8e18-aa7b01f53848@linaro.org> (raw)
In-Reply-To: <CAFEAcA9kVkM16paZQfH1voNNjWRT3DmchepiMs045w+YA61Fzw@mail.gmail.com>

On 20/3/24 14:23, Peter Maydell wrote:
> On Tue, 20 Feb 2024 at 15:09, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>>
>> Only s390x was using the 'cpu_index' argument, but since the
>> previous commit it isn't anymore (it use the first cpu).
>> Since this argument is now completely unused, remove it. Have
>> the callback return a boolean indicating failure.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   include/hw/nmi.h           | 11 ++++++++++-
>>   hw/core/nmi.c              |  3 +--
>>   hw/hppa/machine.c          |  8 +++++---
>>   hw/i386/x86.c              |  7 ++++---
>>   hw/intc/m68k_irqc.c        |  6 ++++--
>>   hw/m68k/q800-glue.c        |  6 ++++--
>>   hw/misc/macio/gpio.c       |  6 ++++--
>>   hw/ppc/pnv.c               |  6 ++++--
>>   hw/ppc/spapr.c             |  6 ++++--
>>   hw/s390x/s390-virtio-ccw.c |  6 ++++--
>>   10 files changed, 44 insertions(+), 21 deletions(-)
>>
>> diff --git a/include/hw/nmi.h b/include/hw/nmi.h
>> index fff41bebc6..c70db941c9 100644
>> --- a/include/hw/nmi.h
>> +++ b/include/hw/nmi.h
>> @@ -37,7 +37,16 @@ typedef struct NMIState NMIState;
>>   struct NMIClass {
>>       InterfaceClass parent_class;
>>
>> -    void (*nmi_monitor_handler)(NMIState *n, int cpu_index, Error **errp);
>> +    /**
>> +     * nmi_handler: Callback to handle NMI notifications.
>> +     *
>> +     * @n: Class #NMIState state
>> +     * @errp: pointer to error object
>> +     *
>> +     * On success, return %true.
>> +     * On failure, store an error through @errp and return %false.
>> +     */
>> +    bool (*nmi_handler)(NMIState *n, Error **errp);
> 
> Any particular reason to change the method name here?
> 
> Do we really need to indicate failure both through the bool return
> and the Error** ?

No, but this is the style *recommended* by the Error API since
commit e3fe3988d7 ("error: Document Error API usage rules"):

     error: Document Error API usage rules

     This merely codifies existing practice, with one exception: the rule
     advising against returning void, where existing practice is mixed.

     When the Error API was created, we adopted the (unwritten) rule to
     return void when the function returns no useful value on success,
     unlike GError, which recommends to return true on success and false
     on error then.

     [...]

     Make the rule advising against returning void official by putting it
     in writing.  This will hopefully reduce confusion.

   * - Whenever practical, also return a value that indicates success /
   *   failure.  This can make the error checking more concise, and can
   *   avoid useless error object creation and destruction.  Note that
   *   we still have many functions returning void.  We recommend
   *   • bool-valued functions return true on success / false on failure,
   *   • pointer-valued functions return non-null / null pointer, and
   *   • integer-valued functions return non-negative / negative.

Anyway I'll respin removing @cpu_index as a single change :)


  reply	other threads:[~2024-03-20 16:47 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-20 15:08 [PATCH 0/4] hw/nmi: Remove @cpu_index argument Philippe Mathieu-Daudé
2024-02-20 15:08 ` [PATCH 1/4] hw/nmi: Use object_child_foreach_recursive() in nmi_children() Philippe Mathieu-Daudé
2024-03-20 13:09   ` Peter Maydell
2024-02-20 15:08 ` [PATCH 2/4] hw/s390x/virtio-ccw: Always deliver NMI to first CPU Philippe Mathieu-Daudé
2024-03-20 13:16   ` Peter Maydell
2024-03-20 14:12   ` David Hildenbrand
2024-02-20 15:08 ` [PATCH 3/4] hw/nmi: Remove @cpu_index argument from NMIClass::nmi_handler() Philippe Mathieu-Daudé
2024-03-20 13:23   ` Peter Maydell
2024-03-20 16:47     ` Philippe Mathieu-Daudé [this message]
2024-03-20 19:05       ` Markus Armbruster
2024-03-20 19:39         ` Peter Maydell
2024-02-20 15:08 ` [PATCH 4/4] hw/nmi: Remove @cpu_index argument from nmi_trigger() Philippe Mathieu-Daudé
2024-03-20 13:34   ` Peter Maydell
2024-02-20 15:19 ` [PATCH 0/4] hw/nmi: Remove @cpu_index argument Thomas Huth
2024-02-20 20:05   ` Philippe Mathieu-Daudé
2024-03-20 11:19   ` Philippe Mathieu-Daudé
2024-03-20 11:44     ` Mark Burton
2024-03-20 12:00     ` Peter Maydell
2024-03-20 12:31       ` Mark Burton
2024-03-20 13:55         ` Peter Maydell
2024-03-20 14:09           ` Mark Burton
2024-03-20 15:00             ` Peter Maydell
2024-03-20 15:40               ` Mark Burton
2024-03-22 14:08               ` Cédric Le Goater
2024-03-22 14:55                 ` Peter Maydell

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=52f35af0-4b18-48c8-8e18-aa7b01f53848@linaro.org \
    --to=philmd@linaro.org \
    --cc=armbru@redhat.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=clg@kaod.org \
    --cc=danielhb413@gmail.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=david@redhat.com \
    --cc=deller@gmx.de \
    --cc=eduardo@habkost.net \
    --cc=farman@linux.ibm.com \
    --cc=fbarrat@linux.ibm.com \
    --cc=harshpb@linux.ibm.com \
    --cc=iii@linux.ibm.com \
    --cc=laurent@vivier.eu \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=mst@redhat.com \
    --cc=npiggin@gmail.com \
    --cc=pasic@linux.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=richard.henderson@linaro.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 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).