[PATCH evtest 5/9] Use type/code/prop instead of i/j

Peter Hutterer peter.hutterer at who-t.net
Wed Aug 21 20:46:50 PDT 2013


Slight readability enhancement

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 evtest.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/evtest.c b/evtest.c
index 2887d49..d14f7c4 100644
--- a/evtest.c
+++ b/evtest.c
@@ -757,7 +757,7 @@ static void print_repdata(int fd)
  */
 static int print_device_info(int fd)
 {
-	int i, j;
+	unsigned int type, code, prop;
 	int version;
 	unsigned short id[4];
 	char name[256] = "Unknown";
@@ -785,16 +785,16 @@ static int print_device_info(int fd)
 	ioctl(fd, EVIOCGBIT(0, EV_MAX), bit[0]);
 	printf("Supported events:\n");
 
-	for (i = 0; i < EV_MAX; i++) {
-		if (test_bit(i, bit[0]) && i != EV_REP) {
-			printf("  Event type %d (%s)\n", i, events[i] ? events[i] : "?");
-			if (!i) continue;
-			ioctl(fd, EVIOCGBIT(i, KEY_MAX), bit[i]);
-			for (j = 0; j < KEY_MAX; j++)
-				if (test_bit(j, bit[i])) {
-					printf("    Event code %d (%s)\n", j, names[i] ? (names[i][j] ? names[i][j] : "?") : "?");
-					if (i == EV_ABS)
-						print_absdata(fd, j);
+	for (type = 0; type < EV_MAX; type++) {
+		if (test_bit(type, bit[0]) && type != EV_REP) {
+			printf("  Event type %d (%s)\n", type, events[type] ? events[type] : "?");
+			if (!type) continue;
+			ioctl(fd, EVIOCGBIT(type, KEY_MAX), bit[type]);
+			for (code = 0; code < KEY_MAX; code++)
+				if (test_bit(code, bit[type])) {
+					printf("    Event code %d (%s)\n", code, names[type] ? (names[type][code] ? names[type][code] : "?") : "?");
+					if (type == EV_ABS)
+						print_absdata(fd, code);
 				}
 		}
 	}
@@ -807,9 +807,9 @@ static int print_device_info(int fd)
 		printf("  Property type %d (%s)\n", EV_REP, events[EV_REP] ?  events[EV_REP] : "?");
 		print_repdata(fd);
 	}
-	for (i = 0; i < INPUT_PROP_MAX; i++) {
-		if (test_bit(i, propbits))
-			printf("  Property type %d (%s)\n", i, props[i] ?  props[i] : "?");
+	for (prop = 0; prop < INPUT_PROP_MAX; prop++) {
+		if (test_bit(prop, propbits))
+			printf("  Property type %d (%s)\n", prop, props[prop] ? props[prop] : "?");
 	}
 #endif
 
-- 
1.8.2.1



More information about the Input-tools mailing list