Received: from eggs.gnu.org ([2001:4830:134:3::10]:59799) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fLr33-0002PU-Jr for qemu-devel@nongnu.org; Thu, 24 May 2018 10:16:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fLr2x-0006qZ-QS for qemu-devel@nongnu.org; Thu, 24 May 2018 10:16:57 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60176 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fLr2x-0006q9-LA for qemu-devel@nongnu.org; Thu, 24 May 2018 10:16:51 -0400 From: Markus Armbruster References: <1525445354-16233-1-git-send-email-walling@linux.ibm.com> <7e9e9dfd-795b-47f2-453a-59bf65f28229@redhat.com> <7274b001-02f2-6584-ea0a-c3d0f96d46b8@linux.ibm.com> <89dc884d-97af-4922-bd69-1cb7308399d8@redhat.com> <724592be-f5ac-7a40-8c26-5d2dd200ef82@linux.ibm.com> Date: Thu, 24 May 2018 16:16:49 +0200 In-Reply-To: (Collin Walling's message of "Mon, 7 May 2018 10:30:54 -0400") Message-ID: <87y3g916lq.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v2] monitor: report entirety of hmp command on error List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Alan Gilbert Cc: Eric Blake , qemu-devel@nongnu.org, Collin Walling David, looks like your turf. Collin Walling writes: > When a user incorrectly provides an hmp command, an error response will be > printed that prompts the user to try "help ". However, when > the command contains multiple parts e.g. "info uuid xyz", only the last > whitespace delimited string will be reported (in this example "info" will > be dropped and the message will read "Try "help uuid" for more information", > which is incorrect). > > Let's correct this by capturing the entirety of the command from the command > line -- excluding any extraneous characters. > > Reported-by: Mikhail Fokin > Signed-off-by: Collin Walling > --- > monitor.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/monitor.c b/monitor.c > index 39f8ee1..38736b3 100644 > --- a/monitor.c > +++ b/monitor.c > @@ -3371,6 +3371,7 @@ static void handle_hmp_command(Monitor *mon, const char *cmdline) > { > QDict *qdict; > const mon_cmd_t *cmd; > + const char *cmd_start = cmdline; > > trace_handle_hmp_command(mon, cmdline); > > @@ -3381,8 +3382,11 @@ static void handle_hmp_command(Monitor *mon, const char *cmdline) > > qdict = monitor_parse_arguments(mon, &cmdline, cmd); > if (!qdict) { > - monitor_printf(mon, "Try \"help %s\" for more information\n", > - cmd->name); > + while (cmdline > cmd_start && qemu_isspace(cmdline[-1])) { > + cmdline--; > + } > + monitor_printf(mon, "Try \"help %.*s\" for more information\n", > + (int)(cmdline - cmd_start), cmd_start); > return; > }