]> granicus.if.org Git - strace/commitdiff
ioctl: do not print comments twice in -Xverbose
authorEugene Syromyatnikov <evgsyr@gmail.com>
Sat, 7 Sep 2019 15:59:31 +0000 (16:59 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 24 Sep 2019 15:31:28 +0000 (15:31 +0000)
Figure out whether the ioctl code is decoded inside a comment and adjust
printflags/printxval calls accordingly.

* ioctl.c (ioctl_print_code, evdev_decode_number): Add abbrev variable,
set it to true if xlat style is not XLAT_STYLE_VERBOSE, do not provide
dflt and set xlat style to XLAT_STYLE_ABBREV in printflags/printxval
calls (that are now changed to printflags_ex/printxval_ex to accomodate
the change).

ioctl.c

diff --git a/ioctl.c b/ioctl.c
index 75c31e8b1e3f638a19ef668d941f28d5ece72566..0620d94951f29b183f5544fbbd002f587c3b8fc5 100644 (file)
--- a/ioctl.c
+++ b/ioctl.c
@@ -51,8 +51,12 @@ ioctl_next_match(const struct_ioctlent *iop)
 static void
 ioctl_print_code(const unsigned int code)
 {
+       const bool abbrev = xlat_verbose(xlat_verbosity) != XLAT_STYLE_VERBOSE;
+
        tprints("_IOC(");
-       printflags(ioctl_dirs, _IOC_DIR(code), "_IOC_???");
+       printflags_ex(_IOC_DIR(code), abbrev ? "_IOC_???" : NULL,
+                     abbrev ? XLAT_STYLE_DEFAULT : XLAT_STYLE_ABBREV,
+                     ioctl_dirs, NULL);
        tprintf(", %#x, %#x, %#x)",
                _IOC_TYPE(code), _IOC_NR(code), _IOC_SIZE(code));
 }
@@ -61,11 +65,15 @@ static int
 evdev_decode_number(const unsigned int code)
 {
        const unsigned int nr = _IOC_NR(code);
+       const bool abbrev = xlat_verbose(xlat_verbosity) != XLAT_STYLE_VERBOSE;
 
        if (_IOC_DIR(code) == _IOC_WRITE) {
                if (nr >= 0xc0 && nr <= 0xc0 + 0x3f) {
                        tprints("EVIOCSABS(");
-                       printxval(evdev_abs, nr - 0xc0, "ABS_???");
+                       printxval_ex(evdev_abs, nr - 0xc0,
+                                    abbrev ? "ABS_???" : NULL,
+                                    abbrev ? XLAT_STYLE_DEFAULT
+                                           : XLAT_STYLE_ABBREV);
                        tprints(")");
                        return 1;
                }
@@ -79,12 +87,16 @@ evdev_decode_number(const unsigned int code)
                if (nr == 0x20)
                        tprintf("0");
                else
-                       printxval(evdev_ev, nr - 0x20, "EV_???");
+                       printxval_ex(evdev_ev, nr - 0x20,
+                                    abbrev ? "EV_???" : NULL,
+                                    abbrev ? XLAT_STYLE_DEFAULT
+                                           : XLAT_STYLE_ABBREV);
                tprintf(", %u)", _IOC_SIZE(code));
                return 1;
        } else if (nr >= 0x40 && nr <= 0x40 + 0x3f) {
                tprints("EVIOCGABS(");
-               printxval(evdev_abs, nr - 0x40, "ABS_???");
+               printxval_ex(evdev_abs, nr - 0x40, abbrev ? "ABS_???" : NULL,
+                            abbrev ? XLAT_STYLE_DEFAULT : XLAT_STYLE_ABBREV);
                tprints(")");
                return 1;
        }