From: Laszlo Ersek <lersek@redhat.com>
To: Wei Huang <wei@redhat.com>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, mst@redhat.com
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH 1/1] virtio-rng: fix condition checking on period_ms
Date: Fri, 19 Feb 2016 21:59:19 +0100 [thread overview]
Message-ID: <56C78227.4030207@redhat.com> (raw)
In-Reply-To: <56C781AE.5050004@redhat.com>
On 02/19/16 21:57, Laszlo Ersek wrote:
> On 02/19/16 19:13, Wei Huang wrote:
>> The condition checking on vrng->conf.period_ms appears to be wrong,
>> conflicting with the error comment following it.
>>
>> Signed-off-by: Wei Huang <wei@redhat.com>
>> ---
>> hw/virtio/virtio-rng.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
>> index 473c044..a06427c 100644
>> --- a/hw/virtio/virtio-rng.c
>> +++ b/hw/virtio/virtio-rng.c
>> @@ -149,7 +149,7 @@ static void virtio_rng_device_realize(DeviceState *dev, Error **errp)
>> VirtIORNG *vrng = VIRTIO_RNG(dev);
>> Error *local_err = NULL;
>>
>> - if (!vrng->conf.period_ms > 0) {
>> + if (!(vrng->conf.period_ms > 0)) {
>> error_setg(errp, "'period' parameter expects a positive integer");
>> return;
>> }
>>
>
> The current condition is absolutely weird, but I think it happens to
> work correctly:
>
> Period_ms has type uint32_t. If it is positive, then !period_ms is zero.
> 0>0 is false, hence the error message is not printed.
>
> If period_ms is zero, then !period_ms is 1. 1>0 is true, hence the error
> message is printed.
>
> I would rewrite the check as
>
> if (vrng->conf.period_ms == 0) {
> error_setg(...)
... actually, what the heck are you looking at? :) This has been fixed
up in:
commit a3a292c420d2fec3c07a7ca56fbb064cd57a298a
Author: Amit Shah <amit.shah@redhat.com>
Date: Thu Dec 11 13:17:42 2014 +0530
virtio-rng: fix check for period_ms validity
Thanks
Laszlo
WARNING: multiple messages have this Message-ID (diff)
From: Laszlo Ersek <lersek@redhat.com>
To: Wei Huang <wei@redhat.com>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, mst@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/1] virtio-rng: fix condition checking on period_ms
Date: Fri, 19 Feb 2016 21:59:19 +0100 [thread overview]
Message-ID: <56C78227.4030207@redhat.com> (raw)
In-Reply-To: <56C781AE.5050004@redhat.com>
On 02/19/16 21:57, Laszlo Ersek wrote:
> On 02/19/16 19:13, Wei Huang wrote:
>> The condition checking on vrng->conf.period_ms appears to be wrong,
>> conflicting with the error comment following it.
>>
>> Signed-off-by: Wei Huang <wei@redhat.com>
>> ---
>> hw/virtio/virtio-rng.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
>> index 473c044..a06427c 100644
>> --- a/hw/virtio/virtio-rng.c
>> +++ b/hw/virtio/virtio-rng.c
>> @@ -149,7 +149,7 @@ static void virtio_rng_device_realize(DeviceState *dev, Error **errp)
>> VirtIORNG *vrng = VIRTIO_RNG(dev);
>> Error *local_err = NULL;
>>
>> - if (!vrng->conf.period_ms > 0) {
>> + if (!(vrng->conf.period_ms > 0)) {
>> error_setg(errp, "'period' parameter expects a positive integer");
>> return;
>> }
>>
>
> The current condition is absolutely weird, but I think it happens to
> work correctly:
>
> Period_ms has type uint32_t. If it is positive, then !period_ms is zero.
> 0>0 is false, hence the error message is not printed.
>
> If period_ms is zero, then !period_ms is 1. 1>0 is true, hence the error
> message is printed.
>
> I would rewrite the check as
>
> if (vrng->conf.period_ms == 0) {
> error_setg(...)
... actually, what the heck are you looking at? :) This has been fixed
up in:
commit a3a292c420d2fec3c07a7ca56fbb064cd57a298a
Author: Amit Shah <amit.shah@redhat.com>
Date: Thu Dec 11 13:17:42 2014 +0530
virtio-rng: fix check for period_ms validity
Thanks
Laszlo
next prev parent reply other threads:[~2016-02-19 20:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-19 18:13 [Qemu-trivial] [PATCH 1/1] virtio-rng: fix condition checking on period_ms Wei Huang
2016-02-19 18:13 ` [Qemu-devel] " Wei Huang
2016-02-19 20:57 ` [Qemu-trivial] " Laszlo Ersek
2016-02-19 20:57 ` Laszlo Ersek
2016-02-19 20:59 ` Laszlo Ersek [this message]
2016-02-19 20:59 ` Laszlo Ersek
2016-02-19 21:07 ` [Qemu-trivial] " Wei Huang
2016-02-19 21:07 ` Wei Huang
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=56C78227.4030207@redhat.com \
--to=lersek@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=wei@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.