[Mesa-dev] [PATCH 0/3] Fix missing initializer errors in generated tables

Chih-Wei Huang cwhuang at android-x86.org
Tue Jun 6 05:16:13 UTC 2017


2017-06-05 3:57 GMT+08:00 Marek Olšák <maraeo at gmail.com>:
> NAK.
>
> In C/C++, the initializer is used to clear the memory to 0s, thus,
> adding 0s to the initializer is redundant and unnecessary. Empty
> initializer {} is also commonly used instead of memset.

Commonly used doesn't mean it's the right thing.
Otherwise the compiler should not generate such warnings.

The compiler tries to tell you "hey, you may miss setting something?"
If that's what you want (init to 0), please express it explicitly.

It's about readability of the code.
When people like me read the code,
I have exact the same question as the compiler:
"does the developer forget to set something?"

> You need to suppress this warning if you don't want to see it.

Not a good suggestion.

Making the code warning-free is the responsibility
of the one who wrote the code instead of
the one who builds the code.

So fix the code, please.

2017-06-05 6:20 GMT+08:00 Emil Velikov <emil.l.velikov at gmail.com>:
> On 4 June 2017 at 21:27, Benedikt Schemmer <ben at besd.de> wrote:
>> Hi all,
>>
>> my reasoning wasn't based on how c handles partial initializations,
>> but on how the generated files look like: like something is missing.
>>
>> Also I don't want to suppress these warnings, because I don't have
>> the experience you have with the codebase and would kind of like to
>> see if my changes have an negative impact or I forgot something.
>>
> Using [C99] designated initalizers should "make things right". Do
> check that the generated files are not included in C++ context, since
> C99 initalizers are not allowed there :-\
>
> Keep in might that explicit [zero] initialization may "force" the
> compiler to generate the actual code, increasing the binary size.

Why should the compiler generate actual code
in this case? I don't believe the compiler is so silly.


> On Sun, Jun 4, 2017 at 9:45 AM, Benedikt Schemmer <ben at besd.de> wrote:
>>
>> I send these patches as a series because they share the same problem:
>> all have missing fields in the default initialization path for field/register
>> definitions.
>>
>> This causes several hundreds (thousands?) of "missing initializer" warnings
>> from the compiler making it hard to spot less frequent errors.
>>
>> This also fixes a small copy and paste error in vk_format_table.py where
>> it isnt clear how it is autogenerated from where.
>>
>> Please kindly review and push if you find this useful.
>>
>> Thanks,
>> Benedikt
>>
>> Benedikt Schemmer (3):
>>   Fix missing initializer warning in sid_tables.h by adding appropriate
>>     default fields in sid_tables.py
>>   Fix missing initializer warning in egd_tables.h by adding appropriate
>>     default fields in egd_tables.py
>>   Fix missing initializer warning in vk_format_table.h by adding
>>     appropriate default fields in vk_format_table.py
>>
>>  src/amd/common/sid_tables.py           | 4 ++--
>>  src/amd/vulkan/vk_format_table.py      | 4 ++--
>>  src/gallium/drivers/r600/egd_tables.py | 4 ++--




-- 
Chih-Wei
Android-x86 project
http://www.android-x86.org


More information about the mesa-dev mailing list