[ros-diffs] [tkreuzer] 55651: {MOUNTMGR] - Use portable KeXxxSpinLock, instead of fastcall variants - Fix usage of uninitialized variable - Fix typos in assignments - Fix several integer size bugs - Fix uninit...

tkreuzer at svn.reactos.org tkreuzer at svn.reactos.org
Thu Feb 16 22:03:33 UTC 2012


Author: tkreuzer
Date: Thu Feb 16 22:03:33 2012
New Revision: 55651

URL: http://svn.reactos.org/svn/reactos?rev=55651&view=rev
Log:
{MOUNTMGR]
- Use portable KeXxxSpinLock, instead of fastcall variants
- Fix usage of uninitialized variable
- Fix typos in assignments
- Fix several integer size bugs
- Fix uninitialied variables (and those gcc couldn't identify as initialized)
- Fix MSVC warnings

Modified:
    trunk/reactos/drivers/filters/mountmgr/database.c
    trunk/reactos/drivers/filters/mountmgr/device.c
    trunk/reactos/drivers/filters/mountmgr/mountmgr.c
    trunk/reactos/drivers/filters/mountmgr/notify.c
    trunk/reactos/drivers/filters/mountmgr/symlink.c

Modified: trunk/reactos/drivers/filters/mountmgr/database.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filters/mountmgr/database.c?rev=55651&r1=55650&r2=55651&view=diff
==============================================================================
--- trunk/reactos/drivers/filters/mountmgr/database.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filters/mountmgr/database.c [iso-8859-1] Thu Feb 16 22:03:33 2012
@@ -175,7 +175,9 @@
                         &ByteOffset,
                         NULL);
     /* If it fails or returns inconsistent data, drop it (= truncate) */
-    if (!NT_SUCCESS(Status) || IoStatusBlock.Information != EntrySize || EntrySize < sizeof(DATABASE_ENTRY))
+    if (!NT_SUCCESS(Status) ||
+        (IoStatusBlock.Information != EntrySize) ||
+        (EntrySize < sizeof(DATABASE_ENTRY)) )
     {
         TruncateRemoteDatabase(Database, StartingOffset);
         FreePool(Entry);
@@ -184,7 +186,7 @@
 
     /* Validate entry */
     if (MAX(Entry->SymbolicNameOffset + Entry->SymbolicNameLength,
-            Entry->UniqueIdOffset + Entry->UniqueIdLength) > EntrySize)
+            Entry->UniqueIdOffset + Entry->UniqueIdLength) > (LONG)EntrySize)
     {
         TruncateRemoteDatabase(Database, StartingOffset);
         FreePool(Entry);
@@ -201,10 +203,10 @@
 DeleteRemoteDatabaseEntry(IN HANDLE Database,
                           IN LONG StartingOffset)
 {
-    LONG EndSize;
+    ULONG EndSize;
     PVOID TmpBuffer;
     NTSTATUS Status;
-    LONG DatabaseSize;
+    ULONG DatabaseSize;
     PDATABASE_ENTRY Entry;
     IO_STATUS_BLOCK IoStatusBlock;
     LARGE_INTEGER EndEntriesOffset;
@@ -423,7 +425,8 @@
     /* Acquire workers lock */
     KeWaitForSingleObject(&(DeviceExtension->WorkerSemaphore), Executive, KernelMode, FALSE, NULL);
 
-    OldIrql = KfAcquireSpinLock(&(DeviceExtension->WorkerLock));
+    KeAcquireSpinLock(&(DeviceExtension->WorkerLock), &OldIrql);
+
     /* Ensure there are workers */
     while (!IsListEmpty(&(DeviceExtension->WorkerQueueListHead)))
     {
@@ -433,7 +436,7 @@
                                      RECONCILE_WORK_ITEM,
                                      WorkerQueueListEntry);
 
-        KfReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
+        KeReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
 
         /* Call it */
         WorkItem->WorkerRoutine(WorkItem->Context);
@@ -447,9 +450,9 @@
         }
 
         KeWaitForSingleObject(&(DeviceExtension->WorkerSemaphore), Executive, KernelMode, FALSE, NULL);
-        OldIrql = KfAcquireSpinLock(&(DeviceExtension->WorkerLock));
-    }
-    KfReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
+        KeAcquireSpinLock(&(DeviceExtension->WorkerLock), &OldIrql);
+    }
+    KeReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
 
     InterlockedDecrement(&(DeviceExtension->WorkerReferences));
 
@@ -478,10 +481,10 @@
     }
 
     /* Otherwise queue worker for delayed execution */
