From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yy3n3-0001s5-Gp for qemu-devel@nongnu.org; Thu, 28 May 2015 15:48:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yy3n0-0001FN-3X for qemu-devel@nongnu.org; Thu, 28 May 2015 15:48:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57687) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yy3mz-0001FD-Ry for qemu-devel@nongnu.org; Thu, 28 May 2015 15:48:26 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 5651B2B64AB for ; Thu, 28 May 2015 19:48:25 +0000 (UTC) Message-ID: <55677108.8090205@redhat.com> Date: Thu, 28 May 2015 13:48:24 -0600 From: Eric Blake MIME-Version: 1.0 References: <1432768754-28523-1-git-send-email-bsd@redhat.com> <1432768754-28523-2-git-send-email-bsd@redhat.com> <87h9qxi322.fsf@blackfin.pond.sub.org> In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="rN3BHwNhOxtkjBmbPs7N5cGBolGeA88a8" Subject: Re: [Qemu-devel] [PATCH v3 1/2] monitor: cleanup parsing of cmd name and cmd arguments List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bandan Das , Markus Armbruster Cc: qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --rN3BHwNhOxtkjBmbPs7N5cGBolGeA88a8 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 05/28/2015 12:48 PM, Bandan Das wrote: > Markus Armbruster writes: >=20 >> Bandan Das 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. >>> =20 >>> #ifdef DEBUG >>> - monitor_printf(mon, "command=3D'%s', start=3D'%d'\n", cmdline, s= tart); >>> + monitor_printf(mon, "command=3D'%s', start=3D'%d'\n", cmdline, *= start); >> >> Would this compile if we defined DEBUG? >=20 > 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=3D'%s'....) and the compiler will always check for correct format vs. arguments, even when debugging is off= =2E 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. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --rN3BHwNhOxtkjBmbPs7N5cGBolGeA88a8 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJVZ3EIAAoJEKeha0olJ0Nq+WAH/2o089M0kzeZs9xA5qTihcsS rsKAAXLbMEoogfobdnJiRK662+xIO8jNjSjbTWCssMuyQz2l68xX7yT0WUPh4ctm gdlrha0xt1BkMjlwyYDbtfwQ1YMJdf6sUjFDA22uaALWycJvszBERPyj/3utWLO3 hZr01eKQ82m/yon2x2GxT27QgV5RJHZGn9xJ9mSC82cvI/6aV0yV87LOTtE+BOLn IGRNLooNdUy2J1SbIWkl3+efGXgrweMPaGO7DkWib7Ti8kErHLrpWvQFNe0Zb0Vb rf8hluCeX+tm7KulMfnCAYwbONRj4v/mZ4avDrqQTteX5AS0svsGwIa5R4gy+1w= =TLhf -----END PGP SIGNATURE----- --rN3BHwNhOxtkjBmbPs7N5cGBolGeA88a8--