From: Eric Blake <eblake@redhat.com>
To: Peter Xu <peterx@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 09:02:42 -0500 [thread overview]
Message-ID: <b5eeb9d8-b5d5-ea06-ae09-3bfacb6036e0@redhat.com> (raw)
In-Reply-To: <20180516030750.GC9089@xz-mi>
On 05/15/2018 10:07 PM, Peter Xu wrote:
>>> + 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)
git grep "\b_[_A-Z]" might be a more precise grep for use of reserved
identifiers. The Linux kernel can get away with some uses that qemu
does not, because it is a monolithic low-level project that is closely
tied to rather specific compiler behaviors and does not have to port to
other systems; rather than a user-space application that aims to be
portable to multiple operating systems, compilers, and libc
implementations. Also, grepping for leading double-underscore will have
hits even in qemu, where we ARE taking advantage of a compiler feature
(an obvious example: anywhere we #define a macro wrapper around an
__attribute__ tag - __attribute__ belongs to the namespace reserved for
the compiler, so it makes sense that turning on that compiler feature
requires using the compiler's namespace). Or put another way, grepping
for the use of reserved identifiers is easy, but grepping for where we
are inappropriately declaring something that may collide (rather than
using something that already exists) is a bit harder.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
next prev parent reply other threads:[~2018-05-16 14:02 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
2018-05-16 14:02 ` Eric Blake [this message]
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=b5eeb9d8-b5d5-ea06-ae09-3bfacb6036e0@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=peterx@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).