From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:40002) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXcBJ-00008p-0K for qemu-devel@nongnu.org; Thu, 24 May 2012 13:50:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SXcBG-0005uE-SH for qemu-devel@nongnu.org; Thu, 24 May 2012 13:50:36 -0400 Received: from cantor2.suse.de ([195.135.220.15]:35000 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXcBG-0005tO-IK for qemu-devel@nongnu.org; Thu, 24 May 2012 13:50:34 -0400 Message-ID: <4FBE74E3.7070304@suse.de> Date: Thu, 24 May 2012 19:50:27 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1337787881-3579-1-git-send-email-pbonzini@redhat.com> <1337787881-3579-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1337787881-3579-2-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 01/10] qdev: remove PropertyInfo range checking List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: imammedo@redhat.com, qemu-devel@nongnu.org, peter.maydell@linaro.org 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. >=20 > Signed-off-by: Paolo Bonzini > --- > hw/qdev-properties.c | 104 ++++++++++++------------------------------= -------- > hw/qdev.h | 2 - > 2 files changed, 24 insertions(+), 82 deletions(-) >=20 > 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; > } > =20 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 =3D { > .name =3D "blocksize", > .get =3D get_uint16, > .set =3D set_blocksize, > - .min =3D 512, > - .max =3D 65024, > }; > =20 > /* --- public helpers --- */ [snip] --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg