Mesa (master): vulkan/util: cast enums to int64_t in switch

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Apr 19 06:59:23 UTC 2021


Module: Mesa
Branch: master
Commit: f90d625841363eb95ea69c6e4a8eee4dfdd17619
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f90d625841363eb95ea69c6e4a8eee4dfdd17619

Author: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Date:   Sun Apr 18 12:45:01 2021 +0300

vulkan/util: cast enums to int64_t in switch

With the new Vulkan Video extensions a bunch of enum values have been
added. The problem is that those are behind #ifdef so our generated
code complains that we using enum values not defined.

Since we're not using enum names but integer values, we can silence
all those by casting the enum type to int64_t.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10304>

---

 src/vulkan/util/gen_enum_to_str.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/vulkan/util/gen_enum_to_str.py b/src/vulkan/util/gen_enum_to_str.py
index bfcc466bec3..01f0551d3b8 100644
--- a/src/vulkan/util/gen_enum_to_str.py
+++ b/src/vulkan/util/gen_enum_to_str.py
@@ -72,7 +72,7 @@ C_TEMPLATE = Template(textwrap.dedent(u"""\
     const char *
     vk_${enum.name[2:]}_to_str(${enum.name} input)
     {
-        switch(input) {
+        switch((int64_t)input) {
     % for v in sorted(enum.values.keys()):
         case ${v}:
             return "${enum.values[v]}";



More information about the mesa-commit mailing list