From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41616) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWhhu-00061y-9e for qemu-devel@nongnu.org; Tue, 11 Dec 2018 08:04:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gWhht-0000jA-0X for qemu-devel@nongnu.org; Tue, 11 Dec 2018 08:04:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49284) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gWhhs-0000ia-6b for qemu-devel@nongnu.org; Tue, 11 Dec 2018 08:04:12 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4B5273082193 for ; Tue, 11 Dec 2018 13:04:11 +0000 (UTC) Date: Tue, 11 Dec 2018 14:04:07 +0100 From: Igor Mammedov Message-ID: <20181211140407.10b838dc@redhat.com> In-Reply-To: <20181204142023.15982-13-marcandre.lureau@redhat.com> References: <20181204142023.15982-1-marcandre.lureau@redhat.com> <20181204142023.15982-13-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH for-3.2 v5 12/19] qdev-props: convert global_props to GPtrArray List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?TWFyYy1BbmRyw6k=?= Lureau Cc: qemu-devel@nongnu.org, ehabkost@redhat.com On Tue, 4 Dec 2018 18:20:16 +0400 Marc-Andr=C3=A9 Lureau wrote: > A step towards being able to call a common function, > object_apply_global_props(). >=20 > Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Igor Mammedov > --- > hw/core/qdev-properties.c | 29 ++++++++++++++++++++--------- > 1 file changed, 20 insertions(+), 9 deletions(-) >=20 > diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c > index 43c30a57f4..3467e0485c 100644 > --- a/hw/core/qdev-properties.c > +++ b/hw/core/qdev-properties.c > @@ -1173,22 +1173,32 @@ void qdev_prop_set_ptr(DeviceState *dev, const ch= ar *name, void *value) > *ptr =3D value; > } > =20 > -static GList *global_props; > +static GPtrArray *global_props(void) > +{ > + static GPtrArray *gp; > + > + if (!gp) { > + gp =3D g_ptr_array_new(); > + } > + > + return gp; > +} > =20 > void qdev_prop_register_global(GlobalProperty *prop) > { > - global_props =3D g_list_append(global_props, prop); > + g_ptr_array_add(global_props(), prop); > } > =20 > int qdev_prop_check_globals(void) > { > - GList *l; > - int ret =3D 0; > + int i, ret =3D 0; > =20 > - for (l =3D global_props; l; l =3D l->next) { > - GlobalProperty *prop =3D l->data; > + for (i =3D 0; i < global_props()->len; i++) { > + GlobalProperty *prop; > ObjectClass *oc; > DeviceClass *dc; > + > + prop =3D g_ptr_array_index(global_props(), i); > if (prop->used) { > continue; > } > @@ -1213,12 +1223,13 @@ int qdev_prop_check_globals(void) > =20 > void qdev_prop_set_globals(DeviceState *dev) > { > - GList *l; > + int i; > =20 > - for (l =3D global_props; l; l =3D l->next) { > - GlobalProperty *prop =3D l->data; > + for (i =3D 0; i < global_props()->len; i++) { > + GlobalProperty *prop; > Error *err =3D NULL; > =20 > + prop =3D g_ptr_array_index(global_props(), i); > if (object_dynamic_cast(OBJECT(dev), prop->driver) =3D=3D NULL) { > continue; > }