[PATCH xorg-gtest 4/6] device: If we can't open the device, it's not the one we want

Peter Hutterer peter.hutterer at who-t.net
Tue Aug 28 23:14:32 PDT 2012


well, or at least we're not sure whether it is, so...

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/device.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/device.cpp b/src/device.cpp
index 5868036..50d0c28 100644
--- a/src/device.cpp
+++ b/src/device.cpp
@@ -69,6 +69,9 @@ static bool event_is_device(const std::string &path,
     bool equal = false;
     int fd = open(path.c_str(), O_RDONLY);
 
+    if (fd == -1)
+      return false;
+
     if (ioctl(fd, EVIOCGNAME(sizeof(device_name)), device_name) != -1 &&
         devname.compare(device_name) == 0) {
       struct stat buf;
-- 
1.7.11.2



More information about the xorg-devel mailing list