Blob Blame History Raw
From 14685b280fde85a6e801f7fb7d5e579b2ddb3581 Mon Sep 17 00:00:00 2001
From: Ayke van Laethem <aykevanlaethem@gmail.com>
Date: Fri, 28 Jul 2017 18:07:50 +0200
Subject: [PATCH 3/6] plugins: devinput: fix glob "no match" error

See 63e041cc5 and LIRC issue #285 (Debian: #860551)
---
 plugins/devinput.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/plugins/devinput.c b/plugins/devinput.c
index 846a0b70..d4d733a0 100644
--- a/plugins/devinput.c
+++ b/plugins/devinput.c
@@ -247,15 +247,15 @@ static int locate_default_device(char* errmsg, size_t size)
 
 	r = glob("/sys/class/rc/rc0/input[0-9]*/event[0-9]*",
 		 0, NULL, &matches);
-	if (r != 0) {
-		log_perror_warn("Cannot run glob %s", DEV_PATTERN);
+	if (r == GLOB_NOMATCH) {
+		strncpy(errmsg, "No /sys/class/rc/ devices found", size - 1);
 		log_notice("No input device available for devinput driver."
 			   " Consider stopping lircd.socket or reconfigure lirc");
-		snprintf(errmsg, size, "Cannot glob %s", DEV_PATTERN);
 		return 0;
 	}
-	if (matches.gl_pathc == 0) {
-		strncpy(errmsg, "No /sys/class/rc/ devices found", size - 1);
+	if (r != 0) {
+		log_perror_warn("Cannot run glob %s", DEV_PATTERN);
+		snprintf(errmsg, size, "Cannot glob %s", DEV_PATTERN);
 		return 0;
 	}
 	if (matches.gl_pathc > 1) {
-- 
2.20.1