[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v1 2/3] util/qemu-error: Add a warning_report() functi
From: |
Alistair Francis |
Subject: |
[Qemu-devel] [RFC v1 2/3] util/qemu-error: Add a warning_report() function |
Date: |
Tue, 27 Jun 2017 13:45:45 -0700 |
Add a functino which can be used similarly to error_report() execpt to
inform the users about warnings instead of errors.
The warning print does not include the timestamp and instead will
preface the messages with a 'warning: '.
Signed-off-by: Alistair Francis <address@hidden>
---
include/qemu/error-report.h | 2 ++
util/qemu-error.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h
index 3001865896..c2600d2298 100644
--- a/include/qemu/error-report.h
+++ b/include/qemu/error-report.h
@@ -36,7 +36,9 @@ void error_vprintf_unless_qmp(const char *fmt, va_list ap)
GCC_FMT_ATTR(1, 0);
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 warning_vreport(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0);
void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
+void warning_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 1c5e35ecdb..2edd752fec 100644
--- a/util/qemu-error.c
+++ b/util/qemu-error.c
@@ -203,6 +203,23 @@ void error_vreport(const char *fmt, va_list ap)
}
/*
+ * Print a warning message ot the current monitor if we have one, else to
+ * stderr. This follows similar formating and use cases as error_vreport()
+ * except for these two differentce:
+ * - It prefixes the message with 'warning: ' to indicate it is only a
+ * warning.
+ * - It does not print the timestamp.
+ */
+void warning_vreport(const char *fmt, va_list ap)
+{
+ error_vprintf("warning: ", ap);
+
+ print_loc();
+ error_vprintf(fmt, ap);
+ error_printf("\n");
+}
+
+/*
* Print an error message to current monitor if we have one, else to stderr.
* Format arguments like sprintf(). The resulting message should be a
* single phrase, with no newline or trailing punctuation.
@@ -217,3 +234,18 @@ void error_report(const char *fmt, ...)
error_vreport(fmt, ap);
va_end(ap);
}
+
+/*
+ * Print an warning message to current monitor if we have one, else to stderr.
+ * This follows the same formating and use cases as error_report()
+ * except it prefixes the message with 'warning: ' to indicate it is only a
+ * warning.
+ */
+void warning_report(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ warning_vreport(fmt, ap);
+ va_end(ap);
+}
--
2.11.0
[Qemu-devel] [RFC v1 3/3] char-socket: Report TCP socket waiting as a warning, Alistair Francis, 2017/06/27