[PATCH evemu 6/7] tools: handle scanf errors

Peter Hutterer peter.hutterer at who-t.net
Tue Aug 18 18:03:29 PDT 2015


hush little coverity, don't you cry,
that scanf error is not gonna squeeze by

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 tools/find_event_devices.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/find_event_devices.c b/tools/find_event_devices.c
index 36aa3ac..86d4e6a 100644
--- a/tools/find_event_devices.c
+++ b/tools/find_event_devices.c
@@ -79,9 +79,9 @@ char* find_event_devices(void)
 	}
 
 	fprintf(stderr, "Select the device event number [0-%d]: ", max_device);
-	scanf("%d", &devnum);
+	rc = scanf("%d", &devnum);
 
-	if (devnum > max_device || devnum < 0)
+	if (rc != 1 || devnum > max_device || devnum < 0)
 		return NULL;
 
 	asprintf(&filename, "%s/%s%d",
-- 
2.4.3



More information about the Input-tools mailing list