Skip to content
Snippets Groups Projects
Commit e342081c authored by Konstantin Seurer's avatar Konstantin Seurer Committed by Marge Bot
Browse files

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: default avatarKonstantin Seurer <konstantin.seurer@gmail.com>
Reviewed-by: default avatarAlyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: default avatarMarek Olšák <marek.olsak@amd.com>
Part-of: <mesa/mesa!17490>
parent 2b02ac27
No related branches found
No related tags found
No related merge requests found
......@@ -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()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment