[PATCH evdev 5/6] Move duplicate check up before mtdev allocation

Peter Hutterer peter.hutterer at who-t.net
Wed Jun 6 18:36:59 PDT 2012


No need to alloc mtdev if we then find out the fd is a duplicate one anyway.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/evdev.c |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/evdev.c b/src/evdev.c
index 39cdcf0..7d1e666 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2346,6 +2346,15 @@ EvdevOpenDevice(InputInfoPtr pInfo)
         }
     }
 
+    /* Check major/minor of device node to avoid adding duplicate devices. */
+    pEvdev->min_maj = EvdevGetMajorMinor(pInfo);
+    if (EvdevIsDuplicate(pInfo))
+    {
+        xf86IDrvMsg(pInfo, X_WARNING, "device file is duplicate. Ignoring.\n");
+        EvdevCloseDevice(pInfo);
+        return BadMatch;
+    }
+
 #ifdef MULTITOUCH
     pEvdev->mtdev = mtdev_new_open(pInfo->fd);
     if (pEvdev->mtdev)
@@ -2357,15 +2366,6 @@ EvdevOpenDevice(InputInfoPtr pInfo)
     }
 #endif
 
-    /* Check major/minor of device node to avoid adding duplicate devices. */
-    pEvdev->min_maj = EvdevGetMajorMinor(pInfo);
-    if (EvdevIsDuplicate(pInfo))
-    {
-        xf86IDrvMsg(pInfo, X_WARNING, "device file is duplicate. Ignoring.\n");
-        EvdevCloseDevice(pInfo);
-        return BadMatch;
-    }
-
     return Success;
 }
 
-- 
1.7.10.2



More information about the xorg-devel mailing list