From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:52902) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0w3m-0006Md-Ba for qemu-devel@nongnu.org; Fri, 24 Feb 2012 09:23:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S0w3l-0003AU-1M for qemu-devel@nongnu.org; Fri, 24 Feb 2012 09:23:46 -0500 Received: from cantor2.suse.de ([195.135.220.15]:42227 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S0w3k-0003AN-Lr for qemu-devel@nongnu.org; Fri, 24 Feb 2012 09:23:44 -0500 Message-ID: <4F479D6F.3000302@suse.de> Date: Fri, 24 Feb 2012 15:23:43 +0100 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1330092792-22455-1-git-send-email-lcapitulino@redhat.com> <1330092792-22455-5-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1330092792-22455-5-git-send-email-lcapitulino@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 4/5] boards: switch machine type list to QTAILQ List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org Am 24.02.2012 15:13, schrieb Luiz Capitulino: > Signed-off-by: Luiz Capitulino Unless this fixes a bug, I'd rather not refactor this as in my head this is already just object_class_foreach() / object_class_by_name(), similar to CPUs on my qom-cpu branch. Andreas > --- > hw/boards.h | 3 ++- > vl.c | 16 ++++++---------- > 2 files changed, 8 insertions(+), 11 deletions(-) >=20 > diff --git a/hw/boards.h b/hw/boards.h > index 342a774..1eb8314 100644 > --- a/hw/boards.h > +++ b/hw/boards.h > @@ -4,6 +4,7 @@ > #define HW_BOARDS_H > =20 > #include "qdev.h" > +#include "qemu-queue.h" > =20 > typedef void QEMUMachineInitFunc(ram_addr_t ram_size, > const char *boot_device, > @@ -28,7 +29,7 @@ typedef struct QEMUMachine { > int is_default; > const char *default_machine_opts; > GlobalProperty *compat_props; > - struct QEMUMachine *next; > + QTAILQ_ENTRY(QEMUMachine) next; > } QEMUMachine; > =20 > void machine_register(QEMUMachine *m); > diff --git a/vl.c b/vl.c > index 9f9927c..4935106 100644 > --- a/vl.c > +++ b/vl.c > @@ -1160,24 +1160,20 @@ void pcmcia_info(Monitor *mon) > /***********************************************************/ > /* machine registration */ > =20 > -static QEMUMachine *first_machine =3D NULL; > +static QTAILQ_HEAD(QEMUMachineHead, QEMUMachine) machine_types =3D=20 > + QTAILQ_HEAD_INITIALIZER(machine_types); > QEMUMachine *current_machine =3D NULL; > =20 > void machine_register(QEMUMachine *m) > { > - QEMUMachine **pm; > - pm =3D &first_machine; > - while (*pm !=3D NULL) > - pm =3D &(*pm)->next; > - m->next =3D NULL; > - *pm =3D m; > + QTAILQ_INSERT_TAIL(&machine_types, m, next); > } > =20 > static QEMUMachine *machine_find(const char *name) > { > QEMUMachine *m; > =20 > - for(m =3D first_machine; m !=3D NULL; m =3D m->next) { > + QTAILQ_FOREACH(m, &machine_types, next) { > if (!strcmp(m->name, name)) > return m; > if (m->alias && !strcmp(m->alias, name)) > @@ -1190,7 +1186,7 @@ QEMUMachine *machine_find_default(void) > { > QEMUMachine *m; > =20 > - for(m =3D first_machine; m !=3D NULL; m =3D m->next) { > + QTAILQ_FOREACH(m, &machine_types, next) { > if (m->is_default) { > return m; > } > @@ -1203,7 +1199,7 @@ void machine_print_all(void) > QEMUMachine *m; > =20 > printf("Supported machines are:\n"); > - for (m =3D first_machine; m !=3D NULL; m =3D m->next) { > + QTAILQ_FOREACH(m, &machine_types, next) { > if (m->alias) { > printf("%-10s %s (alias of %s)\n", m->alias, m->desc, m->n= ame); > } --=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