tools/record: use a pointer to the libinput fd poll entry
authorPeter Hutterer <peter.hutterer@who-t.net>
Mon, 25 Jan 2021 07:12:12 +0000 (17:12 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Thu, 28 Jan 2021 21:31:46 +0000 (07:31 +1000)
No functional changes, this makes the code slightly more readable, especially
once we start adding more "special" fds.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
tools/libinput-record.c

index e64f56d56264dbfda89b8350fbbe5cffc71b15fc..254a54b5d6dae384838b1e482c030324cfb73e10 100644 (file)
@@ -2116,6 +2116,7 @@ mainloop(struct record_context *ctx)
        bool autorestart = (ctx->timeout > 0);
        struct pollfd fds[ctx->ndevices + 2];
        struct pollfd *signal_fd = &fds[0];
+       struct pollfd *libinput_fd = NULL;
        unsigned int nfds = 0;
        struct record_device *d = NULL;
        sigset_t mask;
@@ -2141,9 +2142,8 @@ mainloop(struct record_context *ctx)
        nfds++;
 
        if (ctx->libinput) {
-               fds[1].fd = libinput_get_fd(ctx->libinput);
-               nfds++;
-               assert(nfds == 2);
+               libinput_fd = &fds[nfds++];
+               libinput_fd->fd = libinput_get_fd(ctx->libinput);
        }
 
        list_for_each(d, &ctx->devices, link) {
@@ -2236,7 +2236,7 @@ mainloop(struct record_context *ctx)
 
                        /* This shouldn't pull any events off unless caused
                         * by libinput-internal timeouts (e.g. tapping) */
-                       if (ctx->libinput && fds[1].revents) {
+                       if (ctx->libinput && libinput_fd->revents) {
                                size_t count, offset;
 
                                libinput_dispatch(ctx->libinput);