Signed-off-by: Peter Hutterer <[email protected]>
---
 src/wcmValidateDevice.c |   14 ++++----------
 1 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/src/wcmValidateDevice.c b/src/wcmValidateDevice.c
index 3a12efa..2235dd6 100644
--- a/src/wcmValidateDevice.c
+++ b/src/wcmValidateDevice.c
@@ -205,20 +205,14 @@ int wcmDeviceTypeKeys(LocalDevicePtr local, unsigned 
long* keys)
        if (ioctl(fd, TIOCGSERIAL, &tmp) == 0)
        {
                int id, i;
-               char *stopstring, *str = strstr(local->name, "WACf");
 
-               if (str) /* id in name */
-               {
-                       str = str + 4;
-                       if (str)
-                               id = (int)strtol(str, &stopstring, 16);
-
-               }
-               else /* id in file sys/class/tty/%str/device/id */
+               /* check device name for ID first */
+               if (sscanf(local->name, "WACf%x", &id) <= 1)
                {
+                       /* id in file sys/class/tty/%str/device/id */
                        FILE *file;
                        char sysfs_id[256];
-                       str = strstr(device, "ttyS");
+                       char *str = strstr(device, "ttyS");
                        snprintf(sysfs_id, sizeof(sysfs_id),
                                "/sys/class/tty/%s/device/id", str);
                        file = fopen(sysfs_id, "r");
-- 
1.6.6


------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Linuxwacom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to