[Mesa-dev] [PATCH] st/mesa: init hash keys with memset(), not designated initializers

Eric Anholt eric at anholt.net
Tue Mar 12 17:34:57 UTC 2019


Ilia Mirkin <imirkin at alum.mit.edu> writes:

> I believe the distinction here is between initializing all the fields
> and using them individually (thus leaving the padding uninitialized),
> vs using the fields to create a structure to hash as a sequence of
> bytes. For the latter, you really need all the memory initialized, not
> just the "valid" parts of the structure. In at least my mind, it's
> fairly well-established that compilers don't always initialize all of
> a structure's underlying bytes, but I also don't have a specific
> instance of that situation I can point to.
>
> For most usage, foo = {0} is fine since you're not hashing the bytes
> but rather accessing the fields directly. But for hashing, you really
> want all the bits initialized.

Gah.  The commit message even said it was about padding, and I failed to
read.  Sorry for the noise, this does seem right.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20190312/4353c4ce/attachment.sig>


More information about the mesa-dev mailing list