qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Cao jin <caoj.fnst@cn.fujitsu.com>
To: qemu-devel@nongnu.org
Cc: Markus Armbruster <armbru@redhat.com>,
	"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v5 10/10] msi_init: convert assert to return -errno
Date: Thu, 3 Nov 2016 14:16:08 +0800	[thread overview]
Message-ID: <581AD628.2020501@cn.fujitsu.com> (raw)
In-Reply-To: <1478145997-28865-11-git-send-email-caoj.fnst@cn.fujitsu.com>

Please ignore this one, I forget to commit the amendment...
Already send the right one.

Cao jin

On 11/03/2016 12:06 PM, Cao jin wrote:
> According to the disscussion:
> http://lists.nongnu.org/archive/html/qemu-devel/2016-09/msg08215.html
>
> Let leaf function returns reasonable -errno, let caller decide how to
> handle the return value.
>
> Suggested-by: Markus Armbruster <armbru@redhat.com>
> CC: Markus Armbruster <armbru@redhat.com>
> CC: Michael S. Tsirkin <mst@redhat.com>
> CC: Marcel Apfelbaum <marcel@redhat.com>
>
> Reviewed-by: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
> ---
>   hw/pci/msi.c | 11 ++++++++---
>   1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/hw/pci/msi.c b/hw/pci/msi.c
> index a87b227..443682b 100644
> --- a/hw/pci/msi.c
> +++ b/hw/pci/msi.c
> @@ -201,9 +201,14 @@ int msi_init(struct PCIDevice *dev, uint8_t offset,
>                      " 64bit %d mask %d\n",
>                      offset, nr_vectors, msi64bit, msi_per_vector_mask);
>
> -    assert(!(nr_vectors & (nr_vectors - 1)));   /* power of 2 */
> -    assert(nr_vectors > 0);
> -    assert(nr_vectors <= PCI_MSI_VECTORS_MAX);
> +    /* vector sanity test: should in range 1 - 32, should be power of 2 */
> +    if ((nr_vectors == 0) ||
> +        (nr_vectors > PCI_MSI_VECTORS_MAX) ||
> +        (nr_vectors & (nr_vectors - 1))) {
> +        error_setg(errp, "Invalid vector number: %d", nr_vectors);
> +        return -EINVAL;
> +    }
> +
>       /* the nr of MSI vectors is up to 32 */
>       vectors_order = ctz32(nr_vectors);
>
>

  reply	other threads:[~2016-11-03  6:13 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-03  4:06 [Qemu-devel] [PATCH v5 00/10] Convert msix_init() to error Cao jin
2016-11-03  4:06 ` [Qemu-devel] [PATCH v5 01/10] msix: Follow CODING_STYLE Cao jin
2016-11-03  4:06 ` [Qemu-devel] [PATCH v5 02/10] hcd-xhci: check & correct param before using it Cao jin
2016-11-03  4:06 ` [Qemu-devel] [PATCH v5 03/10] pci: Convert msix_init() to Error and fix callers to check it Cao jin
2016-11-03 11:38   ` Marcel Apfelbaum
2016-11-04  3:01     ` Cao jin
2016-11-05 16:52       ` Marcel Apfelbaum
2016-11-03  4:06 ` [Qemu-devel] [PATCH v5 04/10] megasas: change behaviour of msix switch Cao jin
2016-11-03  4:06 ` [Qemu-devel] [PATCH v5 05/10] hcd-xhci: " Cao jin
2016-11-03  4:06 ` [Qemu-devel] [PATCH v5 06/10] megasas: remove unnecessary megasas_use_msix() Cao jin
2016-11-03  4:06 ` [Qemu-devel] [PATCH v5 07/10] megasas: undo the overwrites of msi user configuration Cao jin
2016-11-03  4:06 ` [Qemu-devel] [PATCH v5 08/10] vmxnet3: fix reference leak issue Cao jin
2016-11-03  4:06 ` [Qemu-devel] [PATCH v5 09/10] vmxnet3: remove unnecessary internal msix flag Cao jin
2016-11-03  4:06 ` [Qemu-devel] [PATCH v5 10/10] msi_init: convert assert to return -errno Cao jin
2016-11-03  6:16   ` Cao jin [this message]
2016-11-03  6:05 ` [Qemu-devel] [PATCH v5 00/10] Convert msix_init() to error Cao jin
2016-11-03  6:10 ` [Qemu-devel] [PATCH v5 10/10] msi_init: convert assert to return -errno Cao jin
2016-11-03 11:47   ` Marcel Apfelbaum

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=581AD628.2020501@cn.fujitsu.com \
    --to=caoj.fnst@cn.fujitsu.com \
    --cc=armbru@redhat.com \
    --cc=mst@redhat.com \
    --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).