-    OldIrql = KfAcquireSpinLock(&(DeviceExtension->WorkerLock));
+    KeAcquireSpinLock(&(DeviceExtension->WorkerLock), &OldIrql);
     InsertTailList(&(DeviceExtension->WorkerQueueListHead),
                    &(WorkItem->WorkerQueueListEntry));
-    KfReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
+    KeReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
 
     KeReleaseSemaphore(&(DeviceExtension->WorkerSemaphore), IO_NO_INCREMENT, 1, FALSE);
 
@@ -638,8 +641,8 @@
     }
 
     /* Return the volume name */
-    VolumeName->Length = FileNameInfo->FileNameLength;
-    VolumeName->MaximumLength = FileNameInfo->FileNameLength + sizeof(WCHAR);
+    VolumeName->Length = (USHORT)FileNameInfo->FileNameLength;
+    VolumeName->MaximumLength = (USHORT)FileNameInfo->FileNameLength + sizeof(WCHAR);
     VolumeName->Buffer = AllocatePool(VolumeName->MaximumLength);
     if (!VolumeName->Buffer)
     {
@@ -993,7 +996,7 @@
     }
     if (Status == STATUS_OBJECT_NAME_NOT_FOUND)
     {
-        Status == STATUS_SUCCESS;
+        Status = STATUS_SUCCESS;
         Complete = TRUE;
     }
     if (!NT_SUCCESS(Status) || Complete)
@@ -1022,7 +1025,7 @@
         }
 
         /* And write them into new database */
-        Length = IoStatusBlock.Information;
+        Length = (ULONG)IoStatusBlock.Information;
         Status = ZwWriteFile(Database,
                              NULL,
                              NULL,
@@ -1228,7 +1231,7 @@
     if (IntUniqueId)
     {
         /* Copy data & return */
-        IntUniqueId->UniqueIdLength = ValueLength;
+        IntUniqueId->UniqueIdLength = (USHORT)ValueLength;
         RtlCopyMemory(&(IntUniqueId->UniqueId), ValueData, ValueLength);
 
         UniqueId = Context;

Modified: trunk/reactos/drivers/filters/mountmgr/device.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filters/mountmgr/device.c?rev=55651&r1=55650&r2=55651&view=diff
==============================================================================
--- trunk/reactos/drivers/filters/mountmgr/device.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filters/mountmgr/device.c [iso-8859-1] Thu Feb 16 22:03:33 2012
@@ -94,7 +94,7 @@
                                  REG_DWORD,
                                  &Value,
                                  sizeof(Value));
-                                 
+
 }
 
 /*
@@ -221,10 +221,10 @@
 MountMgrScrubRegistry(IN PDEVICE_EXTENSION DeviceExtension)
 {
     NTSTATUS Status;
-    BOOLEAN Continue = TRUE;
+    BOOLEAN Continue;
     RTL_QUERY_REGISTRY_TABLE QueryTable[2];
 
-    while (Continue)
+    do
     {
         RtlZeroMemory(QueryTable, sizeof(QueryTable));
         QueryTable[0].QueryRoutine = ScrubRegistryRoutine;
@@ -237,6 +237,7 @@
                                         DeviceExtension,
                                         NULL);
     }
+    while (Continue);
 
     return Status;
 }
@@ -513,7 +514,7 @@
         if (IsDriveLetter(&(SymlinkInformation->Name)) && SymlinkInformation->Online)
         {
             DriveLetterInfo->DriveLetterWasAssigned = FALSE;
-            DriveLetterInfo->CurrentDriveLetter = SymlinkInformation->Name.Buffer[LETTER_POSITION];
+            DriveLetterInfo->CurrentDriveLetter = (CHAR)SymlinkInformation->Name.Buffer[LETTER_POSITION];
             break;
         }
 
@@ -972,8 +973,8 @@
     }
 
     /* We can't go beyond */
-    if (MountPoint->SymbolicLinkNameLength + MountPoint->UniqueIdLength +
-        MountPoint->DeviceNameLength < Stack->Parameters.DeviceIoControl.InputBufferLength)
+    if (((ULONG)MountPoint->SymbolicLinkNameLength + MountPoint->UniqueIdLength +
+        MountPoint->DeviceNameLength) < Stack->Parameters.DeviceIoControl.InputBufferLength)
     {
         return STATUS_INVALID_PARAMETER;
     }
@@ -1234,7 +1235,7 @@
 NTSTATUS
 MountMgrVolumeMountPointChanged(IN PDEVICE_EXTENSION DeviceExtension,
                                 IN PIRP Irp,
-                                IN NTSTATUS LockStatus, 
+                                IN NTSTATUS LockStatus,
                                 OUT PUNICODE_STRING SourceDeviceName,
                                 OUT PUNICODE_STRING SourceSymbolicName,
                                 OUT PUNICODE_STRING TargetVolumeName)
