Zebediah Figura : setupapi: Use strtoulW().
Alexandre Julliard
julliard at winehq.org
Thu Dec 6 15:24:58 CST 2018
Module: wine
Branch: master
Commit: 26dd015fdd124548fbfa40c199fb489b01deb357
URL: https://source.winehq.org/git/wine.git/?a=commit;h=26dd015fdd124548fbfa40c199fb489b01deb357
Author: Zebediah Figura <z.figura12 at gmail.com>
Date: Wed Dec 5 21:07:53 2018 -0600
setupapi: Use strtoulW().
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/setupapi/devinst.c | 31 +++++--------------------------
1 file changed, 5 insertions(+), 26 deletions(-)
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c
index 5685dc3..38da640 100644
--- a/dlls/setupapi/devinst.c
+++ b/dlls/setupapi/devinst.c
@@ -1412,29 +1412,6 @@ BOOL WINAPI SetupDiCreateDeviceInfoA(HDEVINFO DeviceInfoSet, const char *name,
return ret;
}
-static DWORD SETUPDI_DevNameToDevID(LPCWSTR devName)
-{
- LPCWSTR ptr;
- int devNameLen = lstrlenW(devName);
- DWORD devInst = 0;
- BOOL valid = TRUE;
-
- TRACE("%s\n", debugstr_w(devName));
- for (ptr = devName; valid && *ptr && ptr - devName < devNameLen; )
- {
- if (isdigitW(*ptr))
- {
- devInst *= 10;
- devInst |= *ptr - '0';
- ptr++;
- }
- else
- valid = FALSE;
- }
- TRACE("%d\n", valid ? devInst : 0xffffffff);
- return valid ? devInst : 0xffffffff;
-}
-
/***********************************************************************
* SetupDiCreateDeviceInfoW (SETUPAPI.@)
*/
@@ -1483,14 +1460,16 @@ BOOL WINAPI SetupDiCreateDeviceInfoW(HDEVINFO devinfo, const WCHAR *name, const
LIST_FOR_EACH_ENTRY(device, &set->devices, struct device, entry)
{
const WCHAR *instance_str = strrchrW(device->instanceId, '\\');
+ WCHAR *endptr;
if (instance_str)
instance_str++;
else
instance_str = device->instanceId;
- instance_id = SETUPDI_DevNameToDevID(instance_str);
- if (instance_id != 0xffffffff && instance_id > highest_id)
- highest_id = instance_id;
+
+ instance_id = strtoulW(instance_str, &endptr, 10);
+ if (*instance_str && !*endptr)
+ highest_id = max(highest_id, instance_id);
}
if (snprintfW(id, ARRAY_SIZE(id), formatW, name, highest_id + 1) == -1)
More information about the wine-cvs
mailing list