From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34385) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bX2dN-0000kW-8v for qemu-devel@nongnu.org; Tue, 09 Aug 2016 04:43:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bX2dK-0000jF-W1 for qemu-devel@nongnu.org; Tue, 09 Aug 2016 04:43:36 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:35254) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bX2dK-0000j4-Jt for qemu-devel@nongnu.org; Tue, 09 Aug 2016 04:43:34 -0400 Received: by mail-wm0-x242.google.com with SMTP id i5so1714187wmg.2 for ; Tue, 09 Aug 2016 01:43:34 -0700 (PDT) MIME-Version: 1.0 References: <20160808141439.16908-1-marcandre.lureau@redhat.com> <20160808141439.16908-5-marcandre.lureau@redhat.com> <87h9auibj0.fsf@dusky.pond.sub.org> In-Reply-To: <87h9auibj0.fsf@dusky.pond.sub.org> From: =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= Date: Tue, 09 Aug 2016 08:43:23 +0000 Message-ID: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 04/15] monitor: remove usage of generated marshal functions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org Hi On Tue, Aug 9, 2016 at 12:38 PM Markus Armbruster wrote= : > marcandre.lureau@redhat.com writes: > > > From: Marc-Andr=C3=A9 Lureau > > > > Once the middle mode is removed, the generated marshal functions will n= o > > longer be exported. > > > > Signed-off-by: Marc-Andr=C3=A9 Lureau > > Reviewed-by: Eric Blake > > --- > > monitor.c | 10 +++++----- > > 1 file changed, 5 insertions(+), 5 deletions(-) > > > > diff --git a/monitor.c b/monitor.c > > index c9191e5..3a4a533 100644 > > --- a/monitor.c > > +++ b/monitor.c > > @@ -3659,21 +3659,21 @@ static int monitor_can_read(void *opaque) > > return (mon->suspend_cnt =3D=3D 0) ? 1 : 0; > > } > > > > -static bool invalid_qmp_mode(const Monitor *mon, const mon_cmd_t *cmd, > > +static bool invalid_qmp_mode(const Monitor *mon, const char *cmd, > > Error **errp) > > { > > - bool is_cap =3D cmd->mhandler.cmd_new =3D=3D qmp_marshal_qmp_capab= ilities; > > + bool is_cap =3D g_str_equal(cmd, "qmp_capabilities"); > > We usually do !strcmp(...). The negation is somewhat error-prone, which > is why some people argue for using g_str_equal() instead. Okay. > > > > > if (is_cap && mon->qmp.in_command_mode) { > > error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND, > > "Capabilities negotiation is already complete, > command " > > - "'%s' ignored", cmd->name); > > + "'%s' ignored", cmd); > > return true; > > } > > if (!is_cap && !mon->qmp.in_command_mode) { > > error_set(errp, ERROR_CLASS_COMMAND_NOT_FOUND, > > "Expecting capabilities negotiation with " > > - "'qmp_capabilities' before command '%s'", cmd->name)= ; > > + "'qmp_capabilities' before command '%s'", cmd); > > return true; > > } > > return false; > > @@ -3964,7 +3964,7 @@ static void handle_qmp_command(JSONMessageParser > *parser, GQueue *tokens) > > "The command %s has not been found", cmd_name); > > goto err_out; > > } > > - if (invalid_qmp_mode(mon, cmd, &local_err)) { > > + if (invalid_qmp_mode(mon, cmd_name, &local_err)) { > > goto err_out; > > } > > Patch is okay, but if we decide to keep things simple and give all > marshallers external linkage, it's unnecessary. > I would rather avoid touching marshaller from outside. It also avoids having to lookup the marshaller twice in handle_qmp_command(). (or we would need to teach qmp_dispatch() to take an already looked up marshaller). Well, that's not really bad but still worth to mention. --=20 Marc-Andr=C3=A9 Lureau