From: "Andreas Färber" <afaerber@suse.de>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: imammedo@redhat.com, qemu-devel@nongnu.org, peter.maydell@linaro.org
Subject: Re: [Qemu-devel] [PATCH 01/10] qdev: remove PropertyInfo range checking
Date: Thu, 24 May 2012 19:50:27 +0200 [thread overview]
Message-ID: <4FBE74E3.7070304@suse.de> (raw)
In-Reply-To: <1337787881-3579-2-git-send-email-pbonzini@redhat.com>
Am 23.05.2012 17:44, schrieb Paolo Bonzini:
> Range checking in PropertyInfo is now used only for pci_devfn
> properties and some error reporting. Remove all code that implements
> it in the various property types, and the now unused fields.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> hw/qdev-properties.c | 104 ++++++++++++--------------------------------------
> hw/qdev.h | 2 -
> 2 files changed, 24 insertions(+), 82 deletions(-)
>
> diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
> index 2255ebb..af68ca5 100644
> --- a/hw/qdev-properties.c
> +++ b/hw/qdev-properties.c
[...]
> @@ -924,10 +871,9 @@ static void set_blocksize(Object *obj, Visitor *v, void *opaque,
> error_propagate(errp, local_err);
> return;
> }
> - if (value < prop->info->min || value > prop->info->max) {
> + if (value < 512 || value > 32768) {
> error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE,
> - dev->id?:"", name, (int64_t)value, prop->info->min,
> - prop->info->max);
> + dev->id?:"", name, (int64_t)value, 512L, 32768L);
> return;
> }
>
This would need LL for 32-bit hosts. I've therefore adopted the same
pattern as for the X86CPU properties, adding const int64_t min/max. This
avoids duplicating the numbers between comparison and error message, and
the comparison still compiles warning-free here despite uint16_t vs.
int64_t. Applied to qom-next:
http://repo.or.cz/w/qemu/afaerber.git/shortlog/refs/heads/qom-next
For anyone wondering about the max change
65024 (1111 1110 0000 0000) to
32768 (1000 0000 0000 0000),
there's a check following this one that allows only powers of 2.
Andreas
> @@ -945,8 +891,6 @@ PropertyInfo qdev_prop_blocksize = {
> .name = "blocksize",
> .get = get_uint16,
> .set = set_blocksize,
> - .min = 512,
> - .max = 65024,
> };
>
> /* --- public helpers --- */
[snip]
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
next prev parent reply other threads:[~2012-05-24 17:50 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-23 15:44 [Qemu-devel] [PATCH 00/10] push static properties to Object, add realized property Paolo Bonzini
2012-05-23 15:44 ` [Qemu-devel] [PATCH 01/10] qdev: remove PropertyInfo range checking Paolo Bonzini
2012-05-24 17:50 ` Andreas Färber [this message]
2012-05-23 15:44 ` [Qemu-devel] [PATCH 02/10] qdev: remove qdev_prop_exists Paolo Bonzini
2012-05-24 21:34 ` Andreas Färber
2012-05-25 7:20 ` Paolo Bonzini
2012-05-25 15:57 ` Andreas Färber
2012-05-23 15:44 ` [Qemu-devel] [PATCH 03/10] qom: push error reporting to object_property_find Paolo Bonzini
2012-05-25 16:05 ` Andreas Färber
2012-05-26 9:58 ` Paolo Bonzini
2012-05-26 22:04 ` Andreas Färber
2012-05-23 15:44 ` [Qemu-devel] [PATCH 04/10] qom: add get_id Paolo Bonzini
2012-05-25 16:33 ` Andreas Färber
2012-05-25 17:39 ` malc
2012-05-23 15:44 ` [Qemu-devel] [PATCH 05/10] qdev: push state up to Object Paolo Bonzini
2012-05-25 16:58 ` Andreas Färber
2012-05-23 15:44 ` [Qemu-devel] [PATCH 06/10] qdev: generalize properties to Objects Paolo Bonzini
2012-05-23 15:44 ` [Qemu-devel] [PATCH 07/10] qdev: move bulk of qdev-properties.c to qom/object.c Paolo Bonzini
2012-05-25 13:32 ` Andreas Färber
2012-05-25 13:36 ` Paolo Bonzini
2012-05-23 15:44 ` [Qemu-devel] [PATCH 08/10] qom: push static properties to Object Paolo Bonzini
2012-06-07 16:36 ` Andreas Färber
2012-05-23 15:44 ` [Qemu-devel] [PATCH 09/10] qom: add realized property Paolo Bonzini
2012-05-23 15:44 ` [Qemu-devel] [PATCH 10/10] qom: Add QERR_PROPERTY_SET_AFTER_REALIZE Paolo Bonzini
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=4FBE74E3.7070304@suse.de \
--to=afaerber@suse.de \
--cc=imammedo@redhat.com \
--cc=pbonzini@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).