All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: qemu-trivial@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
	Cam Macdonell <cam@cs.ualberta.ca>,
	qemu-devel@nongnu.org, qemu-stable@nongnu.org
Subject: Re: [Qemu-trivial] [PATCH v2 2/2] ivshmem: add missing error exit(2)
Date: Mon, 03 Jun 2013 06:26:22 -0600	[thread overview]
Message-ID: <51AC8B6E.9040002@redhat.com> (raw)
In-Reply-To: <1370249911-19708-3-git-send-email-stefanha@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1367 bytes --]

On 06/03/2013 02:58 AM, Stefan Hajnoczi wrote:
> If the user fails to specify 'chardev' or 'shm' then we cannot continue.
> Exit right away so that we don't invoke shm_open(3) with a NULL pointer.
> 
> It would be nice to replace exit(1) with error returns in the PCI device
> .init() function, but leave that for another patch since exit(1) is
> currently used elsewhere.
> 
> Spotted by Coverity.
> 
> Cc: Cam Macdonell <cam@cs.ualberta.ca>
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  hw/misc/ivshmem.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
> index a19a6d6..5658f73 100644
> --- a/hw/misc/ivshmem.c
> +++ b/hw/misc/ivshmem.c
> @@ -735,6 +735,7 @@ static int pci_ivshmem_init(PCIDevice *dev)
>  
>          if (s->shmobj == NULL) {
>              fprintf(stderr, "Must specify 'chardev' or 'shm' to ivshmem\n");
> +            exit(1);

Reviewed-by: Eric Blake <eblake@redhat.com>

However, I prefer exit(EXIT_FAILURE) rather than exit(1), to make it a
bit easier to grep for known failure exits.  Libvirt has a syntax
checker (taken from gnulib) that enforces such a style, if qemu would
like to adopt that style.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Eric Blake <eblake@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: qemu-trivial@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
	Cam Macdonell <cam@cs.ualberta.ca>,
	qemu-devel@nongnu.org, qemu-stable@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 2/2] ivshmem: add missing error exit(2)
Date: Mon, 03 Jun 2013 06:26:22 -0600	[thread overview]
Message-ID: <51AC8B6E.9040002@redhat.com> (raw)
In-Reply-To: <1370249911-19708-3-git-send-email-stefanha@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1367 bytes --]

On 06/03/2013 02:58 AM, Stefan Hajnoczi wrote:
> If the user fails to specify 'chardev' or 'shm' then we cannot continue.
> Exit right away so that we don't invoke shm_open(3) with a NULL pointer.
> 
> It would be nice to replace exit(1) with error returns in the PCI device
> .init() function, but leave that for another patch since exit(1) is
> currently used elsewhere.
> 
> Spotted by Coverity.
> 
> Cc: Cam Macdonell <cam@cs.ualberta.ca>
> Cc: qemu-stable@nongnu.org
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  hw/misc/ivshmem.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
> index a19a6d6..5658f73 100644
> --- a/hw/misc/ivshmem.c
> +++ b/hw/misc/ivshmem.c
> @@ -735,6 +735,7 @@ static int pci_ivshmem_init(PCIDevice *dev)
>  
>          if (s->shmobj == NULL) {
>              fprintf(stderr, "Must specify 'chardev' or 'shm' to ivshmem\n");
> +            exit(1);

Reviewed-by: Eric Blake <eblake@redhat.com>

However, I prefer exit(EXIT_FAILURE) rather than exit(1), to make it a
bit easier to grep for known failure exits.  Libvirt has a syntax
checker (taken from gnulib) that enforces such a style, if qemu would
like to adopt that style.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]

  reply	other threads:[~2013-06-03 12:26 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-03  8:58 [Qemu-trivial] [PATCH v2 0/2] vhost-scsi and ivshmem fixes for Coverity issues Stefan Hajnoczi
2013-06-03  8:58 ` [Qemu-devel] " Stefan Hajnoczi
2013-06-03  8:58 ` [Qemu-trivial] [PATCH v2 1/2] vhost-scsi: fix k->set_guest_notifiers() NULL dereference Stefan Hajnoczi
2013-06-03  8:58   ` [Qemu-devel] " Stefan Hajnoczi
2013-06-03  9:07   ` [Qemu-trivial] " Paolo Bonzini
2013-06-03  9:07     ` [Qemu-devel] " Paolo Bonzini
2013-06-03  8:58 ` [Qemu-trivial] [PATCH v2 2/2] ivshmem: add missing error exit(2) Stefan Hajnoczi
2013-06-03  8:58   ` [Qemu-devel] " Stefan Hajnoczi
2013-06-03 12:26   ` Eric Blake [this message]
2013-06-03 12:26     ` Eric Blake
2013-06-03 13:11     ` [Qemu-trivial] " Stefan Hajnoczi
2013-06-03 13:11       ` [Qemu-devel] " Stefan Hajnoczi
2013-06-12  8:49       ` [Qemu-trivial] " Andreas Färber
2013-06-12  8:49         ` Andreas Färber
2013-06-12  7:22   ` [Qemu-trivial] " Stefan Hajnoczi
2013-06-12  7:22     ` [Qemu-devel] " Stefan Hajnoczi
2013-06-12  9:18     ` [Qemu-trivial] " Michael Tokarev
2013-06-12  9:18       ` [Qemu-devel] " Michael Tokarev

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=51AC8B6E.9040002@redhat.com \
    --to=eblake@redhat.com \
    --cc=cam@cs.ualberta.ca \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=stefanha@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.