mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 22:00:13 +01:00
util/format: Assert that formats are valid
It should be the responsibility of the driver to make sure, that "format" is a valid pipe_format. 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>
This commit is contained in:
parent
2b02ac2779
commit
e342081c37
1 changed files with 4 additions and 8 deletions
|
|
@ -176,23 +176,19 @@ def write_format_table(formats):
|
|||
suffix = ""
|
||||
if type == "unpack_":
|
||||
suffix = "_generic"
|
||||
print("const struct util_format_%sdescription *" % type)
|
||||
print("ATTRIBUTE_RETURNS_NONNULL const struct util_format_%sdescription *" % type)
|
||||
print("util_format_%sdescription%s(enum pipe_format format)" % (type, suffix))
|
||||
print("{")
|
||||
print(" if (format >= ARRAY_SIZE(util_format_%sdescriptions))" % (type))
|
||||
print(" return NULL;")
|
||||
print()
|
||||
print(" assert(format < PIPE_FORMAT_COUNT);")
|
||||
print(" return &util_format_%sdescriptions[format];" % (type))
|
||||
print("}")
|
||||
print()
|
||||
|
||||
def generate_function_getter(func):
|
||||
print("util_format_%s_func_ptr" % func)
|
||||
print("ATTRIBUTE_RETURNS_NONNULL util_format_%s_func_ptr" % func)
|
||||
print("util_format_%s_func(enum pipe_format format)" % (func))
|
||||
print("{")
|
||||
print(" if (format >= ARRAY_SIZE(util_format_%s_table))" % (func))
|
||||
print(" return NULL;")
|
||||
print()
|
||||
print(" assert(format < PIPE_FORMAT_COUNT);")
|
||||
print(" return util_format_%s_table[format];" % (func))
|
||||
print("}")
|
||||
print()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue