From cdfed84d5eb71e73995d2020525e52d49a92725b Mon Sep 17 00:00:00 2001 From: Alessandro Mauri Date: Sat, 2 May 2020 16:04:02 +0200 Subject: [PATCH] redundant message on no devices --- hkd.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/hkd.c b/hkd.c index 2297d3e..212aef8 100644 --- a/hkd.c +++ b/hkd.c @@ -71,8 +71,16 @@ int main (void) struct pollfd *fds = NULL; update_descriptors_list(&fds, &fd_num); - if (!fd_num) { - fputs("Could not open any device, exiting\n", stderr); + if (fd_num) { + fprintf(stderr, + ANSI_COLOR_YELLOW + "Monitoring %d devices\n" + ANSI_COLOR_RESET, fd_num); + } else { + fprintf(stderr, + ANSI_COLOR_RED + "Could not open any devices, exiting\n" + ANSI_COLOR_RESET); exit(-1); } // TODO: watch for events inside /dev/input and reload accordingly @@ -328,7 +336,6 @@ void update_descriptors_list (struct pollfd **fds, int *fd_num) (*fds)[(*fd_num)].fd = tmp_fd; (*fd_num)++; } - fprintf(stderr,ANSI_COLOR_YELLOW "Monitoring %d devices\n" ANSI_COLOR_RESET, (*fd_num)); closedir(ev_dir); }