util/format: Use an explicit length for the descs
authorKonstantin Seurer <konstantin.seurer@gmail.com>
Tue, 12 Jul 2022 11:38:42 +0000 (13:38 +0200)
committerMarge Bot <emma+marge@anholt.net>
Thu, 21 Jul 2022 12:48:01 +0000 (12:48 +0000)
The script that generates the format tables does not set every pipe_format.
In practice, the length of the format tables is equal to PIPE_FORMAT_COUNT.
I just added the explicit size to future-proof it.

(If the largest valid format is not part of the format tables,
 there will be a mismatch between the array length and PIPE_FORMAT_COUNT)

Signed-off-by: Konstantin Seurer <konstantin.seurer@gmail.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17490>

src/util/format/u_format_table.py

index a0943f4..12d365c 100644 (file)
@@ -198,7 +198,7 @@ def write_format_table(formats):
         print()
 
     print('static const struct util_format_description')
-    print('util_format_descriptions[] = {')
+    print('util_format_descriptions[PIPE_FORMAT_COUNT] = {')
     for format in formats:
         sn = format.short_name()
 
@@ -224,7 +224,7 @@ def write_format_table(formats):
     generate_table_getter("")
 
     print('static const struct util_format_pack_description')
-    print('util_format_pack_descriptions[] = {')
+    print('util_format_pack_descriptions[PIPE_FORMAT_COUNT] = {')
     for format in formats:
         sn = format.short_name()
 
@@ -253,7 +253,7 @@ def write_format_table(formats):
     print()
     generate_table_getter("pack_")
     print('static const struct util_format_unpack_description')
-    print('util_format_unpack_descriptions[] = {')
+    print('util_format_unpack_descriptions[PIPE_FORMAT_COUNT] = {')
     for format in formats:
         sn = format.short_name()
 
@@ -293,7 +293,7 @@ def write_format_table(formats):
 
     generate_table_getter("unpack_")
 
-    print('static const util_format_fetch_rgba_func_ptr util_format_fetch_rgba_table[] = {')
+    print('static const util_format_fetch_rgba_func_ptr util_format_fetch_rgba_table[PIPE_FORMAT_COUNT] = {')
     for format in formats:
         sn = format.short_name()