From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40807) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVf81-0001Re-BU for qemu-devel@nongnu.org; Fri, 05 Aug 2016 09:25:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bVf7x-0007lH-GB for qemu-devel@nongnu.org; Fri, 05 Aug 2016 09:25:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39872) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVf7x-0007kv-8H for qemu-devel@nongnu.org; Fri, 05 Aug 2016 09:25:29 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1EE8EC04D2A5 for ; Fri, 5 Aug 2016 13:25:28 +0000 (UTC) From: Markus Armbruster References: <20160721140030.28383-1-marcandre.lureau@redhat.com> <20160721140030.28383-8-marcandre.lureau@redhat.com> Date: Fri, 05 Aug 2016 15:25:25 +0200 In-Reply-To: <20160721140030.28383-8-marcandre.lureau@redhat.com> (marcandre lureau's message of "Thu, 21 Jul 2016 18:00:25 +0400") Message-ID: <8737mjuz3u.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 07/12] monitor: implement 'qmp_query_commands' without qmp_cmds List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: marcandre.lureau@redhat.com Cc: qemu-devel@nongnu.org marcandre.lureau@redhat.com writes: > From: Marc-Andr=C3=A9 Lureau > > So we can get rid of the static qmp_cmds table. > > Signed-off-by: Marc-Andr=C3=A9 Lureau > --- > monitor.c | 32 ++++++++++++++------------------ > 1 file changed, 14 insertions(+), 18 deletions(-) > > diff --git a/monitor.c b/monitor.c > index 642be2e..bd41b4b 100644 > --- a/monitor.c > +++ b/monitor.c > @@ -229,8 +229,6 @@ static int mon_refcount; > static mon_cmd_t mon_cmds[]; > static mon_cmd_t info_cmds[]; >=20=20 > -static const mon_cmd_t qmp_cmds[]; > - > Monitor *cur_mon; >=20=20 > static QEMUClockType event_clock_type =3D QEMU_CLOCK_REALTIME; > @@ -947,21 +945,24 @@ static void hmp_info_help(Monitor *mon, const QDict= *qdict) > help_cmd(mon, "info"); > } >=20=20 > -CommandInfoList *qmp_query_commands(Error **errp) > +static void query_commands_cb(QmpCommand *cmd, void *opaque) > { > - CommandInfoList *info, *cmd_list =3D NULL; > - const mon_cmd_t *cmd; > + CommandInfoList *info, **list =3D opaque; >=20=20 > - for (cmd =3D qmp_cmds; cmd->name !=3D NULL; cmd++) { > - info =3D g_malloc0(sizeof(*info)); > - info->value =3D g_malloc0(sizeof(*info->value)); > - info->value->name =3D g_strdup(cmd->name); > + info =3D g_malloc0(sizeof(*info)); > + info->value =3D g_malloc0(sizeof(*info->value)); > + info->value->name =3D g_strdup(cmd->name); > + info->next =3D *list; > + *list =3D info; > +} >=20=20 > - info->next =3D cmd_list; > - cmd_list =3D info; > - } > +CommandInfoList *qmp_query_commands(Error **errp) > +{ > + CommandInfoList *list =3D NULL; >=20=20 > - return cmd_list; > + qmp_for_each_command(query_commands_cb, &list); > + > + return list; > } >=20=20 > EventInfoList *qmp_query_events(Error **errp) > @@ -2166,11 +2167,6 @@ static mon_cmd_t mon_cmds[] =3D { > { NULL, NULL, }, > }; >=20=20 > -static const mon_cmd_t qmp_cmds[] =3D { > -#include "qmp-commands-old.h" > - { /* NULL */ }, > -}; > - > /*******************************************************************/ >=20=20 > static const char *pch; I'm afraid you'll have to rearrange things a bit: x86_64-softmmu/monitor.o /work/armbru/qemu/monitor.c: In function =E2=80=98qmp_find_cmd=E2=80=99: /work/armbru/qemu/monitor.c:2522:34: error: =E2=80=98qmp_cmds=E2=80=99 unde= clared (first use in this function) return search_dispatch_table(qmp_cmds, cmdname); ^ /work/armbru/qemu/monitor.c:2522:34: note: each undeclared identifier is re= ported only once for each function it appears in /work/armbru/qemu/monitor.c:2523:1: warning: control reaches end of non-voi= d function [-Wreturn-type] } ^