qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH RFC] qemu-error: introduce error_report_once


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH RFC] qemu-error: introduce error_report_once
Date: Wed, 16 May 2018 09:02:42 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

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



reply via email to

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