On Tue, Jun 6, 2017 at 7:16 AM, Chih-Wei Huang <cwhu...@android-x86.org> wrote:
> 2017-06-05 3:57 GMT+08:00 Marek Olšák <mar...@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.

No, the code is OK. Do we get a warning for every memset we use? No,
we don't. {} is like memset. Always has been.

The warning is an optional feature of the compiler. Somebody thought that would
be useful, so they put it in there, but in this case it's not.

Marek
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to