Reactos

[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

authored by

Serge Gautherie and committed by
Timo Kreuzer
c5d1638e 77e3fbfa

+17 -12
+17 -12
modules/rostests/kmtests/kmtest_drv/kmtest_fsminifilter.c
··· 1 1 /* 2 - * PROJECT: ReactOS kernel-mode tests - Filter Manager 3 - * LICENSE: GPLv2+ - See COPYING in the top level directory 4 - * PURPOSE: FS Mini-filter wrapper to host the filter manager tests 5 - * PROGRAMMER: Thomas Faber <thomas.faber@reactos.org> 6 - * Ged Murphy <ged.murphy@reactos.org> 2 + * PROJECT: ReactOS kernel-mode tests - Filter Manager 3 + * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) 4 + * PURPOSE: FS Mini-filter wrapper to host the filter manager tests 5 + * COPYRIGHT: Copyright 2017 Thomas Faber <thomas.faber@reactos.org> 6 + * Copyright 2017 Ged Murphy <ged.murphy@reactos.org> 7 7 */ 8 8 9 9 #include <ntifs.h> ··· 39 39 static PDEVICE_OBJECT KmtestDeviceObject; 40 40 static FILTER_DATA FilterData; 41 41 static PFLT_OPERATION_REGISTRATION Callbacks = NULL; 42 + static ULONG CallbacksCount = 0; 42 43 static PFLT_CONTEXT_REGISTRATION Contexts = NULL; 43 44 44 45 static PFLT_CONNECT_NOTIFY FilterConnect = NULL; ··· 296 297 { 297 298 ExFreePoolWithTag(Callbacks, KMTEST_FILTER_POOL_TAG); 298 299 Callbacks = NULL; 300 + CallbacksCount = 0; 299 301 } 300 302 301 303 return STATUS_SUCCESS; ··· 337 339 UNICODE_STRING VolumeName; 338 340 ULONG ReportedSectorSize = 0; 339 341 ULONG SectorSize = 0; 340 - NTSTATUS Status; 342 + NTSTATUS Status = STATUS_SUCCESS; 341 343 342 344 PAGED_CODE(); 343 345 ··· 437 439 _In_ CONST FLT_OPERATION_REGISTRATION *OperationRegistration) 438 440 { 439 441 ULONG Count = 0; 440 - INT i; 442 + ULONG i; 441 443 442 444 if (Callbacks) 443 445 { ··· 461 463 return STATUS_INSUFFICIENT_RESOURCES; 462 464 } 463 465 464 - /* Copy the array, but using the our own pre/post callbacks */ 466 + /* Copy the array, but using our own pre/post callbacks */ 465 467 for (i = 0; i < Count; i++) 466 468 { 467 469 Callbacks[i].MajorFunction = OperationRegistration[i].MajorFunction; ··· 472 474 473 475 /* Terminate the array */ 474 476 Callbacks[Count].MajorFunction = IRP_MJ_OPERATION_END; 477 + 478 + /* Save the count of IRPs, not counting IRP_MJ_OPERATION_END last entry */ 479 + CallbacksCount = Count; 475 480 476 481 return STATUS_SUCCESS; 477 482 } ··· 514 519 { 515 520 FLT_PREOP_CALLBACK_STATUS Status; 516 521 UCHAR MajorFunction; 517 - INT i; 522 + ULONG i; 518 523 519 524 Status = FLT_PREOP_SUCCESS_NO_CALLBACK; 520 525 MajorFunction = Data->Iopb->MajorFunction; 521 526 522 - for (i = 0; i < sizeof(Callbacks) / sizeof(Callbacks[0]); i++) 527 + for (i = 0; i < CallbacksCount; i++) 523 528 { 524 529 if (MajorFunction == Callbacks[i].MajorFunction) 525 530 { ··· 543 548 { 544 549 FLT_POSTOP_CALLBACK_STATUS Status; 545 550 UCHAR MajorFunction; 546 - INT i; 551 + ULONG i; 547 552 548 553 Status = FLT_POSTOP_FINISHED_PROCESSING; 549 554 MajorFunction = Data->Iopb->MajorFunction; 550 555 551 - for (i = 0; i < sizeof(Callbacks) / sizeof(Callbacks[0]); i++) 556 + for (i = 0; i < CallbacksCount; i++) 552 557 { 553 558 if (MajorFunction == Callbacks[i].MajorFunction) 554 559 {