All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alistair Francis <alistair.francis@xilinx.com>
To: qemu-devel@nongnu.org, armbru@redhat.com
Cc: alistair.francis@xilinx.com, alistair23@gmail.com
Subject: [Qemu-devel] [RFC v1 2/3] util/qemu-error: Add a warning_report() function
Date: Tue, 27 Jun 2017 13:45:45 -0700	[thread overview]
Message-ID: <4e1eded5cda7b182a8a4cb133b40b2915817b7d1.1498596157.git.alistair.francis@xilinx.com> (raw)
In-Reply-To: <cover.1498596157.git.alistair.francis@xilinx.com>

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 <alistair.francis@xilinx.com>
---

 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

  parent reply	other threads:[~2017-06-27 20:49 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-27 20:45 [Qemu-devel] [RFC v1 0/3] Implement a warning_report function Alistair Francis
2017-06-27 20:45 ` [Qemu-devel] [RFC v1 1/3] util/qemu-error: Rename error_print_loc() to be more generic Alistair Francis
2017-06-28  4:32   ` Philippe Mathieu-Daudé
2017-06-27 20:45 ` Alistair Francis [this message]
2017-06-27 22:21   ` [Qemu-devel] [RFC v1 2/3] util/qemu-error: Add a warning_report() function Thomas Huth
2017-06-28  0:16     ` Alistair Francis
2017-06-28  9:04   ` Daniel P. Berrange
2017-06-28 16:16     ` Alistair Francis
2017-06-28 16:19       ` Daniel P. Berrange
2017-06-29  7:38         ` Markus Armbruster
2017-06-27 20:45 ` [Qemu-devel] [RFC v1 3/3] char-socket: Report TCP socket waiting as a warning Alistair Francis
2017-06-27 21:10   ` Edgar E. Iglesias
2017-06-28  0:17     ` Alistair Francis
2017-06-28  6:15       ` Edgar E. Iglesias
2017-06-28 16:18         ` Alistair Francis
2017-06-28  9:07 ` [Qemu-devel] [RFC v1 0/3] Implement a warning_report function Daniel P. Berrange
2017-06-28 15:49   ` Alistair Francis

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=4e1eded5cda7b182a8a4cb133b40b2915817b7d1.1498596157.git.alistair.francis@xilinx.com \
    --to=alistair.francis@xilinx.com \
    --cc=alistair23@gmail.com \
    --cc=armbru@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.