qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC for-2.7 01/11] qdt: IEEE1275-style device tree uti


From: Markus Armbruster
Subject: Re: [Qemu-devel] [RFC for-2.7 01/11] qdt: IEEE1275-style device tree utility code
Date: Wed, 27 Apr 2016 10:36:05 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Thomas Huth <address@hidden> writes:

> On 27.04.2016 09:28, Markus Armbruster wrote:
>> Thomas Huth <address@hidden> writes:
>> 
>>> On 27.04.2016 08:43, Markus Armbruster wrote:
>>>> David Gibson <address@hidden> writes:
>>>>
>>>>> On Tue, Apr 26, 2016 at 01:00:06PM +0200, Thomas Huth wrote:
>>>>>> On 20.04.2016 04:33, David Gibson wrote:
>>> [...]
>>>>>>> +/*
>>>>>>> + * Property functions
>>>>>>> + */
>>>>>>> +
>>>>>>> +QDTProperty *qdt_new_property(const gchar *name, gconstpointer val, 
>>>>>>> gsize len)
>>>>>>> +{
>>>>>>> +    QDTProperty *prop = g_malloc0(sizeof(*prop) + len);
>>>>>>> +
>>>>>>> +    prop->name = g_strdup(name);
>>>>>>> +    prop->len = len;
>>>>>>> +    memcpy(prop->val, val, len);
>>>>>>> +    return prop;
>>>>>>> +}
>>>>>>> +
>>>>>>> +static QDTProperty *getprop_(const QDTNode *node, const gchar *name)
>>>>>>
>>>>>> Underscore at the end looks somewhat strange ... can't you simply drop 
>>>>>> that?
>>>>>
>>>>> Well.. the idea was that the _ versions are the "internal" ones,
>>>>> whereas external users will generally use the non-underscore version
>>>>
>>>> I've seen that convention used before.  It's fine with me.
>>>
>>> Can't remember to have seen that convention before ... I know that some
>>> people use the underscore at the beginning to mark an internal function,
>>> but at the end?
>>> So if you really want to use the underscore, what about putting it at
>>> the beginning instead?
>> 
>> C99 7.1.3  Reserved identifiers:

Additional context:

            -- All identifiers  that  begin  with  an  underscore  and
               either  an  uppercase  letter or another underscore are
               always reserved for any use.

>>          -- All identifiers  that  begin  with  an  underscore  are
>>             always  reserved for use as identifiers with file scope
>>             in both the ordinary and tag name spaces.
>
> Oh, I always thought that underscore + lowercase letter would still be
> OK for local variables and functions, since for example
> http://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html says:
>
> "In addition to the names documented in this manual, reserved names
> include all external identifiers (global functions and variables) that
> begin with an underscore (‘_’) and all identifiers regardless of use
> that begin with either two underscores or an underscore followed by a
> capital letter are reserved names"
>
> ... that sounds like the underscore rule only applies to global
> functions and variables (and to those where the underscore is followed
> by a capital letter or another underscore).
>
> But if I've got your quote right, a leading underscore _always_
> indicates a reserved name for functions and variables, no matter whether
> they are local or global... Well, you learn something new
> every day :-)

Almost.  Compare the two clauses carefully: the first one reserves "for
any use", the second one "for use as identifiers with file scope in both
the ordinary and tag name spaces."  The difference is the quantifiers
"file scope" and "ordinary and tag name spaces".

The scopes are function, file, block, function prototype (the parameter
list).  See 6.2.1 Scopes of identifiers.

The name spaces are label, struct/union/enum tag, each struct or union
for its members, and ordinary.  See 6.2.3 Name spaces of identifiers.

Thus, the second clause doesn't apply to labels, struct/union members,
and local variables including arguments.

However, if you need to quote three sections of the standard to convince
yourself that an identifier is okay, perhaps you should pick another one
:)



reply via email to

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