From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38330) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xbq6J-0004li-9n for qemu-devel@nongnu.org; Wed, 08 Oct 2014 08:12:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xbq6C-0004dK-2Q for qemu-devel@nongnu.org; Wed, 08 Oct 2014 08:12:15 -0400 Received: from mail-yh0-x234.google.com ([2607:f8b0:4002:c01::234]:63565) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xbq6B-0004ce-Uw for qemu-devel@nongnu.org; Wed, 08 Oct 2014 08:12:08 -0400 Received: by mail-yh0-f52.google.com with SMTP id f10so414570yha.39 for ; Wed, 08 Oct 2014 05:12:07 -0700 (PDT) Sender: Corey Minyard From: minyard@acm.org Date: Wed, 8 Oct 2014 07:11:54 -0500 Message-Id: <1412770316-5241-2-git-send-email-minyard@acm.org> In-Reply-To: <1412770316-5241-1-git-send-email-minyard@acm.org> References: <1412770316-5241-1-git-send-email-minyard@acm.org> Subject: [Qemu-devel] [PATCH 1/3] qemu-error: Add error_vreport() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, Corey Minyard From: Corey Minyard Needed to nicely print socket error reports. Signed-off-by: Corey Minyard --- include/qemu/error-report.h | 1 + util/qemu-error.c | 23 ++++++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h index 000eae3..7ab2355 100644 --- a/include/qemu/error-report.h +++ b/include/qemu/error-report.h @@ -38,6 +38,7 @@ void error_vprintf(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); void error_printf(const char *fmt, ...) GCC_FMT_ATTR(1, 2); void error_printf_unless_qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2); void error_set_progname(const char *argv0); +void error_vreport(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0); void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2); const char *error_get_progname(void); extern bool enable_timestamp_msg; diff --git a/util/qemu-error.c b/util/qemu-error.c index 7b167fd..9bba5f5 100644 --- a/util/qemu-error.c +++ b/util/qemu-error.c @@ -199,14 +199,13 @@ static void error_print_loc(void) bool enable_timestamp_msg; /* * Print an error message to current monitor if we have one, else to stderr. - * Format arguments like sprintf(). The result should not contain + * Format arguments like vsprintf(). The result should not contain * newlines. * Prepend the current location and append a newline. * It's wrong to call this in a QMP monitor. Use qerror_report() there. */ -void error_report(const char *fmt, ...) +void error_vreport(const char *fmt, va_list ap) { - va_list ap; GTimeVal tv; gchar *timestr; @@ -218,8 +217,22 @@ void error_report(const char *fmt, ...) } error_print_loc(); - va_start(ap, fmt); error_vprintf(fmt, ap); - va_end(ap); error_printf("\n"); } + +/* + * Print an error message to current monitor if we have one, else to stderr. + * Format arguments like sprintf(). The result should not contain + * newlines. + * Prepend the current location and append a newline. + * It's wrong to call this in a QMP monitor. Use qerror_report() there. + */ +void error_report(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + error_vreport(fmt, ap); + va_end(ap); +} -- 1.8.3.1