From: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
To: Eric Blake <eblake@redhat.com>
Cc: kwolf@redhat.com, phrdina@redhat.com, stefanha@gmail.com,
qemu-devel@nongnu.org, lcapitulino@redhat.com,
pbonzini@redhat.com, armbru@redhat.com
Subject: Re: [Qemu-devel] [PATCH V2 4/5] util: add new function message_printf()
Date: Fri, 24 May 2013 09:41:23 +0800 [thread overview]
Message-ID: <519EC543.3030800@linux.vnet.ibm.com> (raw)
In-Reply-To: <519E3024.10904@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 <xiawenc@linux.vnet.ibm.com>
>> ---
>> 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 <stdio.h>
>> #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 <eblake@redhat.com>
>
--
Best Regards
Wenchao Xia
next prev parent reply other threads:[~2013-05-24 1:42 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-23 8:47 [Qemu-devel] [PATCH V2 0/5] qapi and snapshot code clean up in block layer Wenchao Xia
2013-05-23 8:47 ` [Qemu-devel] [PATCH V2 1/5] block: drop bs_snapshots global variable Wenchao Xia
2013-05-23 8:47 ` [Qemu-devel] [PATCH V2 2/5] block: move snapshot code in block.c to block/snapshot.c Wenchao Xia
2013-05-24 11:35 ` Stefan Hajnoczi
2013-05-23 8:47 ` [Qemu-devel] [PATCH V2 3/5] block: move qmp and info dump related code to block/qapi.c Wenchao Xia
2013-05-23 8:47 ` [Qemu-devel] [PATCH V2 4/5] util: add new function message_printf() Wenchao Xia
2013-05-23 15:05 ` Eric Blake
2013-05-24 1:41 ` Wenchao Xia [this message]
2013-05-23 17:14 ` Luiz Capitulino
2013-05-24 11:45 ` Stefan Hajnoczi
2013-05-23 8:47 ` [Qemu-devel] [PATCH V2 5/5] block: dump to specified output for bdrv_snapshot_dump() and bdrv_image_info_dump() Wenchao Xia
2013-05-23 15:31 ` Eric Blake
2013-05-24 1:48 ` Wenchao Xia
2013-05-24 2:31 ` Wenchao Xia
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=519EC543.3030800@linux.vnet.ibm.com \
--to=xiawenc@linux.vnet.ibm.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=pbonzini@redhat.com \
--cc=phrdina@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).