From: Peter Xu <peterx@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH RFC] qemu-error: introduce error_report_once
Date: Wed, 16 May 2018 11:07:50 +0800 [thread overview]
Message-ID: <20180516030750.GC9089@xz-mi> (raw)
In-Reply-To: <584bbd99-11dd-8da9-a5b4-de285cebc84d@redhat.com>
On Tue, May 15, 2018 at 10:29:39AM -0500, Eric Blake wrote:
> On 05/15/2018 04:13 AM, Peter Xu wrote:
> > I stole the printk_once() macro.
> >
> > I always wanted to be able to print some error directly if there is a
> > buffer to dump, however we can't use error_report() really quite often
> > when there can be any DDOS attack. To avoid that, we can introduce a
> > print-once function for it.
> >
> > CC: Markus Armbruster <armbru@redhat.com>
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> > ---
> > We can for sure introduce similar functions for the rest of the
> > error_*() functions, it's just an idea to see whether we'd like it
> > in general.
> > ---
> > include/qemu/error-report.h | 12 ++++++++++++
> > 1 file changed, 12 insertions(+)
> >
> > diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h
> > index e1c8ae1a52..efebb80e2c 100644
> > --- a/include/qemu/error-report.h
> > +++ b/include/qemu/error-report.h
> > @@ -44,6 +44,18 @@ void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
> > void warn_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
> > void info_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
> > +#define error_report_once(fmt, ...) \
> > + ({ \
> > + static bool __print_once; \
>
> Double-underscore names are reserved for the compiler's use, not ours.
> Better would be naming this:
>
> static bool print_once_;
>
> with a trailing underscore, or at most a single leading underscore.
>
> > + bool __ret_print_once = !__print_once; \
>
> Same comment for this variable.
Sure!
(I am wondering why Linux is always using that way to name lots of
variables, and I'm surprised that I got 385350 after I run this under
the Linux repo: 'git grep "__[a-z][a-z]" | wc -l', even considering
some false positives)
Thanks,
--
Peter Xu
next prev parent reply other threads:[~2018-05-16 3:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-15 9:13 [Qemu-devel] [PATCH RFC] qemu-error: introduce error_report_once Peter Xu
2018-05-15 9:16 ` no-reply
2018-05-15 12:02 ` Markus Armbruster
2018-05-15 12:38 ` Peter Xu
2018-05-15 15:56 ` Markus Armbruster
2018-05-15 16:39 ` Eric Blake
2018-05-16 3:08 ` Peter Xu
2018-05-15 15:29 ` Eric Blake
2018-05-16 3:07 ` Peter Xu [this message]
2018-05-16 14:02 ` Eric Blake
2018-05-17 2:51 ` Peter Xu
2018-05-31 11:03 ` Stefan Hajnoczi
2018-06-01 3:17 ` Peter Xu
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=20180516030750.GC9089@xz-mi \
--to=peterx@redhat.com \
--cc=armbru@redhat.com \
--cc=eblake@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 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).