From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:41587) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfXAx-0007GZ-Po for qemu-devel@nongnu.org; Thu, 23 May 2013 11:11:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UfXAv-000346-Gy for qemu-devel@nongnu.org; Thu, 23 May 2013 11:11:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:4767) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfXAv-00033r-9T for qemu-devel@nongnu.org; Thu, 23 May 2013 11:11:29 -0400 Message-ID: <519E3024.10904@redhat.com> Date: Thu, 23 May 2013 09:05:08 -0600 From: Eric Blake MIME-Version: 1.0 References: <1369298836-17416-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1369298836-17416-5-git-send-email-xiawenc@linux.vnet.ibm.com> In-Reply-To: <1369298836-17416-5-git-send-email-xiawenc@linux.vnet.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="----enig2LQIXLOOSPOEBFURUWVCP" Subject: Re: [Qemu-devel] [PATCH V2 4/5] util: add new function message_printf() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wenchao Xia Cc: kwolf@redhat.com, phrdina@redhat.com, stefanha@gmail.com, qemu-devel@nongnu.org, lcapitulino@redhat.com, pbonzini@redhat.com, armbru@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2LQIXLOOSPOEBFURUWVCP Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 05/23/2013 02:47 AM, Wenchao Xia wrote: > This function takes an input parameter *output, which can be specified = by > caller as stderr, stdout or a monitor. error_vprintf() now calls messag= e_vprintf(), > which is a static function added in this patch. >=20 > Signed-off-by: Wenchao Xia > --- > include/qemu/error-report.h | 13 +++++++++++++ > util/qemu-error.c | 28 ++++++++++++++++++++++++++-- > 2 files changed, 39 insertions(+), 2 deletions(-) >=20 > +++ b/util/qemu-error.c > @@ -13,6 +13,25 @@ > #include > #include "monitor/monitor.h" > =20 > +static GCC_FMT_ATTR(2, 0) > +void message_vprintf(const QemuOutput *output, const char *fmt, va_lis= t ap) > +{ > + if (output->kind =3D=3D OUTPUT_STREAM) { > + vfprintf(output->stream, fmt, ap); > + } else if (output->kind =3D=3D OUTPUT_MONITOR) { > + monitor_vprintf(output->monitor, fmt, ap); > + } Should you use a switch statement here, instead of open coding all possible enum values? But that's cosmetic. More importantly, I think this function should return an int, whose value is the value of vfprintf. On the monitor_vfprintf arm, it could return 0 for now (or, you could unravel THAT problem and fix monitor_vfprintf to return an output count, but that sounds like a bigger task). > +} > + > +void message_printf(const QemuOutput *output, const char *fmt, ...) > +{ > + va_list ap; > + > + va_start(ap, fmt); > + message_vprintf(output, fmt, ap); > + va_end(ap); This function should also return int. > +} > + > /* > * Print to current monitor if we have one, else to stderr. > * TODO should return int, so callers can calculate width, but that And by fixing the underlying function to return int, you could finally get rid of this TODO. Given that the int return problem is pre-existing, and probably deserves its own series, I'm fine with taking this patch as-is. Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org ------enig2LQIXLOOSPOEBFURUWVCP Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJRnjAkAAoJEKeha0olJ0NqQ7EH/3xZESobeg04EEnw0uoJyK5q pJTX5uZ0s816dfxYrm0kXwv1/xSdt4j61ObZdyyP2jPggdq3Fj+xBUP9pyCIJcoz 407auRlHVDdTZcg1KUsG7ZENOn9tMynV+BXdC6wTpI4KpZwRdZHQcqcJaEpJVJKB 3y7ORSYheFNjsiojjtbF9n2veCW8uki2tdsTgXWVMuQyMXrXpYpjEcmYBUGBjt4Y aoR4I3Cu5yF2zUgdkdnH7gV+NZN0ssxY2oJ30soSuuf/bFjHTCpBHfCAf+7VTAhF vxuCD9s620FUIKrtSdWDnyPkyxRqKnH53mF8RHaJXUbf0TgY2j1Rt8sc7X1FWUs= =Un9t -----END PGP SIGNATURE----- ------enig2LQIXLOOSPOEBFURUWVCP--