]> granicus.if.org Git - strace/commitdiff
Switch to use of value-indexed xlats for evdev constants
authorEugene Syromyatnikov <evgsyr@gmail.com>
Mon, 2 Apr 2018 19:09:15 +0000 (21:09 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Fri, 27 Apr 2018 00:56:25 +0000 (00:56 +0000)
* xlat/evdev_abs.in: Add "#value_indexed" directive.
* xlat/evdev_autorepeat.in: Likewise.
* xlat/evdev_ff_status.in: Likewise.
* xlat/evdev_keycode.in: Likewise.
* xlat/evdev_leds.in: Likewise.
* xlat/evdev_misc.in: Likewise.
* xlat/evdev_prop.in: Likewise.
* xlat/evdev_relative_axes.in: Likewise.
* xlat/evdev_snd.in: Likewise.
* xlat/evdev_switch.in: Likewise.
* xlat/evdev_sync.in: Likewise.
* xlat/evdev_ff_types.in: Add a comment about sorting.
* evdev.c (keycode_ioctl, keycode_V2_ioctl): Use printxval_index
instead of printxval.
(bit_ioctl): Use XT_SORTED for evdev_ff_types, use XT_INDEXED
for other xlats.
(evdev_read_ioctl): Use XT_INDEXED for all xlats.
* ioctl.c (evdev_decode_number): Use printxval_indexn instead of
printxval for evdev_abs.

14 files changed:
evdev.c
ioctl.c
xlat/evdev_abs.in
xlat/evdev_autorepeat.in
xlat/evdev_ff_status.in
xlat/evdev_ff_types.in
xlat/evdev_keycode.in
xlat/evdev_leds.in
xlat/evdev_misc.in
xlat/evdev_prop.in
xlat/evdev_relative_axes.in
xlat/evdev_snd.in
xlat/evdev_switch.in
xlat/evdev_sync.in

diff --git a/evdev.c b/evdev.c
index bafadbd0d27c6993a65f7b95cbdb0bdf91b91deb..00e8f1705e121322ab791ca71e2774c16cf24924 100644 (file)
--- a/evdev.c
+++ b/evdev.c
@@ -98,7 +98,7 @@ keycode_ioctl(struct tcb *const tcp, const kernel_ulong_t arg)
 
        if (!umove_or_printaddr(tcp, arg, &keycode)) {
                tprintf("[%u, ", keycode[0]);
-               printxval(evdev_keycode, keycode[1], "KEY_???");
+               printxval_index(evdev_keycode, keycode[1], "KEY_???");
                tprints("]");
        }
 
@@ -125,7 +125,7 @@ keycode_V2_ioctl(struct tcb *const tcp, const kernel_ulong_t arg)
                unsigned int i;
 
                tprintf("index=%" PRIu16 ", keycode=", ike.index);
-               printxval(evdev_keycode, ike.keycode, "KEY_???");
+               printxval_index(evdev_keycode, ike.keycode, "KEY_???");
                tprints(", scancode=[");
                for (i = 0; i < ARRAY_SIZE(ike.scancode); i++) {
                        if (i > 0)
@@ -285,34 +285,34 @@ bit_ioctl(struct tcb *const tcp, const unsigned int ev_nr,
        switch (ev_nr) {
                case EV_SYN:
                        return decode_bitset(tcp, arg, evdev_sync,
-                                            SYN_MAX, "SYN_???", XT_NORMAL);
+                                            SYN_MAX, "SYN_???", XT_INDEXED);
                case EV_KEY:
                        return decode_bitset(tcp, arg, evdev_keycode,
-                                            KEY_MAX, "KEY_???", XT_NORMAL);
+                                            KEY_MAX, "KEY_???", XT_INDEXED);
                case EV_REL:
                        return decode_bitset(tcp, arg, evdev_relative_axes,
-                                            REL_MAX, "REL_???", XT_NORMAL);
+                                            REL_MAX, "REL_???", XT_INDEXED);
                case EV_ABS:
                        return decode_bitset(tcp, arg, evdev_abs,
-                                            ABS_MAX, "ABS_???", XT_NORMAL);
+                                            ABS_MAX, "ABS_???", XT_INDEXED);
                case EV_MSC:
                        return decode_bitset(tcp, arg, evdev_misc,
-                                            MSC_MAX, "MSC_???", XT_NORMAL);
+                                            MSC_MAX, "MSC_???", XT_INDEXED);
                case EV_SW:
                        return decode_bitset(tcp, arg, evdev_switch,
-                                            SW_MAX, "SW_???", XT_NORMAL);
+                                            SW_MAX, "SW_???", XT_INDEXED);
                case EV_LED:
                        return decode_bitset(tcp, arg, evdev_leds,
-                                            LED_MAX, "LED_???", XT_NORMAL);
+                                            LED_MAX, "LED_???", XT_INDEXED);
                case EV_SND:
                        return decode_bitset(tcp, arg, evdev_snd,
-                                            SND_MAX, "SND_???", XT_NORMAL);
+                                            SND_MAX, "SND_???", XT_INDEXED);
                case EV_REP:
                        return decode_bitset(tcp, arg, evdev_autorepeat,
-                                            REP_MAX, "REP_???", XT_NORMAL);
+                                            REP_MAX, "REP_???", XT_INDEXED);
                case EV_FF:
                        return decode_bitset(tcp, arg, evdev_ff_types,
-                                            FF_MAX, "FF_???", XT_NORMAL);
+                                            FF_MAX, "FF_???", XT_SORTED);
                case EV_PWR:
                        tprints(", ");
                        printnum_int(tcp, arg, "%d");
@@ -320,7 +320,7 @@ bit_ioctl(struct tcb *const tcp, const unsigned int ev_nr,
                case EV_FF_STATUS:
                        return decode_bitset(tcp, arg, evdev_ff_status,
                                             FF_STATUS_MAX, "FF_STATUS_???",
-                                            XT_NORMAL);
+                                            XT_INDEXED);
                default:
                        tprints(", ");
                        printaddr(arg);
@@ -375,22 +375,22 @@ evdev_read_ioctl(struct tcb *const tcp, const unsigned int code,
                case _IOC_NR(EVIOCGPROP(0)):
                        return decode_bitset(tcp, arg, evdev_prop,
                                             INPUT_PROP_MAX, "PROP_???",
-                                            XT_NORMAL);
+                                            XT_INDEXED);
 # endif
                case _IOC_NR(EVIOCGSND(0)):
                        return decode_bitset(tcp, arg, evdev_snd,
-                                            SND_MAX, "SND_???", XT_NORMAL);
+                                            SND_MAX, "SND_???", XT_INDEXED);
 # ifdef EVIOCGSW
                case _IOC_NR(EVIOCGSW(0)):
                        return decode_bitset(tcp, arg, evdev_switch,
-                                            SW_MAX, "SW_???", XT_NORMAL);
+                                            SW_MAX, "SW_???", XT_INDEXED);
 # endif
                case _IOC_NR(EVIOCGKEY(0)):
                        return decode_bitset(tcp, arg, evdev_keycode,
-                                            KEY_MAX, "KEY_???", XT_NORMAL);
+                                            KEY_MAX, "KEY_???", XT_INDEXED);
                case _IOC_NR(EVIOCGLED(0)):
                        return decode_bitset(tcp, arg, evdev_leds,
-                                            LED_MAX, "LED_???", XT_NORMAL);
+                                            LED_MAX, "LED_???", XT_INDEXED);
        }
 
        /* multi-number fixed-length commands */
diff --git a/ioctl.c b/ioctl.c
index 4cae802c47e8aa9b34c36978ba4f354b56cb7a19..bf4f074be5ea36f7c99901becc06b6116611e460 100644 (file)
--- a/ioctl.c
+++ b/ioctl.c
@@ -87,7 +87,8 @@ evdev_decode_number(const unsigned int code)
        if (_IOC_DIR(code) == _IOC_WRITE) {
                if (nr >= 0xc0 && nr <= 0xc0 + 0x3f) {
                        tprints("EVIOCSABS(");
-                       printxval(evdev_abs, nr - 0xc0, "ABS_???");
+                       printxval_indexn(evdev_abs, evdev_abs_size, nr - 0xc0,
+                                        "ABS_???");
                        tprints(")");
                        return 1;
                }
@@ -103,7 +104,8 @@ evdev_decode_number(const unsigned int code)
                return 1;
        } else if (nr >= 0x40 && nr <= 0x40 + 0x3f) {
                tprints("EVIOCGABS(");
-               printxval(evdev_abs, nr - 0x40, "ABS_???");
+               printxval_indexn(evdev_abs, evdev_abs_size, nr - 0x40,
+                                "ABS_???");
                tprints(")");
                return 1;
        }
