https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c5d1638e1eae49af252ca…
commit c5d1638e1eae49af252ca677ef10f72d47579827
Author: Serge Gautherie <32623169+SergeGautherie(a)users.noreply.github.com>
AuthorDate: Sun Feb 24 17:53:39 2019 +0100
Commit: Timo Kreuzer <timo.kreuzer(a)reactos.org>
CommitDate: Sun Feb 24 17:53:38 2019 +0100
[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
---
.../kmtests/kmtest_drv/kmtest_fsminifilter.c | 29 +++++++++++++---------
1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/modules/rostests/kmtests/kmtest_drv/kmtest_fsminifilter.c
b/modules/rostests/kmtests/kmtest_drv/kmtest_fsminifilter.c
index 3bb686de9e..3305e2fe77 100644
--- a/modules/rostests/kmtests/kmtest_drv/kmtest_fsminifilter.c
+++ b/modules/rostests/kmtests/kmtest_drv/kmtest_fsminifilter.c
@@ -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(a)reactos.org>
- * Ged Murphy <ged.murphy(a)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(a)reactos.org>
+ * Copyright 2017 Ged Murphy <ged.murphy(a)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)
{