From: Marcel Apfelbaum <marcel@redhat.com>
To: Cao jin <caoj.fnst@cn.fujitsu.com>, 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 13:47:53 +0200 [thread overview]
Message-ID: <e89f8838-3aa8-1cc5-41e2-cfbc2905b85a@redhat.com> (raw)
In-Reply-To: <1478153400-29946-1-git-send-email-caoj.fnst@cn.fujitsu.com>
On 11/03/2016 08:10 AM, Cao jin wrote:
> According to the disscussion:
> http://lists.nongnu.org/archive/html/qemu-devel/2016-09/msg08215.html
>
Hi,
Intense discussion, but I learned a lot from it.
> 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 | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> Really sorry, I forget to commit what I amend...
>
> diff --git a/hw/pci/msi.c b/hw/pci/msi.c
> index a87b227..af3efbe 100644
> --- a/hw/pci/msi.c
> +++ b/hw/pci/msi.c
> @@ -201,9 +201,12 @@ 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 (!is_power_of_2(nr_vectors) || nr_vectors > PCI_MSI_VECTORS_MAX) {
> + 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);
>
>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Thanks,
Marcel
prev parent reply other threads:[~2016-11-03 11:48 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
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 [this message]
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=e89f8838-3aa8-1cc5-41e2-cfbc2905b85a@redhat.com \
--to=marcel@redhat.com \
--cc=armbru@redhat.com \
--cc=caoj.fnst@cn.fujitsu.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).