qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/2] error-report: provide error_report_exit()


From: Peter Xu
Subject: Re: [Qemu-devel] [PATCH 1/2] error-report: provide error_report_exit()
Date: Tue, 16 Aug 2016 20:17:08 +0800
User-agent: Mutt/1.5.24 (2015-08-30)

On Tue, Aug 16, 2016 at 07:53:51PM +0800, Fam Zheng wrote:
> On Tue, 08/16 13:05, Markus Armbruster wrote:
> > Peter Xu <address@hidden> writes:
> > 
> > > 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 <address@hidden>
> > > ---
> > >  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)
> > > +
> > 
> > Let's call it error_report_fatal(), for consistency with error_fatal.

Sure. Actually I don't know whether we will like this serie. Anyway,
let me prepare a v2.

> 
> Do we really need error_report_exit when we already have error_fatal?

error_fatal is the name of a global var, not the function.

> > 
> > Also, please make it a function, not a macro:
> > 
> >     void error_report_fatal(const char *fmt, ...)
> >     {
> >         va_list ap;
> > 
> >         va_start(ap, fmt);
> >         error_vreport(fmt, ap);
> >         va_end(ap);
> >         exit(1);
> >     }

Ok. Thanks!

-- peterx



reply via email to

[Prev in Thread] Current Thread [Next in Thread]