From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33353) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5z7y-0006j4-Vm for qemu-devel@nongnu.org; Fri, 19 Jun 2015 12:26:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z5z7u-0002Ke-0V for qemu-devel@nongnu.org; Fri, 19 Jun 2015 12:26:50 -0400 Received: from cantor2.suse.de ([195.135.220.15]:55647 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5z7t-0002KI-Nx for qemu-devel@nongnu.org; Fri, 19 Jun 2015 12:26:45 -0400 Message-ID: <558442C4.8010307@suse.de> Date: Fri, 19 Jun 2015 18:26:44 +0200 From: =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= MIME-Version: 1.0 References: <1432739276-10452-1-git-send-email-berrange@redhat.com> <1432739276-10452-8-git-send-email-berrange@redhat.com> <55843F7A.5050404@redhat.com> In-Reply-To: <55843F7A.5050404@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="vr8gGr3QWmNpqSmUfcKDQO8g7gQ2DjXp9" Subject: Re: [Qemu-devel] [PATCH v5 7/8] qom: add a object_property_add_enum helper method List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , qemu-devel@nongnu.org Cc: Paolo Bonzini This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --vr8gGr3QWmNpqSmUfcKDQO8g7gQ2DjXp9 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Am 19.06.2015 um 18:12 schrieb Eric Blake: > On 05/27/2015 09:07 AM, Daniel P. Berrange wrote: >> A QOM property can be parsed as enum using the visit_type_enum() >> helper method, but this forces callers to use the more complex >> generic object_property_add() method when registering it. It >> also requires that users of that object have access to the >> string map when they want to read the property value. >> >> This patch introduces a specialized object_property_add_enum() >> method which simplifies the use of enum properties, so the >> setters/getters directly get passed the int value. >> >> typedef enum { >=20 >> /** >> + * object_property_add_enum: >> + * @obj: the object to add a property to >> + * @name: the name of the property >> + * @typename: the name of the enum data type >> + * @get: the getter or %NULL if the property is write-only. >> + * @set: the setter or %NULL if the property is read-only >> + * @errp: if an error occurs, a pointer to an area to store the error= >> + * >> + * Add a enum property using getters/setters. This function will add= a >=20 > s/a enum/an enum/ Thanks, fixed on https://github.com/afaerber/qemu-cpu/commits/qom-next >> +static void property_release_enum(Object *obj, const char *name, >> + void *opaque) >> +{ >> + EnumProperty *prop =3D opaque; >> + g_free(prop); >=20 > Could also be written as g_free(opaque), but that's a little less > readable, so I don't see a point in changing it. I prefer it this way. Consuming opaques directly broke a few call sites when I refactored the CPU structs, so the savings of one line is not really worth it IMO. Regards, Andreas --=20 SUSE Linux GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany GF: Felix Imend=C3=B6rffer, Jane Smithard, Dilip Upmanyu, Graham Norton; = HRB 21284 (AG N=C3=BCrnberg) --vr8gGr3QWmNpqSmUfcKDQO8g7gQ2DjXp9 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBAgAGBQJVhELEAAoJEPou0S0+fgE/7GcQALyMHa4VFsRj5P5XYM4Lwp61 qdcnSaWEciXoYxOz/wT4jqDI2qjR53DOgRhF1EyNwaHXw7nFkF8sZRRyPlBU6Nn6 O684l02BVPvKdRKwCtGhNm8JC/LuR4R+FSU89XK1dlw+kNo+MX96YYy5KdicUAq5 /OPNknN1J3x87mJNOoW/sWT3LHFySPz9xRCne8sdEPRwlA5+aJgzV1a8jzOKt46s 4iUdFzXyPYxxlRCSMow5IO7Cn8ynJPa+QA4CunMYKqxDDETKxeKsLDHyAwk8XNir 1tqCpg7bLPLnKLb9vubFbySyv1Q71EOsS+X/nUOpthrm08ipnizIGtDNNjpJ4Rpu zlXqwnas8qh8SE3YYEFmmgNuTEGQAhJz3AUz0Hby/+AGR9Umfy00bcgY/x0N1I4X t+UQFnbQTmUGWR9mfGxzFLy4VFJmk+YhWZ2lf+thAuuMircFfg2D316H4I2Xej2f jnBIxwzwxIpxziCshIzzHqclb1RAEaqY9rh8dO3am3hqht9P/98D4EAWCnyj17/z cxpGoZWPzWeg1FZqorR+JxUjaEx6glVmPhYGrxi4usu9SD+TzkHqtu9DRE37mb1i pSJ0Ch3B2nrQ8oIbO5lSqHmmxNEdm1CxuhkDdRgh4WBMvRMuJRSkWQsSK82Hd883 XZQoXwlxFxWECK10n9tt =H+K/ -----END PGP SIGNATURE----- --vr8gGr3QWmNpqSmUfcKDQO8g7gQ2DjXp9--