mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 17:52:56 +00:00
[KMTESTS:IO] Fix a Clang-Cl warning about NameLength
"warning: variable 'NameLength' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]" CORE-14306
This commit is contained in:
parent
0cc3f19b80
commit
45aa179386
1 changed files with 39 additions and 27 deletions
|
@ -27,12 +27,13 @@ QueryFileInfo(
|
||||||
Buffer = KmtAllocateGuarded(*Length);
|
Buffer = KmtAllocateGuarded(*Length);
|
||||||
if (skip(Buffer != NULL, "Failed to allocate %Iu bytes\n", *Length))
|
if (skip(Buffer != NULL, "Failed to allocate %Iu bytes\n", *Length))
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
|
||||||
|
RtlFillMemory(Buffer, *Length, 0xdd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Buffer = NULL;
|
Buffer = NULL;
|
||||||
}
|
}
|
||||||
RtlFillMemory(Buffer, *Length, 0xDD);
|
|
||||||
RtlFillMemory(&IoStatus, sizeof(IoStatus), 0x55);
|
RtlFillMemory(&IoStatus, sizeof(IoStatus), 0x55);
|
||||||
_SEH2_TRY
|
_SEH2_TRY
|
||||||
{
|
{
|
||||||
|
@ -55,8 +56,16 @@ QueryFileInfo(
|
||||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
Status = IoStatus.Status;
|
Status = IoStatus.Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
*Length = IoStatus.Information;
|
*Length = IoStatus.Information;
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
*Info = Buffer;
|
*Info = Buffer;
|
||||||
|
}
|
||||||
|
else if (Buffer)
|
||||||
|
{
|
||||||
|
KmtFreeGuarded(Buffer);
|
||||||
|
}
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,8 +149,11 @@ TestAllInformation(VOID)
|
||||||
Length = FIELD_OFFSET(FILE_ALL_INFORMATION, NameInformation.FileName) + MAX_PATH * sizeof(WCHAR);
|
Length = FIELD_OFFSET(FILE_ALL_INFORMATION, NameInformation.FileName) + MAX_PATH * sizeof(WCHAR);
|
||||||
Status = QueryFileInfo(FileHandle, (PVOID*)&FileAllInfo, &Length, FileAllInformation);
|
Status = QueryFileInfo(FileHandle, (PVOID*)&FileAllInfo, &Length, FileAllInformation);
|
||||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
if (!skip(NT_SUCCESS(Status) && FileAllInfo != NULL, "No info\n"))
|
if (skip(NT_SUCCESS(Status) && FileAllInfo != NULL, "No info\n"))
|
||||||
{
|
{
|
||||||
|
goto NoInfo;
|
||||||
|
}
|
||||||
|
|
||||||
NameLength = FileAllInfo->NameInformation.FileNameLength;
|
NameLength = FileAllInfo->NameInformation.FileNameLength;
|
||||||
ok_eq_size(Length, FIELD_OFFSET(FILE_ALL_INFORMATION, NameInformation.FileName) + NameLength);
|
ok_eq_size(Length, FIELD_OFFSET(FILE_ALL_INFORMATION, NameInformation.FileName) + NameLength);
|
||||||
Name = ExAllocatePoolWithTag(PagedPool, NameLength + sizeof(UNICODE_NULL), 'sFmK');
|
Name = ExAllocatePoolWithTag(PagedPool, NameLength + sizeof(UNICODE_NULL), 'sFmK');
|
||||||
|
@ -166,7 +178,6 @@ TestAllInformation(VOID)
|
||||||
ok(FileAllInfo->NameInformation.FileName[NameLength / sizeof(WCHAR)] == 0xdddd,
|
ok(FileAllInfo->NameInformation.FileName[NameLength / sizeof(WCHAR)] == 0xdddd,
|
||||||
"Char past FileName is %x\n",
|
"Char past FileName is %x\n",
|
||||||
FileAllInfo->NameInformation.FileName[NameLength / sizeof(WCHAR)]);
|
FileAllInfo->NameInformation.FileName[NameLength / sizeof(WCHAR)]);
|
||||||
}
|
|
||||||
if (FileAllInfo)
|
if (FileAllInfo)
|
||||||
KmtFreeGuarded(FileAllInfo);
|
KmtFreeGuarded(FileAllInfo);
|
||||||
|
|
||||||
|
@ -210,6 +221,7 @@ TestAllInformation(VOID)
|
||||||
if (FileAllInfo)
|
if (FileAllInfo)
|
||||||
KmtFreeGuarded(FileAllInfo);
|
KmtFreeGuarded(FileAllInfo);
|
||||||
|
|
||||||
|
NoInfo:
|
||||||
Status = ObCloseHandle(FileHandle, KernelMode);
|
Status = ObCloseHandle(FileHandle, KernelMode);
|
||||||
ok_eq_hex(Status, STATUS_SUCCESS);
|
ok_eq_hex(Status, STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue