diff mbox

[v3,2/4] error-report: provide error_report_abort()

Message ID 1471498092-27135-3-git-send-email-peterx@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Xu Aug. 18, 2016, 5:28 a.m. UTC
A twin for error_report_fatal(), for programming errors.

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 include/qemu/error-report.h |  1 +
 util/qemu-error.c           | 12 ++++++++++++
 2 files changed, 13 insertions(+)

Comments

Fam Zheng Sept. 6, 2016, 9:53 a.m. UTC | #1
On Thu, 08/18 13:28, Peter Xu wrote:
> A twin for error_report_fatal(), for programming errors.
> 
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>  include/qemu/error-report.h |  1 +
>  util/qemu-error.c           | 12 ++++++++++++
>  2 files changed, 13 insertions(+)
> 
> diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h
> index eb8260e..51a6f31 100644
> --- a/include/qemu/error-report.h
> +++ b/include/qemu/error-report.h
> @@ -37,6 +37,7 @@ 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);
>  void error_report_fatal(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
> +void error_report_abort(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 81379e1..d1c6b10 100644
> --- a/util/qemu-error.c
> +++ b/util/qemu-error.c
> @@ -11,6 +11,7 @@
>   */
>  
>  #include <unistd.h>
> +#include <stdlib.h>

Not needed, again.

>  #include "qemu/osdep.h"
>  #include "monitor/monitor.h"
>  #include "qemu/error-report.h"
> @@ -249,3 +250,14 @@ void error_report_fatal(const char *fmt, ...)
>  
>      exit(1);
>  }
> +
> +void error_report_abort(const char *fmt, ...)
> +{
> +    va_list ap;
> +
> +    va_start(ap, fmt);
> +    error_vreport(fmt, ap);
> +    va_end(ap);
> +
> +    abort();
> +}
> -- 
> 2.7.4
>
Peter Xu Sept. 6, 2016, 10:20 a.m. UTC | #2
On Tue, Sep 06, 2016 at 05:53:26PM +0800, Fam Zheng wrote:
> On Thu, 08/18 13:28, Peter Xu wrote:
> > A twin for error_report_fatal(), for programming errors.
> > 
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> > ---
> >  include/qemu/error-report.h |  1 +
> >  util/qemu-error.c           | 12 ++++++++++++
> >  2 files changed, 13 insertions(+)
> > 
> > diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h
> > index eb8260e..51a6f31 100644
> > --- a/include/qemu/error-report.h
> > +++ b/include/qemu/error-report.h
> > @@ -37,6 +37,7 @@ 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);
> >  void error_report_fatal(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
> > +void error_report_abort(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 81379e1..d1c6b10 100644
> > --- a/util/qemu-error.c
> > +++ b/util/qemu-error.c
> > @@ -11,6 +11,7 @@
> >   */
> >  
> >  #include <unistd.h>
> > +#include <stdlib.h>
> 
> Not needed, again.

Will remove above two lines. Thanks!

-- peterx
diff mbox

Patch

diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h
index eb8260e..51a6f31 100644
--- a/include/qemu/error-report.h
+++ b/include/qemu/error-report.h
@@ -37,6 +37,7 @@  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);
 void error_report_fatal(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
+void error_report_abort(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 81379e1..d1c6b10 100644
--- a/util/qemu-error.c
+++ b/util/qemu-error.c
@@ -11,6 +11,7 @@ 
  */
 
 #include <unistd.h>
+#include <stdlib.h>
 #include "qemu/osdep.h"
 #include "monitor/monitor.h"
 #include "qemu/error-report.h"
@@ -249,3 +250,14 @@  void error_report_fatal(const char *fmt, ...)
 
     exit(1);
 }
+
+void error_report_abort(const char *fmt, ...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    error_vreport(fmt, ap);
+    va_end(ap);
+
+    abort();
+}