[KMTEST] Fix 3 Clang-Cl warnings about Status and Callbacks (#502)

* 1 "warning: variable 'Status' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]"
* 2 "warning: comparison of unsigned expression < 0 is always false [-Wtautological-unsigned-zero-compare]"
* Use a consistent type for "i" and fix a comment
* Also update licence header.

CORE-14306
This commit is contained in:
Serge Gautherie 2019-02-24 17:53:39 +01:00 committed by Timo Kreuzer
parent 77e3fbfad5
commit c5d1638e1e

View file

@ -1,9 +1,9 @@
/* /*
* PROJECT: ReactOS kernel-mode tests - Filter Manager * PROJECT: ReactOS kernel-mode tests - Filter Manager
* LICENSE: GPLv2+ - See COPYING in the top level directory * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: FS Mini-filter wrapper to host the filter manager tests * PURPOSE: FS Mini-filter wrapper to host the filter manager tests
* PROGRAMMER: Thomas Faber <thomas.faber@reactos.org> * COPYRIGHT: Copyright 2017 Thomas Faber <thomas.faber@reactos.org>
* Ged Murphy <ged.murphy@reactos.org> * Copyright 2017 Ged Murphy <ged.murphy@reactos.org>
*/ */
#include <ntifs.h> #include <ntifs.h>
@ -39,6 +39,7 @@ static PDRIVER_OBJECT TestDriverObject;
static PDEVICE_OBJECT KmtestDeviceObject; static PDEVICE_OBJECT KmtestDeviceObject;
static FILTER_DATA FilterData; static FILTER_DATA FilterData;
static PFLT_OPERATION_REGISTRATION Callbacks = NULL; static PFLT_OPERATION_REGISTRATION Callbacks = NULL;
static ULONG CallbacksCount = 0;
static PFLT_CONTEXT_REGISTRATION Contexts = NULL; static PFLT_CONTEXT_REGISTRATION Contexts = NULL;
static PFLT_CONNECT_NOTIFY FilterConnect = NULL; static PFLT_CONNECT_NOTIFY FilterConnect = NULL;
@ -296,6 +297,7 @@ FilterUnload(
{ {
ExFreePoolWithTag(Callbacks, KMTEST_FILTER_POOL_TAG); ExFreePoolWithTag(Callbacks, KMTEST_FILTER_POOL_TAG);
Callbacks = NULL; Callbacks = NULL;
CallbacksCount = 0;
} }
return STATUS_SUCCESS; return STATUS_SUCCESS;
@ -337,7 +339,7 @@ FilterInstanceSetup(
UNICODE_STRING VolumeName; UNICODE_STRING VolumeName;
ULONG ReportedSectorSize = 0; ULONG ReportedSectorSize = 0;
ULONG SectorSize = 0; ULONG SectorSize = 0;
NTSTATUS Status; NTSTATUS Status = STATUS_SUCCESS;
PAGED_CODE(); PAGED_CODE();
@ -437,7 +439,7 @@ KmtFilterRegisterCallbacks(
_In_ CONST FLT_OPERATION_REGISTRATION *OperationRegistration) _In_ CONST FLT_OPERATION_REGISTRATION *OperationRegistration)
{ {
ULONG Count = 0; ULONG Count = 0;
INT i; ULONG i;
if (Callbacks) if (Callbacks)
{ {
@ -461,7 +463,7 @@ KmtFilterRegisterCallbacks(
return STATUS_INSUFFICIENT_RESOURCES; 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++) for (i = 0; i < Count; i++)
{ {
Callbacks[i].MajorFunction = OperationRegistration[i].MajorFunction; Callbacks[i].MajorFunction = OperationRegistration[i].MajorFunction;
@ -473,6 +475,9 @@ KmtFilterRegisterCallbacks(
/* Terminate the array */ /* Terminate the array */
Callbacks[Count].MajorFunction = IRP_MJ_OPERATION_END; 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; return STATUS_SUCCESS;
} }
@ -514,12 +519,12 @@ FilterPreOperation(
{ {
FLT_PREOP_CALLBACK_STATUS Status; FLT_PREOP_CALLBACK_STATUS Status;
UCHAR MajorFunction; UCHAR MajorFunction;
INT i; ULONG i;
Status = FLT_PREOP_SUCCESS_NO_CALLBACK; Status = FLT_PREOP_SUCCESS_NO_CALLBACK;
MajorFunction = Data->Iopb->MajorFunction; 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) if (MajorFunction == Callbacks[i].MajorFunction)
{ {
@ -543,12 +548,12 @@ FilterPostOperation(
{ {
FLT_POSTOP_CALLBACK_STATUS Status; FLT_POSTOP_CALLBACK_STATUS Status;
UCHAR MajorFunction; UCHAR MajorFunction;
INT i; ULONG i;
Status = FLT_POSTOP_FINISHED_PROCESSING; Status = FLT_POSTOP_FINISHED_PROCESSING;
MajorFunction = Data->Iopb->MajorFunction; 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) if (MajorFunction == Callbacks[i].MajorFunction)
{ {