From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:38090) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ufh1Y-0007fD-6g for qemu-devel@nongnu.org; Thu, 23 May 2013 21:42:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ufh1W-00082a-SR for qemu-devel@nongnu.org; Thu, 23 May 2013 21:42:28 -0400 Received: from e23smtp06.au.ibm.com ([202.81.31.148]:32978) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ufh1W-00080z-9v for qemu-devel@nongnu.org; Thu, 23 May 2013 21:42:26 -0400 Received: from /spool/local by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 24 May 2013 11:35:45 +1000 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [9.190.235.152]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id DF9B52BB0050 for ; Fri, 24 May 2013 11:42:15 +1000 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r4O1RtXr20971768 for ; Fri, 24 May 2013 11:27:56 +1000 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r4O1gEJ8002974 for ; Fri, 24 May 2013 11:42:14 +1000 Message-ID: <519EC543.3030800@linux.vnet.ibm.com> Date: Fri, 24 May 2013 09:41:23 +0800 From: Wenchao Xia 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> <519E3024.10904@redhat.com> In-Reply-To: <519E3024.10904@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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: Eric Blake Cc: kwolf@redhat.com, phrdina@redhat.com, stefanha@gmail.com, qemu-devel@nongnu.org, lcapitulino@redhat.com, pbonzini@redhat.com, armbru@redhat.com 于 2013-5-23 23:05, Eric Blake 写道: > 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 message_vprintf(), >> which is a static function added in this patch. >> >> Signed-off-by: Wenchao Xia >> --- >> include/qemu/error-report.h | 13 +++++++++++++ >> util/qemu-error.c | 28 ++++++++++++++++++++++++++-- >> 2 files changed, 39 insertions(+), 2 deletions(-) >> >> +++ b/util/qemu-error.c >> @@ -13,6 +13,25 @@ >> #include >> #include "monitor/monitor.h" >> >> +static GCC_FMT_ATTR(2, 0) >> +void message_vprintf(const QemuOutput *output, const char *fmt, va_list ap) >> +{ >> + if (output->kind == OUTPUT_STREAM) { >> + vfprintf(output->stream, fmt, ap); >> + } else if (output->kind == 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. > It may not have much meaning of returning int now, since underlining function do not support it so no caller can benefit from it. I think a series later for that is better, thanks for your reviewing. > Reviewed-by: Eric Blake > -- Best Regards Wenchao Xia