From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42381) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YsDS7-0001RL-3V for qemu-devel@nongnu.org; Tue, 12 May 2015 12:54:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YsDS2-0007aV-CV for qemu-devel@nongnu.org; Tue, 12 May 2015 12:54:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52332) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YsDS2-0007a5-49 for qemu-devel@nongnu.org; Tue, 12 May 2015 12:54:38 -0400 Date: Tue, 12 May 2015 17:54:33 +0100 From: "Daniel P. Berrange" Message-ID: <20150512165433.GR18200@redhat.com> References: <1430476206-26034-1-git-send-email-berrange@redhat.com> <1430476206-26034-8-git-send-email-berrange@redhat.com> <554CF868.1080906@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <554CF868.1080906@suse.de> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 7/7] qom: don't pass string table to object_get_enum method Reply-To: "Daniel P. Berrange" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas =?utf-8?Q?F=C3=A4rber?= Cc: Paolo Bonzini , qemu-devel@nongnu.org On Fri, May 08, 2015 at 07:54:48PM +0200, Andreas F=C3=A4rber wrote: > Am 01.05.2015 um 12:30 schrieb Daniel P. Berrange: > > Now that properties can be explicitly registered as an enum > > type, there is no need to pass the string table to the > > object_get_enum method. The object property registration > > already has a pointer to the string table. > >=20 > > In changing this method signature, the hostmem backend object > > has to be converted to use the new enum property registration > > code, which simplifies it somewhat. > >=20 > > Signed-off-by: Daniel P. Berrange > > --- > > backends/hostmem.c | 22 ++++++++-------------- > > include/qom/object.h | 4 ++-- > > numa.c | 2 +- > > qom/object.c | 32 ++++++++++++++++++++++++-------- > > tests/check-qom-proplist.c | 46 ++++++++++++++++++++++++++++++++++++= ++++++++++ > > 5 files changed, 81 insertions(+), 25 deletions(-) > > diff --git a/qom/object.c b/qom/object.c > > index ba0e4b8..6d2a2a9 100644 > > --- a/qom/object.c > > +++ b/qom/object.c > > @@ -1026,13 +1026,35 @@ int64_t object_property_get_int(Object *obj, = const char *name, > > return retval; > > } > > =20 > > +typedef struct EnumProperty { > > + const char * const *strings; > > + int (*get)(Object *, Error **); > > + void (*set)(Object *, int, Error **); >=20 > Since get and set and moved unchanged, I would prefer placing it in the > final destination in the original patch to avoid churn. Yep, easy to do. > > diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c > > index de142e3..d5cd38b 100644 > > --- a/tests/check-qom-proplist.c > > +++ b/tests/check-qom-proplist.c > > @@ -249,6 +249,51 @@ static void test_dummy_badenum(void) > > } > > =20 > > =20 > > + > > +static void test_dummy_getenum(void) > > +{ > > + Error *err =3D NULL; > > + int val; > > + Object *parent =3D container_get(object_get_root(), > > + "/objects"); > > + DummyObject *dobj =3D DUMMY_OBJECT( > > + object_new_propv(TYPE_DUMMY, > > + parent, > > + "dummy0", > > + &err, > > + "av", "platypus", > > + NULL)); > > + > > + g_assert(dobj !=3D NULL); > > + g_assert(err =3D=3D NULL); > > + g_assert(dobj->av =3D=3D DUMMY_PLATYPUS); > > + > > + val =3D object_property_get_enum(OBJECT(dobj), > > + "av", > > + "DummyAnimal", > > + &err); > > + g_assert(err =3D=3D NULL); >=20 > Is there any significant difference between g_assert()'ing on error and > passing &error_abort? I didn't know about &error_abort until now :-) I will use that. Regards, Daniel --=20 |: http://berrange.com -o- http://www.flickr.com/photos/dberrange= / :| |: http://libvirt.org -o- http://virt-manager.or= g :| |: http://autobuild.org -o- http://search.cpan.org/~danberr= / :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vn= c :|