@@ -1265,7 +1266,7 @@
 
     VolumeMountPoint = (PMOUNTMGR_VOLUME_MOUNT_POINT)Irp->AssociatedIrp.SystemBuffer;
 
-    if (VolumeMountPoint->SourceVolumeNameLength + VolumeMountPoint->TargetVolumeNameLength <
+    if (((ULONG)VolumeMountPoint->SourceVolumeNameLength + VolumeMountPoint->TargetVolumeNameLength) <
         Stack->Parameters.DeviceIoControl.InputBufferLength)
     {
         return STATUS_INVALID_PARAMETER;
@@ -1406,7 +1407,7 @@
 
     /* Return symbolic name */
     SourceSymbolicName->Length =
-    SourceSymbolicName->MaximumLength = FileNameInfo->FileNameLength;
+    SourceSymbolicName->MaximumLength = (USHORT)FileNameInfo->FileNameLength;
     SourceSymbolicName->Buffer = (PWSTR)FileNameInfo;
     /* memmove allows memory overlap */
     RtlMoveMemory(SourceSymbolicName->Buffer, FileNameInfo->FileName, SourceSymbolicName->Length);

Modified: trunk/reactos/drivers/filters/mountmgr/mountmgr.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filters/mountmgr/mountmgr.c?rev=55651&r1=55650&r2=55651&view=diff
==============================================================================
--- trunk/reactos/drivers/filters/mountmgr/mountmgr.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filters/mountmgr/mountmgr.c [iso-8859-1] Thu Feb 16 22:03:33 2012
@@ -131,7 +131,7 @@
                          IN UCHAR Letter,
                          IN PMOUNTDEV_UNIQUE_ID UniqueId OPTIONAL)
 {
-    NTSTATUS Status;
+    NTSTATUS Status = STATUS_UNSUCCESSFUL;
 
     /* Allocate a big enough buffer to contain the symbolic link */
     DriveLetter->MaximumLength = sizeof(DosDevices.Buffer) + 3 * sizeof(WCHAR);
@@ -907,7 +907,7 @@
 /*
  * @implemented
  */
-ULONG
+BOOLEAN
 MountmgrReadNoAutoMount(IN PUNICODE_STRING RegistryPath)
 {
     NTSTATUS Status;
@@ -931,10 +931,10 @@
                                     NULL);
     if (!NT_SUCCESS(Status))
     {
-        return Default;
-    }
-
-    return Result;
+        return (Default != 0);
+    }
+
+    return (Result != 0);
 }
 
 /*
@@ -1009,7 +1009,7 @@
 
             if (RtlEqualUnicodeString(&(DeviceInformation->SymbolicName), &(CurrentDevice->SymbolicName), TRUE))
             {
-                break;            
+                break;
             }
         }
 
@@ -1054,7 +1054,7 @@
     /* If it's OK, set it and save its letter (if any) */
     if (SuggestedLinkName.Buffer && IsDriveLetter(&SuggestedLinkName))
     {
-        DeviceInformation->SuggestedDriveLetter = SuggestedLinkName.Buffer[LETTER_POSITION];
+        DeviceInformation->SuggestedDriveLetter = (UCHAR)SuggestedLinkName.Buffer[LETTER_POSITION];
     }
 
     /* Acquire driver exclusively */
@@ -1069,7 +1069,7 @@
 
         if (RtlEqualUnicodeString(&(DeviceInformation->DeviceName), &TargetDeviceName, TRUE))
         {
-            break;            
+            break;
         }
     }
 

Modified: trunk/reactos/drivers/filters/mountmgr/notify.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filters/mountmgr/notify.c?rev=55651&r1=55650&r2=55651&view=diff
==============================================================================
--- trunk/reactos/drivers/filters/mountmgr/notify.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filters/mountmgr/notify.c [iso-8859-1] Thu Feb 16 22:03:33 2012
@@ -107,7 +107,7 @@
     /* First, send the notification */
     SendOnlineNotification(&(WorkItem->SymbolicName));
 
