[MOUNTMGR] HasDriveLetter(): Simplify code by using a for() loop

This commit is contained in:
Serge Gautherie 2019-09-22 10:25:09 +02:00 committed by Pierre Schweitzer
parent b6654c0fb5
commit 085528c31a
2 changed files with 9 additions and 19 deletions

View file

@ -506,13 +506,13 @@ MountMgrNextDriveLetterWorker(IN PDEVICE_EXTENSION DeviceExtension,
DeviceInformation->LetterAssigned =
DriveLetterInfo->DriveLetterWasAssigned = TRUE;
/* Browse all the symlink to see if there's already a drive letter */
/* Browse all the symlinks to check if there is already a drive letter */
NextEntry = DeviceInformation->SymbolicLinksListHead.Flink;
while (NextEntry != &(DeviceInformation->SymbolicLinksListHead))
{
SymlinkInformation = CONTAINING_RECORD(NextEntry, SYMLINK_INFORMATION, SymbolicLinksListEntry);
/* This is a driver letter & online one, forget about new drive eltter */
/* If this is a drive letter and it is online, forget about new drive letter */
if (IsDriveLetter(&(SymlinkInformation->Name)) && SymlinkInformation->Online)
{
DriveLetterInfo->DriveLetterWasAssigned = FALSE;

View file

@ -89,28 +89,18 @@ HasDriveLetter(IN PDEVICE_INFORMATION DeviceInformation)
PLIST_ENTRY NextEntry;
PSYMLINK_INFORMATION SymlinkInfo;
/* To have a drive letter, a device must have symbolic links */
if (IsListEmpty(&(DeviceInformation->SymbolicLinksListHead)))
{
return FALSE;
}
/* Browse all the links untill a drive letter is found */
NextEntry = &(DeviceInformation->SymbolicLinksListHead);
do
/* Browse all the symlinks to check if there is at least a drive letter */
for (NextEntry = DeviceInformation->SymbolicLinksListHead.Flink;
NextEntry != &DeviceInformation->SymbolicLinksListHead;
NextEntry = NextEntry->Flink)
{
SymlinkInfo = CONTAINING_RECORD(NextEntry, SYMLINK_INFORMATION, SymbolicLinksListEntry);
if (SymlinkInfo->Online)
if (IsDriveLetter(&SymlinkInfo->Name) && SymlinkInfo->Online)
{
if (IsDriveLetter(&(SymlinkInfo->Name)))
{
return TRUE;
}
return TRUE;
}
NextEntry = NextEntry->Flink;
} while (NextEntry != &(DeviceInformation->SymbolicLinksListHead));
}
return FALSE;
}