[PATCH libinput] libinput: rewrite loop to make it more readable

Eric Engestrom eric.engestrom at imgtec.com
Wed May 10 10:27:15 UTC 2017


Rewrite
  foo(); while(...) { foo(); }
into
  do { foo(); } while(...);
to avoid duplication and make the flow easier to read and understand.

Signed-off-by: Eric Engestrom <eric.engestrom at imgtec.com>
---
 src/libinput.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/libinput.c b/src/libinput.c
index 472b1c0..e84e3c3 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -54,15 +54,15 @@ check_event_type(struct libinput *libinput,
 	unsigned int type_permitted;
 
 	va_start(args, type_in);
-	type_permitted = va_arg(args, unsigned int);
 
-	while (type_permitted != (unsigned int)-1) {
+	do {
+		type_permitted = va_arg(args, unsigned int);
+
 		if (type_permitted == type_in) {
 			rc = true;
 			break;
 		}
-		type_permitted = va_arg(args, unsigned int);
-	}
+	} while (type_permitted != (unsigned int)-1);
 
 	va_end(args);
 
-- 
Cheers,
  Eric



More information about the wayland-devel mailing list