From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: armbru@redhat.com, peter.maydell@linaro.org, pbonzini@redhat.com,
famz@redhat.com, peterx@redhat.com
Subject: [Qemu-devel] [PATCH 1/2] error-report: provide error_report_exit()
Date: Thu, 11 Aug 2016 15:37:17 +0800 [thread overview]
Message-ID: <1470901038-9409-2-git-send-email-peterx@redhat.com> (raw)
In-Reply-To: <1470901038-9409-1-git-send-email-peterx@redhat.com>
There are many places in current QEMU codes that needs to print some
error and then quit QEMU. Provide a macro for it.
Also, one coccinelle script is added to convert existing cases to
leverage this new macro.
Signed-off-by: Peter Xu <peterx@redhat.com>
---
include/qemu/error-report.h | 8 ++++++++
scripts/coccinelle/error_report_exit.cocci | 13 +++++++++++++
2 files changed, 21 insertions(+)
create mode 100644 scripts/coccinelle/error_report_exit.cocci
diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h
index 499ec8b..c2d5059 100644
--- a/include/qemu/error-report.h
+++ b/include/qemu/error-report.h
@@ -13,6 +13,8 @@
#ifndef QEMU_ERROR_REPORT_H
#define QEMU_ERROR_REPORT_H
+#include <unistd.h>
+
typedef struct Location {
/* all members are private to qemu-error.c */
enum { LOC_NONE, LOC_CMDLINE, LOC_FILE } kind;
@@ -36,6 +38,12 @@ 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);
+
+#define error_report_exit(...) do { \
+ error_report(__VA_ARGS__); \
+ exit(1); \
+ } while (0)
+
const char *error_get_progname(void);
extern bool enable_timestamp_msg;
diff --git a/scripts/coccinelle/error_report_exit.cocci b/scripts/coccinelle/error_report_exit.cocci
new file mode 100644
index 0000000..49f6c17
--- /dev/null
+++ b/scripts/coccinelle/error_report_exit.cocci
@@ -0,0 +1,13 @@
+@@
+expression list X;
+@@
+
+-error_report(X);
++error_report_exit(X);
+-exit(
+(
+-1
+|
+-EXIT_FAILURE
+)
+-);
--
2.7.4
next prev parent reply other threads:[~2016-08-11 7:37 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-11 7:37 [Qemu-devel] [PATCH 0/2] error-report: introduce error_report_exit() Peter Xu
2016-08-11 7:37 ` Peter Xu [this message]
2016-08-16 11:05 ` [Qemu-devel] [PATCH 1/2] error-report: provide error_report_exit() Markus Armbruster
2016-08-16 11:53 ` Fam Zheng
2016-08-16 12:17 ` Peter Xu
2016-08-16 12:19 ` Fam Zheng
2016-08-16 14:00 ` Peter Xu
2016-08-16 14:01 ` Fam Zheng
2016-08-16 14:45 ` Markus Armbruster
2016-08-17 6:47 ` Peter Xu
2016-08-17 7:33 ` Markus Armbruster
2016-08-17 7:38 ` Peter Xu
2016-08-17 8:17 ` Peter Xu
2016-08-17 9:26 ` Markus Armbruster
2016-08-17 9:32 ` Peter Xu
2016-08-11 7:37 ` [Qemu-devel] [PATCH 2/2] error-report: leveraging error_report_exit() Peter Xu
2016-08-11 7:55 ` [Qemu-devel] [PATCH v2] " Peter Xu
2016-08-11 8:01 ` no-reply
2016-08-11 8:47 ` Peter Xu
2016-08-11 8:45 ` Fam Zheng
2016-08-11 8:58 ` Peter Xu
2016-08-11 7:50 ` [Qemu-devel] [PATCH 0/2] error-report: introduce error_report_exit() 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=1470901038-9409-2-git-send-email-peterx@redhat.com \
--to=peterx@redhat.com \
--cc=armbru@redhat.com \
--cc=famz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--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 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).