All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alistair Francis <alistair.francis@xilinx.com>
To: qemu-devel@nongnu.org
Cc: alistair.francis@xilinx.com, alistair23@gmail.com,
	philippe@mathieu-daude.net, berrange@redhat.com,
	armbru@redhat.com
Subject: [Qemu-devel] [PATCH v3 6/8] error: Implement the warn and free Error functions
Date: Tue, 11 Jul 2017 05:07:33 -0700	[thread overview]
Message-ID: <04209f16a478a286268a56357650f213a8167c8a.1499774331.git.alistair.francis@xilinx.com> (raw)
In-Reply-To: <cover.1499774331.git.alistair.francis@xilinx.com>

Implement warn_report_err() and warn_reportf_err() functions which
are the same as the error_report_err() and error_reportf_err()
functions except report a warning instead of an error.

Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---

 include/qapi/error.h  | 11 +++++++++++
 scripts/checkpatch.pl |  1 +
 util/error.c          | 20 ++++++++++++++++++++
 3 files changed, 32 insertions(+)

diff --git a/include/qapi/error.h b/include/qapi/error.h
index 7e532d00e9..af53b34410 100644
--- a/include/qapi/error.h
+++ b/include/qapi/error.h
@@ -267,11 +267,22 @@ void error_free(Error *err);
 void error_free_or_abort(Error **errp);
 
 /*
+ * Convenience function to warn_report() and free @err.
+ */
+void warn_report_err(Error *err);
+
+/*
  * Convenience function to error_report() and free @err.
  */
 void error_report_err(Error *err);
 
 /*
+ * Convenience function to error_prepend(), warn_report() and free @err.
+ */
+void warn_reportf_err(Error *err, const char *fmt, ...)
+    GCC_FMT_ATTR(2, 3);
+
+/*
  * Convenience function to error_prepend(), error_report() and free @err.
  */
 void error_reportf_err(Error *err, const char *fmt, ...)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 60b1f320a1..dba8c84ca5 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2533,6 +2533,7 @@ sub process {
 				error_setg_file_open|
 				error_set|
 				error_prepend|
+				warn_reportf_err|
 				error_reportf_err|
 				error_vreport|
 				report_vreport|
diff --git a/util/error.c b/util/error.c
index 020b86b9f0..3efdd69162 100644
--- a/util/error.c
+++ b/util/error.c
@@ -232,6 +232,15 @@ void error_report_err(Error *err)
     error_free(err);
 }
 
+void warn_report_err(Error *err)
+{
+    warn_report("%s", error_get_pretty(err));
+    if (err->hint) {
+        error_printf_unless_qmp("%s", err->hint->str);
+    }
+    error_free(err);
+}
+
 void error_reportf_err(Error *err, const char *fmt, ...)
 {
     va_list ap;
@@ -242,6 +251,17 @@ void error_reportf_err(Error *err, const char *fmt, ...)
     error_report_err(err);
 }
 
+
+void warn_reportf_err(Error *err, const char *fmt, ...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    error_vprepend(&err, fmt, ap);
+    va_end(ap);
+    warn_report_err(err);
+}
+
 void error_free(Error *err)
 {
     if (err) {
-- 
2.11.0

  parent reply	other threads:[~2017-07-11 12:11 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-11 12:07 [Qemu-devel] [PATCH v3 0/8] Implement a warning_report function Alistair Francis
2017-07-11 12:07 ` [Qemu-devel] [PATCH v3 1/8] util/qemu-error: Rename error_print_loc() to be more generic Alistair Francis
2017-07-11 12:07 ` [Qemu-devel] [PATCH v3 2/8] error: Functions to report warnings and informational messages Alistair Francis
2017-07-12  7:57   ` Markus Armbruster
2017-07-12 10:48     ` Alistair Francis
2017-07-11 12:07 ` [Qemu-devel] [PATCH v3 3/8] Convert error_report() to warn_report() Alistair Francis
2017-07-11 16:51   ` Max Reitz
2017-07-12  8:34   ` Markus Armbruster
2017-07-12 10:46     ` Alistair Francis
2017-07-11 12:07 ` [Qemu-devel] [PATCH v3 4/8] hw/i386: Improve some of the warning messages Alistair Francis
2017-07-12  9:39   ` Markus Armbruster
2017-07-12 19:45     ` Eduardo Habkost
2017-07-13  6:24       ` Markus Armbruster
2017-07-13  7:10         ` Alistair Francis
2017-07-11 12:07 ` [Qemu-devel] [PATCH v3 5/8] char-socket: Report TCP socket waiting as information Alistair Francis
2017-07-11 12:07 ` Alistair Francis [this message]
2017-07-11 12:07 ` [Qemu-devel] [PATCH v3 7/8] Convert error_report*_err() to warn_report*_err() Alistair Francis
2017-07-11 12:07 ` [Qemu-devel] [PATCH v3 8/8] error: Add a 'error: ' prefix to error_report() Alistair Francis
2017-07-11 17:44   ` Max Reitz
2017-07-12 12:27     ` Alistair Francis
2017-07-12 12:37       ` Max Reitz
2017-07-12 13:03       ` Markus Armbruster
2017-07-11 13:58 ` [Qemu-devel] [PATCH v3 0/8] Implement a warning_report function no-reply

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=04209f16a478a286268a56357650f213a8167c8a.1499774331.git.alistair.francis@xilinx.com \
    --to=alistair.francis@xilinx.com \
    --cc=alistair23@gmail.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=philippe@mathieu-daude.net \
    --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.