[Mesa-dev] [PATCH 1/2] util: use memset() to initialize surface, sampler_view templates

Dave Airlie airlied at gmail.com
Tue Jan 10 13:12:36 PST 2012


On Tue, Jan 10, 2012 at 7:27 PM, Marek Olšák <maraeo at gmail.com> wrote:
> On Tue, Jan 10, 2012 at 7:48 PM, Jakob Bornecrantz <jakob at vmware.com> wrote:
>> ----- Original Message -----
>>> These initialization functions weren't initializing all the fields so
>>> some had undefined values.  The callers of these functions sometimes
>>> use a structure assignment to initialize new objects from these
>>> templates so we'd just propagate the undefined values.  That made for
>>> some confusing info when debugging, plus it could lead to bugs.
>>
>> Hmm, in theory doing "struct my_struct strct = { 0 };" should work but
>> as I noticed earlier at least gcc doesn't seem to do what we want in
>> this case.
>
> Long ago I noticed that scons was throwing a warning that a variable
> may have been uninitialized when using the empty initializer {}, but
> it worked fine with make. It seems to be an issue with scons. I am not
> a fan of memset. I prefer {} more, even though it may not be
> C89-friendly.

{0} isn't guaranteed to initialise padding in structs if memory serves.

Dave.


More information about the mesa-dev mailing list