setupapi: Get rid of the redundant cDevices parameter to struct device.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
d6a504eaf0
commit
ac1d89fa13
|
@ -104,7 +104,6 @@ struct DeviceInfoSet
|
||||||
DWORD magic; /* if is equal to SETUP_DEVICE_INFO_SET_MAGIC struct is okay */
|
DWORD magic; /* if is equal to SETUP_DEVICE_INFO_SET_MAGIC struct is okay */
|
||||||
GUID ClassGuid;
|
GUID ClassGuid;
|
||||||
HWND hwndParent;
|
HWND hwndParent;
|
||||||
DWORD cDevices;
|
|
||||||
struct list devices;
|
struct list devices;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -670,7 +669,6 @@ static struct device *SETUPDI_CreateDeviceInfo(struct DeviceInfoSet *set,
|
||||||
device->devnode = alloc_devnode(device);
|
device->devnode = alloc_devnode(device);
|
||||||
device->removed = FALSE;
|
device->removed = FALSE;
|
||||||
list_add_tail(&set->devices, &device->entry);
|
list_add_tail(&set->devices, &device->entry);
|
||||||
set->cDevices++;
|
|
||||||
|
|
||||||
SETUPDI_GuidToString(class, guidstr);
|
SETUPDI_GuidToString(class, guidstr);
|
||||||
SETUPDI_SetDeviceRegistryPropertyW(device, SPDRP_CLASSGUID,
|
SETUPDI_SetDeviceRegistryPropertyW(device, SPDRP_CLASSGUID,
|
||||||
|
@ -1289,7 +1287,6 @@ SetupDiCreateDeviceInfoListExW(const GUID *ClassGuid,
|
||||||
memcpy(&list->ClassGuid,
|
memcpy(&list->ClassGuid,
|
||||||
ClassGuid ? ClassGuid : &GUID_NULL,
|
ClassGuid ? ClassGuid : &GUID_NULL,
|
||||||
sizeof(list->ClassGuid));
|
sizeof(list->ClassGuid));
|
||||||
list->cDevices = 0;
|
|
||||||
list_init(&list->devices);
|
list_init(&list->devices);
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
@ -1475,7 +1472,7 @@ BOOL WINAPI SetupDiCreateDeviceInfoW(HDEVINFO devinfo, const WCHAR *name, const
|
||||||
if ((flags & DICD_GENERATE_ID))
|
if ((flags & DICD_GENERATE_ID))
|
||||||
{
|
{
|
||||||
static const WCHAR formatW[] = {'R','O','O','T','\\','%','s','\\','%','0','4','d',0};
|
static const WCHAR formatW[] = {'R','O','O','T','\\','%','s','\\','%','0','4','d',0};
|
||||||
DWORD devId;
|
int instance_id, highest_id = -1;
|
||||||
|
|
||||||
if (strchrW(name, '\\'))
|
if (strchrW(name, '\\'))
|
||||||
{
|
{
|
||||||
|
@ -1483,29 +1480,20 @@ BOOL WINAPI SetupDiCreateDeviceInfoW(HDEVINFO devinfo, const WCHAR *name, const
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (set->cDevices)
|
|
||||||
{
|
|
||||||
DWORD highestDevID = 0;
|
|
||||||
|
|
||||||
LIST_FOR_EACH_ENTRY(device, &set->devices, struct device, entry)
|
LIST_FOR_EACH_ENTRY(device, &set->devices, struct device, entry)
|
||||||
{
|
{
|
||||||
const WCHAR *devName = strrchrW(device->instanceId, '\\');
|
const WCHAR *instance_str = strrchrW(device->instanceId, '\\');
|
||||||
DWORD id;
|
|
||||||
|
|
||||||
if (devName)
|
if (instance_str)
|
||||||
devName++;
|
instance_str++;
|
||||||
else
|
else
|
||||||
devName = device->instanceId;
|
instance_str = device->instanceId;
|
||||||
id = SETUPDI_DevNameToDevID(devName);
|
instance_id = SETUPDI_DevNameToDevID(instance_str);
|
||||||
if (id != 0xffffffff && id > highestDevID)
|
if (instance_id != 0xffffffff && instance_id > highest_id)
|
||||||
highestDevID = id;
|
highest_id = instance_id;
|
||||||
}
|
}
|
||||||
devId = highestDevID + 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
devId = 0;
|
|
||||||
|
|
||||||
if (snprintfW(id, ARRAY_SIZE(id), formatW, name, devId) == -1)
|
if (snprintfW(id, ARRAY_SIZE(id), formatW, name, highest_id + 1) == -1)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_INVALID_DEVINST_NAME);
|
SetLastError(ERROR_INVALID_DEVINST_NAME);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -1646,22 +1634,17 @@ BOOL WINAPI SetupDiEnumDeviceInfo(HDEVINFO devinfo, DWORD index, SP_DEVINFO_DATA
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index >= set->cDevices)
|
|
||||||
{
|
|
||||||
SetLastError(ERROR_NO_MORE_ITEMS);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
LIST_FOR_EACH_ENTRY(device, &set->devices, struct device, entry)
|
LIST_FOR_EACH_ENTRY(device, &set->devices, struct device, entry)
|
||||||
{
|
{
|
||||||
if (i++ == index)
|
if (i++ == index)
|
||||||
{
|
{
|
||||||
copy_device_data(device_data, device);
|
copy_device_data(device_data, device);
|
||||||
break;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
SetLastError(ERROR_NO_MORE_ITEMS);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
|
Loading…
Reference in New Issue