test: convert event handling while loops into for loops
authorPeter Hutterer <peter.hutterer@who-t.net>
Thu, 19 Jan 2017 06:52:04 +0000 (16:52 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Thu, 26 Jan 2017 05:43:02 +0000 (15:43 +1000)
No functional changes, just enables us to use 'continue' instead of piling up
negated conditions.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
test/litest.c

index 3bc58d9..ff65587 100644 (file)
@@ -1505,8 +1505,9 @@ litest_slot_start(struct litest_device *d,
                return;
        }
 
-       ev = d->interface->touch_down_events;
-       while (ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1) {
+       for (ev = d->interface->touch_down_events;
+            ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1;
+            ev++) {
                int value = litest_auto_assign_value(d,
                                                     ev,
                                                     slot,
@@ -1514,9 +1515,10 @@ litest_slot_start(struct litest_device *d,
                                                     y,
                                                     axes,
                                                     touching);
-               if (value != LITEST_AUTO_ASSIGN)
-                       litest_event(d, ev->type, ev->code, value);
-               ev++;
+               if (value == LITEST_AUTO_ASSIGN)
+                       continue;
+
+               litest_event(d, ev->type, ev->code, value);
        }
 }
 
@@ -1563,7 +1565,9 @@ litest_touch_up(struct litest_device *d, unsigned int slot)
        } else
                ev = up;
 
-       while (ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1) {
+       for ( /* */;
+            ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1;
+            ev++) {
                int value = litest_auto_assign_value(d,
                                                     ev,
                                                     slot,
@@ -1572,7 +1576,6 @@ litest_touch_up(struct litest_device *d, unsigned int slot)
                                                     NULL,
                                                     false);
                litest_event(d, ev->type, ev->code, value);
-               ev++;
        }
 }
 
@@ -1591,8 +1594,9 @@ litest_slot_move(struct litest_device *d,
                return;
        }
 
-       ev = d->interface->touch_move_events;
-       while (ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1) {
+       for (ev = d->interface->touch_move_events;
+            ev && (int16_t)ev->type != -1 && (int16_t)ev->code != -1;
+            ev++) {
                int value = litest_auto_assign_value(d,
                                                     ev,
                                                     slot,
@@ -1600,9 +1604,10 @@ litest_slot_move(struct litest_device *d,
                                                     y,
                                                     axes,
                                                     touching);
-               if (value != LITEST_AUTO_ASSIGN)
-                       litest_event(d, ev->type, ev->code, value);
-               ev++;
+               if (value == LITEST_AUTO_ASSIGN)
+                       continue;
+
+               litest_event(d, ev->type, ev->code, value);
        }
 }