[I8042PRT]
authorThomas Faber <thomas.faber@reactos.org>
Sun, 27 Apr 2014 13:33:42 +0000 (13:33 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Sun, 27 Apr 2014 13:33:42 +0000 (13:33 +0000)
- Fix WDK warnings and remove some unnecessary casts

svn path=/trunk/; revision=63019

reactos/drivers/input/i8042prt/i8042prt.c
reactos/drivers/input/i8042prt/i8042prt.h
reactos/drivers/input/i8042prt/keyboard.c
reactos/drivers/input/i8042prt/misc.c
reactos/drivers/input/i8042prt/mouse.c
reactos/drivers/input/i8042prt/pnp.c

index d9c792b..1fc55e8 100644 (file)
@@ -19,7 +19,9 @@
 
 static DRIVER_STARTIO i8042StartIo;
 static DRIVER_DISPATCH IrpStub;
+_Dispatch_type_(IRP_MJ_DEVICE_CONTROL)
 static DRIVER_DISPATCH i8042DeviceControl;
+_Dispatch_type_(IRP_MJ_INTERNAL_DEVICE_CONTROL)
 static DRIVER_DISPATCH i8042InternalDeviceControl;
 DRIVER_INITIALIZE DriverEntry;
 
index 9247801..6c60ae3 100644 (file)
@@ -292,10 +292,13 @@ typedef struct _I8042_HOOK_WORKITEM
 
 IO_WORKITEM_ROUTINE i8042SendHookWorkItem;
 
+_Dispatch_type_(IRP_MJ_CREATE)
 DRIVER_DISPATCH i8042Create;
 
+_Dispatch_type_(IRP_MJ_CLEANUP)
 DRIVER_DISPATCH i8042Cleanup;
 
+_Dispatch_type_(IRP_MJ_CLOSE)
 DRIVER_DISPATCH i8042Close;
 
 /* keyboard.c */
@@ -371,6 +374,7 @@ i8042ChangeMode(
        IN UCHAR FlagsToDisable,
        IN UCHAR FlagsToEnable);
 
+_Dispatch_type_(IRP_MJ_PNP)
 DRIVER_DISPATCH i8042Pnp;
 
 /* ps2pp.c */
index e59af09..0827a2f 100644 (file)
@@ -21,6 +21,7 @@
 /* GLOBALS *******************************************************************/
 
 static IO_WORKITEM_ROUTINE i8042PowerWorkItem;
+static KDEFERRED_ROUTINE i8042KbdDpcRoutine;
 
 /* This structure starts with the same layout as KEYBOARD_INDICATOR_TRANSLATION */
 typedef struct _LOCAL_KEYBOARD_INDICATOR_TRANSLATION {
@@ -196,10 +197,11 @@ i8042PowerWorkItem(
        PIRP WaitingIrp;
        NTSTATUS Status;
 
-       DeviceExtension = (PI8042_KEYBOARD_EXTENSION)Context;
-
        UNREFERENCED_PARAMETER(DeviceObject);
 
+       __analysis_assume(Context != NULL);
+       DeviceExtension = Context;
+
        /* See http://blogs.msdn.com/doronh/archive/2006/09/08/746961.aspx */
 
        /* Register GUID_DEVICE_SYS_BUTTON interface and report capability */
@@ -331,7 +333,8 @@ i8042KbdDpcRoutine(
        UNREFERENCED_PARAMETER(SystemArgument1);
        UNREFERENCED_PARAMETER(SystemArgument2);
 
-       DeviceExtension = (PI8042_KEYBOARD_EXTENSION)DeferredContext;
+       __analysis_assume(DeferredContext != NULL);
+       DeviceExtension = DeferredContext;
        PortDeviceExtension = DeviceExtension->Common.PortDeviceExtension;
 
        if (HandlePowerKeys(DeviceExtension))
@@ -652,9 +655,6 @@ cleanup:
                        Irp->IoStatus.Information = sizeof(KEYBOARD_ATTRIBUTES);
                        Status = STATUS_SUCCESS;
                        break;
-
-                       Status = STATUS_NOT_IMPLEMENTED;
-                       break;
                }
                case IOCTL_KEYBOARD_QUERY_TYPEMATIC:
                {
@@ -745,9 +745,9 @@ cleanup:
 }
 
 /*
- * Call the customization hook. The ToReturn parameter is about wether
+ * Call the customization hook. The ToReturn parameter is about whether
  * we should go on with the interrupt. The return value is what
- * we should return (indicating to the system wether someone else
+ * we should return (indicating to the system whether someone else
  * should try to handle the interrupt)
  */
 static BOOLEAN
@@ -796,7 +796,8 @@ i8042KbdInterruptService(
 
        UNREFERENCED_PARAMETER(Interrupt);
 
-       DeviceExtension = (PI8042_KEYBOARD_EXTENSION)Context;
+       __analysis_assume(Context != NULL);
+       DeviceExtension = Context;
        PortDeviceExtension = DeviceExtension->Common.PortDeviceExtension;
        InputData = DeviceExtension->KeyboardBuffer + DeviceExtension->KeysInBuffer;
        Counter = PortDeviceExtension->Settings.PollStatusIterations;
index 6b6ad57..3adb2d4 100644 (file)
@@ -23,8 +23,9 @@ ForwardIrpAndWaitCompletion(
        IN PVOID Context)
 {
        UNREFERENCED_PARAMETER(DeviceObject);
+       __analysis_assume(Context != NULL);
        if (Irp->PendingReturned)
-               KeSetEvent((PKEVENT)Context, IO_NO_INCREMENT, FALSE);
+               KeSetEvent(Context, IO_NO_INCREMENT, FALSE);
        return STATUS_MORE_PROCESSING_REQUIRED;
 }
 
index cb66c35..c12a0e9 100644 (file)
@@ -18,6 +18,8 @@
 
 /* FUNCTIONS *****************************************************************/
 
+static KDEFERRED_ROUTINE i8042MouDpcRoutine;
+
 /*
  * These functions are callbacks for filter driver custom interrupt
  * service routines.
@@ -269,7 +271,8 @@ i8042MouDpcRoutine(
        UNREFERENCED_PARAMETER(SystemArgument1);
        UNREFERENCED_PARAMETER(SystemArgument2);
 
-       DeviceExtension = (PI8042_MOUSE_EXTENSION)DeferredContext;
+       __analysis_assume(DeferredContext != NULL);
+       DeviceExtension = DeferredContext;
        PortDeviceExtension = DeviceExtension->Common.PortDeviceExtension;
 
        switch (DeviceExtension->MouseTimeoutState)
@@ -343,6 +346,7 @@ i8042MouDpcRoutine(
  * I'll just send the 'disable mouse port' command to the controller
  * and say the mouse doesn't exist.
  */
+static KDEFERRED_ROUTINE i8042DpcRoutineMouseTimeout;
 static VOID NTAPI
 i8042DpcRoutineMouseTimeout(
        IN PKDPC Dpc,
@@ -358,7 +362,8 @@ i8042DpcRoutineMouseTimeout(
        UNREFERENCED_PARAMETER(SystemArgument1);
        UNREFERENCED_PARAMETER(SystemArgument2);
 
-       DeviceExtension = (PI8042_MOUSE_EXTENSION)DeferredContext;
+       __analysis_assume(DeferredContext != NULL);
+       DeviceExtension = DeferredContext;
        PortDeviceExtension = DeviceExtension->Common.PortDeviceExtension;
 
        Irql = KeAcquireInterruptSpinLock(PortDeviceExtension->HighestDIRQLInterrupt);
@@ -906,7 +911,8 @@ i8042MouInterruptService(
 
        UNREFERENCED_PARAMETER(Interrupt);
 
-       DeviceExtension = (PI8042_MOUSE_EXTENSION)Context;
+       __analysis_assume(Context != NULL);
+       DeviceExtension = Context;
        PortDeviceExtension = DeviceExtension->Common.PortDeviceExtension;
        Counter = PortDeviceExtension->Settings.PollStatusIterations;
 
index 3cb70ca..8dd6f1b 100644 (file)
@@ -112,7 +112,7 @@ i8042BasicDetect(
         }
         else if (Value == KBD_RESEND)
         {
-            TRACE_(I8042PRT, "Resending...\n", Value);
+            TRACE_(I8042PRT, "Resending...\n");
             KeStallExecutionProcessor(50);
         }
         else
@@ -390,7 +390,7 @@ static NTSTATUS
 StartProcedure(
     IN PPORT_DEVICE_EXTENSION DeviceExtension)
 {
-    NTSTATUS Status;
+    NTSTATUS Status = STATUS_UNSUCCESSFUL;
     UCHAR FlagsToDisable = 0;
     UCHAR FlagsToEnable = 0;
     KIRQL Irql;
@@ -495,7 +495,7 @@ i8042PnpStartDevice(
     PFDO_DEVICE_EXTENSION DeviceExtension;
     PPORT_DEVICE_EXTENSION PortDeviceExtension;
     PCM_PARTIAL_RESOURCE_DESCRIPTOR ResourceDescriptor, ResourceDescriptorTranslated;
-    INTERRUPT_DATA InterruptData;
+    INTERRUPT_DATA InterruptData = { NULL };
     BOOLEAN FoundDataPort = FALSE;
     BOOLEAN FoundControlPort = FALSE;
     BOOLEAN FoundIrq = FALSE;
@@ -685,7 +685,9 @@ i8042Pnp(
                     PDEVICE_RELATIONS DeviceRelations;
 
                     TRACE_(I8042PRT, "IRP_MJ_PNP / IRP_MN_QUERY_DEVICE_RELATIONS / BusRelations\n");
-                    DeviceRelations = ExAllocatePool(PagedPool, sizeof(DEVICE_RELATIONS));
+                    DeviceRelations = ExAllocatePoolWithTag(PagedPool,
+                                                            sizeof(DEVICE_RELATIONS),
+                                                            I8042PRT_TAG);
                     if (DeviceRelations)
                     {
                         DeviceRelations->Count = 0;