qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Eduardo Habkost" <ehabkost@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>,
	Eric Blake <eblake@redhat.com>,
	Peter Crosthwaite <crosthwaite.peter@gmail.com>,
	Markus Armbruster <armbru@redhat.com>,
	Laszlo Ersek <lersek@redhat.com>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	Gerd Hoffmann <kraxel@redhat.com>, Alexander Graf <agraf@suse.de>,
	David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [Qemu-devel] [PATCH 3/3] hw/core: report an error if invalid gpio is used
Date: Fri, 23 Jun 2017 16:47:22 -0300	[thread overview]
Message-ID: <20170623194722.GE3038@localhost.localdomain> (raw)
In-Reply-To: <20170623164557.11636-4-f4bug@amsat.org>

On Fri, Jun 23, 2017 at 01:45:57PM -0300, Philippe Mathieu-Daudé wrote:
> then abort calling error_setg()
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  hw/core/qdev.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index 849952a8d4..05aaa67cb8 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -448,7 +448,11 @@ qemu_irq qdev_get_gpio_in_named(DeviceState *dev, const char *name, int n)
>  {
>      NamedGPIOList *gpio_list = qdev_get_named_gpio_list(dev, name);
>  
> -    assert(n >= 0 && n < gpio_list->num_in);
> +    assert(n >= 0);
> +    if (n >= gpio_list->num_in) {
> +        error_setg(&error_abort, "Invalid gpio #%d (of %d) for %s",
> +                   n, gpio_list->num_in, name ? name : "device");

I just noticed error_setg() documentation explicitly discourages this.

"""
  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().
"""

-- 
Eduardo

  parent reply	other threads:[~2017-06-27  0:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-23 16:45 [Qemu-devel] [PATCH 0/3] hw/core: minor fixups Philippe Mathieu-Daudé
2017-06-23 16:45 ` [Qemu-devel] [PATCH 1/3] elf-loader: warn about invalid endianess Philippe Mathieu-Daudé
2017-06-23 17:11   ` Peter Maydell
2017-06-27 13:29   ` Michael Tokarev
2017-06-23 16:45 ` [Qemu-devel] [PATCH 2/3] hw/core: fix missing return value in load_image_targphys_as() Philippe Mathieu-Daudé
2017-06-26 22:36   ` Alistair Francis
2017-06-27 13:30   ` Michael Tokarev
2017-06-23 16:45 ` [Qemu-devel] [PATCH 3/3] hw/core: report an error if invalid gpio is used Philippe Mathieu-Daudé
2017-06-23 19:25   ` Eduardo Habkost
2017-06-27  1:33     ` Eric Blake
2017-06-23 19:47   ` Eduardo Habkost [this message]
2017-06-26 22:39   ` Alistair Francis
2017-06-23 19:45 ` [Qemu-devel] [PATCH 0/3] hw/core: minor fixups Eduardo Habkost
2017-06-27 12:16   ` Philippe Mathieu-Daudé
2017-06-23 20:09 ` Laszlo Ersek
2017-06-26 22:33 ` Alistair Francis

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=20170623194722.GE3038@localhost.localdomain \
    --to=ehabkost@redhat.com \
    --cc=agraf@suse.de \
    --cc=armbru@redhat.com \
    --cc=crosthwaite.peter@gmail.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=eblake@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=kraxel@redhat.com \
    --cc=lersek@redhat.com \
    --cc=mst@redhat.com \
    --cc=peter.maydell@linaro.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 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).