From: Eric Blake <eblake@redhat.com>
To: Bandan Das <bsd@redhat.com>, Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v3 1/2] monitor: cleanup parsing of cmd name and cmd arguments
Date: Thu, 28 May 2015 13:48:24 -0600 [thread overview]
Message-ID: <55677108.8090205@redhat.com> (raw)
In-Reply-To: <jpgpp5kczc5.fsf@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1653 bytes --]
On 05/28/2015 12:48 PM, Bandan Das wrote:
> Markus Armbruster <armbru@redhat.com> writes:
>
>> Bandan Das <bsd@redhat.com> writes:
>>
>>> There's too much going on in monitor_parse_command().
>>> Split up the arguments parsing bits into a separate function
>>> monitor_parse_arguments(). Let the original function check for
>>> command validity and sub-commands if any and return data (*cmd)
>>> that the newly introduced function can process and return a
>>> QDict. Also, pass a pointer to the cmdline to track current
>>> parser location.
>>>
>>> #ifdef DEBUG
>>> - monitor_printf(mon, "command='%s', start='%d'\n", cmdline, start);
>>> + monitor_printf(mon, "command='%s', start='%d'\n", cmdline, *start);
>>
>> Would this compile if we defined DEBUG?
>
> No, it won't :) Sorry, will fix.
That's why I like solutions that can't bitrot; something like this
framework (needs a bit more to actually compile, but you get the picture):
#ifdef DEBUG
# define DEBUG_MONITOR 1
#else
# define DEBUG_MONITOR 0
#endif
#define DEBUG_MONITOR_PRINTF(stuff...) do { \
if (DEBUG_MONITOR) { \
monitor_printf(stuff...); \
} \
} while (0)
then you can avoid the #ifdef in the function body, and just do
DEBUG_MONITOR_PRINTF(mon, "command='%s'....) and the compiler will
always check for correct format vs. arguments, even when debugging is off.
Of course, adding such a framework in this file would be a separate
patch, and does not have to be done as a prerequisite of this series.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2015-05-28 19:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-27 23:19 [Qemu-devel] [PATCH v3 0/2] monitor: suggest running "help" for command errors Bandan Das
2015-05-27 23:19 ` [Qemu-devel] [PATCH v3 1/2] monitor: cleanup parsing of cmd name and cmd arguments Bandan Das
2015-05-28 7:17 ` Markus Armbruster
2015-05-28 18:48 ` Bandan Das
2015-05-28 19:48 ` Eric Blake [this message]
2015-05-28 20:24 ` Bandan Das
2015-05-29 7:57 ` Markus Armbruster
2015-05-27 23:19 ` [Qemu-devel] [PATCH v3 2/2] When a command fails due to incorrect syntax or input, suggest using the "help" command to get more information about the command. This is only applicable for HMP Bandan Das
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55677108.8090205@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=bsd@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.