Commit 26dd015f authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

setupapi: Use strtoulW().

parent cda846b8
...@@ -1412,29 +1412,6 @@ BOOL WINAPI SetupDiCreateDeviceInfoA(HDEVINFO DeviceInfoSet, const char *name, ...@@ -1412,29 +1412,6 @@ BOOL WINAPI SetupDiCreateDeviceInfoA(HDEVINFO DeviceInfoSet, const char *name,
return ret; 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.@) * SetupDiCreateDeviceInfoW (SETUPAPI.@)
*/ */
...@@ -1483,14 +1460,16 @@ BOOL WINAPI SetupDiCreateDeviceInfoW(HDEVINFO devinfo, const WCHAR *name, const ...@@ -1483,14 +1460,16 @@ BOOL WINAPI SetupDiCreateDeviceInfoW(HDEVINFO devinfo, const WCHAR *name, const
LIST_FOR_EACH_ENTRY(device, &set->devices, struct device, entry) LIST_FOR_EACH_ENTRY(device, &set->devices, struct device, entry)
{ {
const WCHAR *instance_str = strrchrW(device->instanceId, '\\'); const WCHAR *instance_str = strrchrW(device->instanceId, '\\');
WCHAR *endptr;
if (instance_str) if (instance_str)
instance_str++; instance_str++;
else else
instance_str = device->instanceId; instance_str = device->instanceId;
instance_id = SETUPDI_DevNameToDevID(instance_str);
if (instance_id != 0xffffffff && instance_id > highest_id) instance_id = strtoulW(instance_str, &endptr, 10);
highest_id = instance_id; if (*instance_str && !*endptr)
highest_id = max(highest_id, instance_id);
} }
if (snprintfW(id, ARRAY_SIZE(id), formatW, name, highest_id + 1) == -1) if (snprintfW(id, ARRAY_SIZE(id), formatW, name, highest_id + 1) == -1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment