Browse Source

ioctl: do not print comments twice in -Xverbose

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).
Eugene Syromyatnikov 2 months ago
parent
commit
ab86d85790
1 changed files with 16 additions and 4 deletions
  1. 16
    4
      ioctl.c

+ 16
- 4
ioctl.c View File

@@ -51,8 +51,12 @@ ioctl_next_match(const struct_ioctlent *iop)
51 51
 static void
52 52
 ioctl_print_code(const unsigned int code)
53 53
 {
54
+	const bool abbrev = xlat_verbose(xlat_verbosity) != XLAT_STYLE_VERBOSE;
55
+
54 56
 	tprints("_IOC(");
55
-	printflags(ioctl_dirs, _IOC_DIR(code), "_IOC_???");
57
+	printflags_ex(_IOC_DIR(code), abbrev ? "_IOC_???" : NULL,
58
+		      abbrev ? XLAT_STYLE_DEFAULT : XLAT_STYLE_ABBREV,
59
+		      ioctl_dirs, NULL);
56 60
 	tprintf(", %#x, %#x, %#x)",
57 61
 		_IOC_TYPE(code), _IOC_NR(code), _IOC_SIZE(code));
58 62
 }
@@ -61,11 +65,15 @@ static int
61 65
 evdev_decode_number(const unsigned int code)
62 66
 {
63 67
 	const unsigned int nr = _IOC_NR(code);
68
+	const bool abbrev = xlat_verbose(xlat_verbosity) != XLAT_STYLE_VERBOSE;
64 69
 
65 70
 	if (_IOC_DIR(code) == _IOC_WRITE) {
66 71
 		if (nr >= 0xc0 && nr <= 0xc0 + 0x3f) {
67 72
 			tprints("EVIOCSABS(");
68
-			printxval(evdev_abs, nr - 0xc0, "ABS_???");
73
+			printxval_ex(evdev_abs, nr - 0xc0,
74
+				     abbrev ? "ABS_???" : NULL,
75
+				     abbrev ? XLAT_STYLE_DEFAULT
76
+					    : XLAT_STYLE_ABBREV);
69 77
 			tprints(")");
70 78
 			return 1;
71 79
 		}
@@ -79,12 +87,16 @@ evdev_decode_number(const unsigned int code)
79 87
 		if (nr == 0x20)
80 88
 			tprintf("0");
81 89
 		else
82
-			printxval(evdev_ev, nr - 0x20, "EV_???");
90
+			printxval_ex(evdev_ev, nr - 0x20,
91
+				     abbrev ? "EV_???" : NULL,
92
+				     abbrev ? XLAT_STYLE_DEFAULT
93
+					    : XLAT_STYLE_ABBREV);
83 94
 		tprintf(", %u)", _IOC_SIZE(code));
84 95
 		return 1;
85 96
 	} else if (nr >= 0x40 && nr <= 0x40 + 0x3f) {
86 97
 		tprints("EVIOCGABS(");
87
-		printxval(evdev_abs, nr - 0x40, "ABS_???");
98
+		printxval_ex(evdev_abs, nr - 0x40, abbrev ? "ABS_???" : NULL,
99
+			     abbrev ? XLAT_STYLE_DEFAULT : XLAT_STYLE_ABBREV);
88 100
 		tprints(")");
89 101
 		return 1;
90 102
 	}

Loading…
Cancel
Save