mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 21:11:54 +00:00
- Remove a LIST_FOR_EACH
- ASSERTify 2 assumptions - Rename "ListEntry" to "NextEntry" for clarification svn path=/trunk/; revision=35542
This commit is contained in:
parent
df9f666602
commit
03d12cf07b
1 changed files with 42 additions and 24 deletions
|
@ -197,7 +197,7 @@ NTAPI
|
||||||
KeRemoveByKeyDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue,
|
KeRemoveByKeyDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue,
|
||||||
IN ULONG SortKey)
|
IN ULONG SortKey)
|
||||||
{
|
{
|
||||||
PLIST_ENTRY ListEntry;
|
PLIST_ENTRY NextEntry;
|
||||||
PKDEVICE_QUEUE_ENTRY ReturnEntry;
|
PKDEVICE_QUEUE_ENTRY ReturnEntry;
|
||||||
KLOCK_QUEUE_HANDLE DeviceLock;
|
KLOCK_QUEUE_HANDLE DeviceLock;
|
||||||
ASSERT_DEVICE_QUEUE(DeviceQueue);
|
ASSERT_DEVICE_QUEUE(DeviceQueue);
|
||||||
|
@ -218,8 +218,8 @@ KeRemoveByKeyDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* If SortKey is greater than the last key, then return the first entry right away */
|
/* If SortKey is greater than the last key, then return the first entry right away */
|
||||||
ListEntry = &DeviceQueue->DeviceListHead;
|
NextEntry = &DeviceQueue->DeviceListHead;
|
||||||
ReturnEntry = CONTAINING_RECORD(ListEntry->Blink,
|
ReturnEntry = CONTAINING_RECORD(NextEntry->Blink,
|
||||||
KDEVICE_QUEUE_ENTRY,
|
KDEVICE_QUEUE_ENTRY,
|
||||||
DeviceListEntry);
|
DeviceListEntry);
|
||||||
|
|
||||||
|
@ -227,24 +227,27 @@ KeRemoveByKeyDeviceQueue(IN PKDEVICE_QUEUE DeviceQueue,
|
||||||
if (ReturnEntry->SortKey <= SortKey)
|
if (ReturnEntry->SortKey <= SortKey)
|
||||||
{
|
{
|
||||||
/* Get the first entry */
|
/* Get the first entry */
|
||||||
ReturnEntry = CONTAINING_RECORD(ListEntry->Flink,
|
ReturnEntry = CONTAINING_RECORD(NextEntry->Flink,
|
||||||
KDEVICE_QUEUE_ENTRY,
|
KDEVICE_QUEUE_ENTRY,
|
||||||
DeviceListEntry);
|
DeviceListEntry);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Loop the list */
|
/* Loop the list */
|
||||||
ListEntry = DeviceQueue->DeviceListHead.Flink;
|
NextEntry = DeviceQueue->DeviceListHead.Flink;
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
|
/* Make sure we don't go beyond the end of the queue */
|
||||||
|
ASSERT(NextEntry != &DeviceQueue->DeviceListHead);
|
||||||
|
|
||||||
/* Get the next entry and check if the key is low enough */
|
/* Get the next entry and check if the key is low enough */
|
||||||
ReturnEntry = CONTAINING_RECORD(ListEntry,
|
ReturnEntry = CONTAINING_RECORD(NextEntry,
|
||||||
KDEVICE_QUEUE_ENTRY,
|
KDEVICE_QUEUE_ENTRY,
|
||||||
DeviceListEntry);
|
DeviceListEntry);
|
||||||
if (SortKey <= ReturnEntry->SortKey) break;
|
if (SortKey <= ReturnEntry->SortKey) break;
|
||||||
|
|
||||||
/* Try the next one */
|
/* Try the next one */
|
||||||
ListEntry = ListEntry->Flink;
|
NextEntry = NextEntry->Flink;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,7 +273,7 @@ NTAPI
|
||||||
KeRemoveByKeyDeviceQueueIfBusy(IN PKDEVICE_QUEUE DeviceQueue,
|
KeRemoveByKeyDeviceQueueIfBusy(IN PKDEVICE_QUEUE DeviceQueue,
|
||||||
IN ULONG SortKey)
|
IN ULONG SortKey)
|
||||||
{
|
{
|
||||||
PLIST_ENTRY ListEntry;
|
PLIST_ENTRY NextEntry;
|
||||||
PKDEVICE_QUEUE_ENTRY ReturnEntry;
|
PKDEVICE_QUEUE_ENTRY ReturnEntry;
|
||||||
KLOCK_QUEUE_HANDLE DeviceLock;
|
KLOCK_QUEUE_HANDLE DeviceLock;
|
||||||
ASSERT_DEVICE_QUEUE(DeviceQueue);
|
ASSERT_DEVICE_QUEUE(DeviceQueue);
|
||||||
|
@ -289,27 +292,42 @@ KeRemoveByKeyDeviceQueueIfBusy(IN PKDEVICE_QUEUE DeviceQueue,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Find entry with SortKey greater than or equal to the passed-in SortKey */
|
/* If SortKey is greater than the last key, then return the first entry right away */
|
||||||
LIST_FOR_EACH(ReturnEntry, &DeviceQueue->DeviceListHead, KDEVICE_QUEUE_ENTRY, DeviceListEntry)
|
NextEntry = &DeviceQueue->DeviceListHead;
|
||||||
{
|
ReturnEntry = CONTAINING_RECORD(NextEntry->Blink,
|
||||||
/* Check if keys match */
|
KDEVICE_QUEUE_ENTRY,
|
||||||
if (ReturnEntry->SortKey >= SortKey)
|
DeviceListEntry);
|
||||||
{
|
|
||||||
/* We found it, so just remove it */
|
|
||||||
RemoveEntryList(&ReturnEntry->DeviceListEntry);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if we found something */
|
/* Check if we can just get the first entry */
|
||||||
if (!ReturnEntry)
|
if (ReturnEntry->SortKey <= SortKey)
|
||||||
{
|
{
|
||||||
/* Not found, return the first entry */
|
/* Get the first entry */
|
||||||
ListEntry = RemoveHeadList(&DeviceQueue->DeviceListHead);
|
ReturnEntry = CONTAINING_RECORD(NextEntry->Flink,
|
||||||
ReturnEntry = CONTAINING_RECORD(ListEntry,
|
|
||||||
KDEVICE_QUEUE_ENTRY,
|
KDEVICE_QUEUE_ENTRY,
|
||||||
DeviceListEntry);
|
DeviceListEntry);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Loop the list */
|
||||||
|
NextEntry = DeviceQueue->DeviceListHead.Flink;
|
||||||
|
while (TRUE)
|
||||||
|
{
|
||||||
|
/* Make sure we don't go beyond the end of the queue */
|
||||||
|
ASSERT(NextEntry != &DeviceQueue->DeviceListHead);
|
||||||
|
|
||||||
|
/* Get the next entry and check if the key is low enough */
|
||||||
|
ReturnEntry = CONTAINING_RECORD(NextEntry,
|
||||||
|
KDEVICE_QUEUE_ENTRY,
|
||||||
|
DeviceListEntry);
|
||||||
|
if (SortKey <= ReturnEntry->SortKey) break;
|
||||||
|
|
||||||
|
/* Try the next one */
|
||||||
|
NextEntry = NextEntry->Flink;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We have an entry, remove it now */
|
||||||
|
RemoveEntryList(&ReturnEntry->DeviceListEntry);
|
||||||
|
|
||||||
/* Set it as non-inserted */
|
/* Set it as non-inserted */
|
||||||
ReturnEntry->Inserted = FALSE;
|
ReturnEntry->Inserted = FALSE;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue