[Mesa-dev] [PATCH 4/6] i965: Replace 0 with ISL_FORMAT_UNSUPPORTED in format table
Matt Turner
mattst88 at gmail.com
Thu Jun 1 06:34:55 UTC 2017
On Wed, May 31, 2017 at 10:42 PM, Jason Ekstrand <jason at jlekstrand.net> wrote:
> On May 31, 2017 9:32:23 PM Ian Romanick <idr at freedesktop.org> wrote:
>
>> Having the unsupported format value not be zero isn't very safe. The
>> C99 rules say that any field missing an initializer is implicitly
>> initialized to zero. If a MESA_FORMAT_ value is added but is not added
>> to the array initializer, we'll have this same problem... but in a way
>> that is much harder to detect.
>
>
> Good point. Chad, how would you feel about leaving things zero and then
> having a loop that walks the array, knows about the one special case, and
> sets all unsupported things to ISL_FORMAT_UNSUPPORTED? Then we get the best
> of both worlds.
You can actually just use the GNU C range initializer and leave the
array static const:
int array[100] = {
[0 ... 99] = -1,
[1] = 1,
[2] = 2,
};
More information about the mesa-dev
mailing list