Re: [PATCH 05/38] refs: create a base class "ref_store" for files_ref_store

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

 



Michael Haggerty <mhagger@xxxxxxxxxxxx> writes:

>>> +
>>> +static struct ref_store *main_ref_store = NULL;
>>> +
>>> +static struct ref_store *submodule_ref_stores = NULL;
>> 
>> Let's let BSS take care of these initialization.
>
> I like the `= NULL` because it expresses "yes, I care about the initial
> values of these variables", which to me is more valuable than saving a
> few bytes in the size of the executable. But in fact, GCC does the
> obvious optimization: it detects that these variables are being
> initialized to zero, and puts them in BSS anyway. I'd be surprised if
> other compilers don't do the same. So I'd prefer to leave this as-is, if
> it's OK with you.

Sorry; I shouldn't have phrased it with BSS, because the main point
of the convention is not about "saving bytes by placing it in BSS".

Lack of "= ..." is a clear-enough clue that the code wants these
pointers initialized to NULL.  And in this snippet:

	static struct foo the_foo;

        static struct foo *default_foo = &the_foo;
        static struct foo *other_foo;

we want the presence of "=" as a clue that something special is
going on only for default_foo (it is not initialied to the nul value
for the type like usual static variables).  If you wrote it this way,

        static struct foo *default_foo = &the_foo;
        static struct foo *other_foo = NULL;

the reader has to say "something funny going on about other_foo?"
when scanning up to "other_foo =" and then "... ah, no that is just
wasted typing and reading, it is left to NULL after all".

So, no, it is not OK with me.

Otherwise I would have said "I wonder if ..." ;-)

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]