-    OldIrql = KfAcquireSpinLock(&(DeviceExtension->WorkerLock));
+    KeAcquireSpinLock(&(DeviceExtension->WorkerLock), &OldIrql);
     /* If there are no notifications running any longer, reset event */
     if (--DeviceExtension->OnlineNotificationCount == 0)
     {
@@ -120,7 +120,7 @@
         /* Queue a new one for execution */
         Head = RemoveHeadList(&(DeviceExtension->OnlineNotificationListHead));
         NewWorkItem = CONTAINING_RECORD(Head, ONLINE_NOTIFICATION_WORK_ITEM, List);
-        KfReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
+        KeReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
         NewWorkItem->List.Blink = NULL;
         NewWorkItem->List.Flink = NULL;
         ExQueueWorkItem((PWORK_QUEUE_ITEM)NewWorkItem, DelayedWorkQueue);
@@ -129,7 +129,7 @@
     {
         /* Mark it's over */
         DeviceExtension->OnlineNotificationWorkerActive = 0;
-        KfReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
+        KeReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
     }
 
     FreePool(WorkItem->SymbolicName.Buffer);
@@ -171,14 +171,14 @@
     RtlCopyMemory(WorkItem->SymbolicName.Buffer, SymbolicName->Buffer, SymbolicName->Length);
     WorkItem->SymbolicName.Buffer[SymbolicName->Length / sizeof(WCHAR)] = UNICODE_NULL;
 
-    OldIrql = KfAcquireSpinLock(&(DeviceExtension->WorkerLock));
+    KeAcquireSpinLock(&(DeviceExtension->WorkerLock), &OldIrql);
     DeviceExtension->OnlineNotificationCount++;
 
     /* If no worker are active */
     if (DeviceExtension->OnlineNotificationWorkerActive == 0)
     {
         /* Queue that one for execution */
-        DeviceExtension->OnlineNotificationWorkerActive == 1;
+        DeviceExtension->OnlineNotificationWorkerActive = 1;
         ExQueueWorkItem((PWORK_QUEUE_ITEM)WorkItem, DelayedWorkQueue);
     }
     else
@@ -187,7 +187,7 @@
         InsertTailList(&(DeviceExtension->OnlineNotificationListHead), &(WorkItem->List));
     }
 
-    KfReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
+    KeReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
 
     return;
 }
@@ -202,13 +202,13 @@
 
     KeInitializeEvent(&(DeviceExtension->OnlineNotificationEvent), NotificationEvent, FALSE);
 
-    OldIrql = KfAcquireSpinLock(&(DeviceExtension->WorkerLock));
+    KeAcquireSpinLock(&(DeviceExtension->WorkerLock), &OldIrql);
 
     /* Just wait all the worker are done */
     if (DeviceExtension->OnlineNotificationCount != 1)
     {
         DeviceExtension->OnlineNotificationCount--;
-        KfReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
+        KeReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
 
         KeWaitForSingleObject(&(DeviceExtension->OnlineNotificationEvent),
                               Executive,
@@ -216,11 +216,11 @@
                               FALSE,
                               NULL);
 
-        OldIrql = KfAcquireSpinLock(&(DeviceExtension->WorkerLock));
+        KeAcquireSpinLock(&(DeviceExtension->WorkerLock), &OldIrql);
         DeviceExtension->OnlineNotificationCount++;
     }
 
-    KfReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
+    KeReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
 }
 
 /*
@@ -477,7 +477,7 @@
 VOID
 RemoveWorkItem(IN PUNIQUE_ID_WORK_ITEM WorkItem)
 {
-    PDEVICE_EXTENSION DeviceExtension;
+    PDEVICE_EXTENSION DeviceExtension = WorkItem->DeviceExtension;
 
     KeWaitForSingleObject(&(DeviceExtension->DeviceLock), Executive, KernelMode, FALSE, NULL);
 
@@ -605,7 +605,7 @@
 
     /* Initialize the IRP */
     Irp = WorkItem->Irp;
-    IoInitializeIrp(Irp, IoSizeOfIrp(WorkItem->StackSize), WorkItem->StackSize);
+    IoInitializeIrp(Irp, IoSizeOfIrp(WorkItem->StackSize), (CCHAR)WorkItem->StackSize);
 
     if (InterlockedExchange((PLONG)&(WorkItem->Event), 0) != 0)
     {

Modified: trunk/reactos/drivers/filters/mountmgr/symlink.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filters/mountmgr/symlink.c?rev=55651&r1=55650&r2=55651&view=diff
==============================================================================
--- trunk/reactos/drivers/filters/mountmgr/symlink.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filters/mountmgr/symlink.c [iso-8859-1] Thu Feb 16 22:03:33 2012
@@ -852,7 +852,7 @@
             RemoveEntryList(&(SymlinkInformation->SymbolicLinksListEntry));
             FreePool(SymlinkInformation->Name.Buffer);
             FreePool(SymlinkInformation);
-                
+
             return TRUE;
         }
     }




More information about the Ros-diffs mailing list