https://git.reactos.org/?p=reactos.git;a=commitdiff;h=085528c31ad8b91ae7af6d...
commit 085528c31ad8b91ae7af6dda9b9faa5c463ade70 Author: Serge Gautherie 32623169+SergeGautherie@users.noreply.github.com AuthorDate: Sun Sep 22 10:25:09 2019 +0200 Commit: Pierre Schweitzer pierre@reactos.org CommitDate: Sun Sep 22 10:25:09 2019 +0200
[MOUNTMGR] HasDriveLetter(): Simplify code by using a for() loop --- drivers/filters/mountmgr/device.c | 4 ++-- drivers/filters/mountmgr/mountmgr.c | 24 +++++++----------------- 2 files changed, 9 insertions(+), 19 deletions(-)
diff --git a/drivers/filters/mountmgr/device.c b/drivers/filters/mountmgr/device.c index ce8f58ce855..8ed81e327d0 100644 --- a/drivers/filters/mountmgr/device.c +++ b/drivers/filters/mountmgr/device.c @@ -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; diff --git a/drivers/filters/mountmgr/mountmgr.c b/drivers/filters/mountmgr/mountmgr.c index c2fc801a478..37c85874c97 100644 --- a/drivers/filters/mountmgr/mountmgr.c +++ b/drivers/filters/mountmgr/mountmgr.c @@ -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; }