Avoid initializer index range
authorMichael Forney <mforney@mforney.org>
Mon, 17 Jun 2019 00:14:18 +0000 (17:14 -0700)
committerMichael Forney <mforney@mforney.org>
Thu, 6 Feb 2020 04:31:30 +0000 (20:31 -0800)
This is a GNU C extension, and is not available in ISO C.

Instead, just explicitly initialize other indices to -1.

Signed-off-by: Michael Forney <mforney@mforney.org>
libevdev/make-event-names.py

index 820eb5efcfbea2e5f017d9166ebe16f2e3ffd06a..4d9d807cb8916f40403bd7d4eae9b3a1178997a4 100755 (executable)
@@ -94,11 +94,13 @@ def print_map(bits):
        print("#pragma GCC diagnostic ignored \"-Woverride-init\"")
        print("#endif")
        print("static const int ev_max[EV_MAX + 1] = {")
-       print(" [0 ... EV_MAX] = -1,")
-       for prefix in prefixes:
-               if prefix in ["BTN_", "EV_", "INPUT_PROP_", "MT_TOOL_"]:
-                       continue
-               print(" [EV_%s] = %s_MAX," % (prefix[:-1], prefix[:-1]))
+       for val in range(bits.max_codes["EV_MAX"] + 1):
+               if val in bits.ev:
+                       prefix = bits.ev[val][3:]
+                       if prefix + "_" in prefixes:
+                               print(" %s_MAX," % prefix)
+                               continue
+               print(" -1,")
        print("};")
        print("#if __clang__")
        print("#pragma clang diagnostic pop /* \"-Winitializer-overrides\" */")