[KMTEST] Fix 3 Clang-Cl warnings about Status and Callbacks (#502)
[reactos.git] / modules / rostests / kmtests / kmtest_drv / kmtest_fsminifilter.c
index 3bb686d..3305e2f 100644 (file)
@@ -1,9 +1,9 @@
 /*
- * PROJECT:         ReactOS kernel-mode tests - Filter Manager
- * LICENSE:         GPLv2+ - See COPYING in the top level directory
- * PURPOSE:         FS Mini-filter wrapper to host the filter manager tests
- * PROGRAMMER:      Thomas Faber <thomas.faber@reactos.org>
- *                  Ged Murphy <ged.murphy@reactos.org>
+ * PROJECT:     ReactOS kernel-mode tests - Filter Manager
+ * LICENSE:     GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
+ * PURPOSE:     FS Mini-filter wrapper to host the filter manager tests
+ * COPYRIGHT:   Copyright 2017 Thomas Faber <thomas.faber@reactos.org>
+ *              Copyright 2017 Ged Murphy <ged.murphy@reactos.org>
  */
 
 #include <ntifs.h>
@@ -39,6 +39,7 @@ static PDRIVER_OBJECT TestDriverObject;
 static PDEVICE_OBJECT KmtestDeviceObject;
 static FILTER_DATA FilterData;
 static PFLT_OPERATION_REGISTRATION Callbacks = NULL;
+static ULONG CallbacksCount = 0;
 static PFLT_CONTEXT_REGISTRATION Contexts = NULL;
 
 static PFLT_CONNECT_NOTIFY FilterConnect = NULL;
@@ -296,6 +297,7 @@ FilterUnload(
     {
         ExFreePoolWithTag(Callbacks, KMTEST_FILTER_POOL_TAG);
         Callbacks = NULL;
+        CallbacksCount = 0;
     }
 
     return STATUS_SUCCESS;
@@ -337,7 +339,7 @@ FilterInstanceSetup(
     UNICODE_STRING VolumeName;
     ULONG ReportedSectorSize = 0;
     ULONG SectorSize = 0;
-    NTSTATUS Status;
+    NTSTATUS Status = STATUS_SUCCESS;
 
     PAGED_CODE();
 
@@ -437,7 +439,7 @@ KmtFilterRegisterCallbacks(
     _In_ CONST FLT_OPERATION_REGISTRATION *OperationRegistration)
 {
     ULONG Count = 0;
-    INT i;
+    ULONG i;
 
     if (Callbacks)
     {
@@ -461,7 +463,7 @@ KmtFilterRegisterCallbacks(
         return STATUS_INSUFFICIENT_RESOURCES;
     }
 
-    /* Copy the array, but using the our own pre/post callbacks */
+    /* Copy the array, but using our own pre/post callbacks */
     for (i = 0; i < Count; i++)
     {
         Callbacks[i].MajorFunction = OperationRegistration[i].MajorFunction;
@@ -473,6 +475,9 @@ KmtFilterRegisterCallbacks(
     /* Terminate the array */
     Callbacks[Count].MajorFunction = IRP_MJ_OPERATION_END;
 
+    /* Save the count of IRPs, not counting IRP_MJ_OPERATION_END last entry */
+    CallbacksCount = Count;
+
     return STATUS_SUCCESS;
 }
 
@@ -514,12 +519,12 @@ FilterPreOperation(
 {
     FLT_PREOP_CALLBACK_STATUS Status;
     UCHAR MajorFunction;
-    INT i;
+    ULONG i;
 
     Status = FLT_PREOP_SUCCESS_NO_CALLBACK;
     MajorFunction = Data->Iopb->MajorFunction;
 
-    for (i = 0; i < sizeof(Callbacks) / sizeof(Callbacks[0]); i++)
+    for (i = 0; i < CallbacksCount; i++)
     {
         if (MajorFunction == Callbacks[i].MajorFunction)
         {
@@ -543,12 +548,12 @@ FilterPostOperation(
 {
     FLT_POSTOP_CALLBACK_STATUS Status;
     UCHAR MajorFunction;
-    INT i;
+    ULONG i;
 
     Status = FLT_POSTOP_FINISHED_PROCESSING;
     MajorFunction = Data->Iopb->MajorFunction;
 
-    for (i = 0; i < sizeof(Callbacks) / sizeof(Callbacks[0]); i++)
+    for (i = 0; i < CallbacksCount; i++)
     {
         if (MajorFunction == Callbacks[i].MajorFunction)
         {