index dc80831faa8b75f7bb04b5be1849b6ab315d58a1..d65b8463c3fb818305acd725d641d198044e0490 100644 (file)
@@ -1,3 +1,4 @@
+#value_indexed
 ABS_X                  0x00
 ABS_Y                  0x01
 ABS_Z                  0x02
index fcdd4a6c6607a5060a615c6cb01054d8c543cf6e..7ab7e2e75bf7f365756bd35b88e1e0ad66885bfc 100644 (file)
@@ -1,2 +1,3 @@
+#value_indexed
 REP_DELAY      0x00
 REP_PERIOD     0x01
index 914d2f49801b25bc03abb3d106fc44d5f6cdc09e..1f2815f767ffd83195b857154624b3bee83a6aae 100644 (file)
@@ -1,2 +1,3 @@
+#value_indexed
 FF_STATUS_STOPPED      0x00
 FF_STATUS_PLAYING      0x01
index d88a9b2e9e4d2fa47281e1ed93eeb073e7248a49..72b87c5320abfba69322bbc22cf0b0a412051295 100644 (file)
@@ -1,3 +1,4 @@
+/* sort -k2,2 */
 FF_RUMBLE       0x50
 FF_PERIODIC     0x51
 FF_CONSTANT     0x52
index c0811ba12970d025b3ac0e2b9596ea0e27846076..43989c9f3174aad8d7f7e427592e85a853b06737 100644 (file)
@@ -1,3 +1,4 @@
+#value_indexed
 /* awk '{if (NF>1) {n=strtonum($2)}; printf("%d %s\n", n, $0)}' |sort -s -k1,1n |sed 's/^[0-9]* //' */
 KEY_RESERVED           0
 KEY_ESC                        1
index 7fb9128b646ff1d388e4191d825b587ee8dbf901..6178bbd8ac96e74b4f3a08a0b21ee49a827ad04f 100644 (file)
@@ -1,3 +1,4 @@
+#value_indexed
 LED_NUML       0x00
 LED_CAPSL      0x01
 LED_SCROLLL    0x02
index b9f721399b053b2b7d9ce09b8894042982ad759b..0528092ac76bb457634b6be8848b753bcaa8a6a8 100644 (file)
@@ -1,3 +1,4 @@
+#value_indexed
 MSC_SERIAL     0x00
 MSC_PULSELED   0x01
 MSC_GESTURE    0x02
index 40ce923a3619a8d1ccd202c3c849b647ce20099d..5e7d025c29d6fa8f2efcf126cef192a6102d4c7d 100644 (file)
@@ -1,3 +1,4 @@
+#value_indexed
 INPUT_PROP_POINTER             0
 INPUT_PROP_DIRECT              1
 INPUT_PROP_BUTTONPAD           2
index 02d189d67d0ff50f770074da3c5db2fda8a347ab..4684a5246bb64903ad7efb89ea56e5f98fbf20f5 100644 (file)
@@ -1,3 +1,4 @@
+#value_indexed
 REL_X          0x00
 REL_Y          0x01
 REL_Z          0x02
index 21e8b70ff23301679536be3d366d6d9d4ba70a66..22e51cc15e0aeafd41bb20f08c82aa4cca6d600c 100644 (file)
@@ -1,3 +1,4 @@
+#value_indexed
 SND_CLICK      0x00
 SND_BELL       0x01
 SND_TONE       0x02
index e4eab8591d53b708a3b05b836437966fc055bb7a..8f80872527d05ee9aa3a862b55a2f50545bf2ee2 100644 (file)
@@ -1,3 +1,4 @@
+#value_indexed
 SW_LID                 0x00
 SW_TABLET_MODE         0x01
 SW_HEADPHONE_INSERT    0x02
index 0b8ee32f249cc25a4dfc00f830f15e1ab8678e37..ca9ea50356833e37d367fd9c828629ef57fa3833 100644 (file)
@@ -1,3 +1,4 @@
+#value_indexed
 SYN_REPORT     0
 SYN_CONFIG     1
 SYN_MT_REPORT  2