Fix a number of warnings found with VS /analyze

svn path=/trunk/; revision=58318
This commit is contained in:
Timo Kreuzer 2013-02-16 17:21:34 +00:00
parent aa173340b2
commit a087bbe982
16 changed files with 75 additions and 59 deletions

View file

@ -387,7 +387,7 @@ static void free_entity_array(struct entity_array *array)
RtlFreeHeap(RtlGetProcessHeap(), 0, entity->u.clrsurrogate.clsid);
break;
default:
DPRINT1("Unknown entity kind %d\n", entity->kind);
DPRINT1("Unknown entity kind %u\n", entity->kind);
}
}
RtlFreeHeap( RtlGetProcessHeap(), 0, array->base );
@ -788,7 +788,7 @@ static BOOL parse_expect_no_attr(xmlbuf_t* xmlbuf, BOOL* end)
{
attr_nameU = xmlstr2unicode(&attr_name);
attr_valueU = xmlstr2unicode(&attr_name);
DPRINT1( "unexpected attr %S=%S\n", &attr_nameU,
DPRINT1( "unexpected attr %wZ=%wZ\n", &attr_nameU,
&attr_valueU);
}
return !error;
@ -2275,7 +2275,8 @@ NTSTATUS WINAPI RtlCreateActivationContext( HANDLE *handle, void *ptr )
if (pActCtx->dwFlags & ACTCTX_FLAG_HMODULE_VALID) module = pActCtx->hModule;
else module = NtCurrentTeb()->ProcessEnvironmentBlock->ImageBaseAddress;
if ((status = get_module_filename( module, &dir, 0 ))) goto error;
status = get_module_filename(module, &dir, 0);
if (!NT_SUCCESS(status)) goto error;
if ((p = strrchrW( dir.Buffer, '\\' ))) p[1] = 0;
actctx->appdir.info = dir.Buffer;
}
@ -2289,7 +2290,7 @@ NTSTATUS WINAPI RtlCreateActivationContext( HANDLE *handle, void *ptr )
goto error;
}
status = open_nt_file( &file, &nameW );
if (status)
if (!NT_SUCCESS(status))
{
RtlFreeUnicodeString( &nameW );
goto error;
@ -2334,10 +2335,11 @@ NTSTATUS WINAPI RtlCreateActivationContext( HANDLE *handle, void *ptr )
if (file) NtClose( file );
RtlFreeUnicodeString( &nameW );
if (status == STATUS_SUCCESS) status = parse_depend_manifests(&acl);
if (NT_SUCCESS(status)) status = parse_depend_manifests(&acl);
free_depend_manifests( &acl );
if (status == STATUS_SUCCESS) *handle = actctx;
if (NT_SUCCESS(status))
*handle = actctx;
else actctx_release( actctx );
return status;
@ -2498,7 +2500,7 @@ RtlQueryInformationActivationContext( ULONG flags, HANDLE handle, PVOID subinst,
ACTIVATION_CONTEXT *actctx;
NTSTATUS status;
DPRINT("%08x %p %p %u %p %ld %p\n", flags, handle,
DPRINT("%08x %p %p %u %p %Iu %p\n", flags, handle,
subinst, class, buffer, bufsize, retlen);
if (retlen) *retlen = 0;

View file

@ -100,7 +100,7 @@ RtlAssert(IN PVOID FailedAssertion,
#else
if (NULL != Message)
{
DbgPrint("Assertion \'%s\' failed at %s line %d: %s\n",
DbgPrint("Assertion \'%s\' failed at %s line %u: %s\n",
(PCHAR)FailedAssertion,
(PCHAR)FileName,
LineNumber,
@ -108,7 +108,7 @@ RtlAssert(IN PVOID FailedAssertion,
}
else
{
DbgPrint("Assertion \'%s\' failed at %s line %d\n",
DbgPrint("Assertion \'%s\' failed at %s line %u\n",
(PCHAR)FailedAssertion,
(PCHAR)FileName,
LineNumber);

View file

@ -433,6 +433,7 @@ RtlpSysVolTakeOwnership(IN PUNICODE_STRING DirectoryPath,
HANDLE hToken = NULL;
HANDLE hDirectory = NULL;
NTSTATUS Status;
ULONG ReturnLength;
Status = ZwOpenProcessToken(NtCurrentProcess(),
TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES,
@ -452,7 +453,7 @@ RtlpSysVolTakeOwnership(IN PUNICODE_STRING DirectoryPath,
&TokenPrivileges,
sizeof(TokenPrivileges),
&TokenPrivileges,
NULL);
&ReturnLength);
if (!NT_SUCCESS(Status))
{
goto Cleanup;
@ -757,7 +758,7 @@ RtlGetSetBootStatusData(IN HANDLE FileHandle,
LARGE_INTEGER ByteOffset;
NTSTATUS Status;
DPRINT("RtlGetSetBootStatusData (%p %u %u %p %lu %p)\n",
DPRINT("RtlGetSetBootStatusData (%p %u %d %p %lu %p)\n",
FileHandle, WriteMode, DataClass, Buffer, BufferSize, ReturnLength);
if (DataClass >= RtlBsdItemMax)

View file

@ -91,7 +91,7 @@ RtlComputeCrc32(IN ULONG Initial,
{
ULONG CrcValue = ~Initial;
DPRINT("(%d,%p,%d)\n", Initial, Data, Length);
DPRINT("(%u,%p,%u)\n", Initial, Data, Length);
while (Length > 0)
{

View file

@ -238,6 +238,9 @@ RtlIsNameLegalDOS8Dot3(IN PCUNICODE_STRING UnicodeName,
char Buffer[12];
OEM_STRING OemString;
BOOLEAN GotSpace = FALSE;
NTSTATUS Status;
if (SpacesFound) *SpacesFound = FALSE;
if (!AnsiName)
{
@ -246,7 +249,9 @@ RtlIsNameLegalDOS8Dot3(IN PCUNICODE_STRING UnicodeName,
OemString.Buffer = Buffer;
AnsiName = &OemString;
}
if (RtlUpcaseUnicodeStringToCountedOemString( AnsiName, UnicodeName, FALSE ) != STATUS_SUCCESS)
Status = RtlUpcaseUnicodeStringToCountedOemString(AnsiName, UnicodeName, FALSE);
if (!NT_SUCCESS(Status))
return FALSE;
if ((AnsiName->Length > 12) || (AnsiName->Buffer == NULL)) return FALSE;
@ -255,7 +260,6 @@ RtlIsNameLegalDOS8Dot3(IN PCUNICODE_STRING UnicodeName,
if (AnsiName->Buffer[0] == '.')
{
if (AnsiName->Length != 1 && (AnsiName->Length != 2 || AnsiName->Buffer[1] != '.')) return FALSE;
if (SpacesFound) *SpacesFound = FALSE;
return TRUE;
}

View file

@ -345,6 +345,7 @@ RtlEnumerateGenericTable(IN PRTL_GENERIC_TABLE Table,
} while(RtlLeftChild(FoundNode));
/* Splay it */
_Analysis_assume_(FoundNode != NULL);
Table->TableRoot = RtlSplay(FoundNode);
}
else

View file

@ -321,7 +321,7 @@ RtlpDphAllocateVm(PVOID *Base, SIZE_T Size, ULONG Type, ULONG Protection)
&Size,
Type,
Protection);
DPRINT("Page heap: AllocVm (%p, %p, %x) status %x \n", Base, Size, Type, Status);
DPRINT("Page heap: AllocVm (%p, %Ix, %lx) status %lx \n", Base, Size, Type, Status);
/* Check for failures */
if (!NT_SUCCESS(Status))
{
@ -330,7 +330,7 @@ RtlpDphAllocateVm(PVOID *Base, SIZE_T Size, ULONG Type, ULONG Protection)
_InterlockedIncrement(&RtlpDphCounter);
if (RtlpDphBreakOptions & DPH_BREAK_ON_RESERVE_FAIL)
{
DPRINT1("Page heap: AllocVm (%p, %p, %x) failed with %x \n", Base, Size, Type, Status);
DPRINT1("Page heap: AllocVm (%p, %Ix, %x) failed with %x \n", Base, Size, Type, Status);
DbgBreakPoint();
return Status;
}
@ -340,7 +340,7 @@ RtlpDphAllocateVm(PVOID *Base, SIZE_T Size, ULONG Type, ULONG Protection)
_InterlockedIncrement(&RtlpDphAllocFails);
if (RtlpDphBreakOptions & DPH_BREAK_ON_COMMIT_FAIL)
{
DPRINT1("Page heap: AllocVm (%p, %p, %x) failed with %x \n", Base, Size, Type, Status);
DPRINT1("Page heap: AllocVm (%p, %Ix, %x) failed with %x \n", Base, Size, Type, Status);
DbgBreakPoint();
return Status;
}
@ -357,7 +357,7 @@ RtlpDphFreeVm(PVOID Base, SIZE_T Size, ULONG Type)
/* Free the memory */
Status = RtlpSecMemFreeVirtualMemory(NtCurrentProcess(), &Base, &Size, Type);
DPRINT1("Page heap: FreeVm (%p, %p, %x) status %x \n", Base, Size, Type, Status);
DPRINT1("Page heap: FreeVm (%p, %Ix, %x) status %x \n", Base, Size, Type, Status);
/* Log/report failures */
if (!NT_SUCCESS(Status))
{
@ -366,7 +366,7 @@ RtlpDphFreeVm(PVOID Base, SIZE_T Size, ULONG Type)
_InterlockedIncrement(&RtlpDphReleaseFails);
if (RtlpDphBreakOptions & DPH_BREAK_ON_RELEASE_FAIL)
{
DPRINT1("Page heap: FreeVm (%p, %p, %x) failed with %x \n", Base, Size, Type, Status);
DPRINT1("Page heap: FreeVm (%p, %Ix, %x) failed with %x \n", Base, Size, Type, Status);
DbgBreakPoint();
return Status;
}
@ -376,7 +376,7 @@ RtlpDphFreeVm(PVOID Base, SIZE_T Size, ULONG Type)
_InterlockedIncrement(&RtlpDphFreeFails);
if (RtlpDphBreakOptions & DPH_BREAK_ON_FREE_FAIL)
{
DPRINT1("Page heap: FreeVm (%p, %p, %x) failed with %x \n", Base, Size, Type, Status);
DPRINT1("Page heap: FreeVm (%p, %Ix, %x) failed with %x \n", Base, Size, Type, Status);
DbgBreakPoint();
return Status;
}
@ -401,7 +401,7 @@ RtlpDphProtectVm(PVOID Base, SIZE_T Size, ULONG Protection)
_InterlockedIncrement(&RtlpDphProtectFails);
if (RtlpDphBreakOptions & DPH_BREAK_ON_PROTECT_FAIL)
{
DPRINT1("Page heap: ProtectVm (%p, %p, %x) failed with %x \n", Base, Size, Protection, Status);
DPRINT1("Page heap: ProtectVm (%p, %Ix, %x) failed with %x \n", Base, Size, Protection, Status);
DbgBreakPoint();
return Status;
}
@ -732,7 +732,7 @@ RtlpDphCoalesceFreeIntoAvailable(PDPH_HEAP_ROOT DphRoot,
/* Make sure requested size is not too big */
ASSERT(FreeAllocations >= LeaveOnFreeList);
DPRINT("RtlpDphCoalesceFreeIntoAvailable(%p %d)\n", DphRoot, LeaveOnFreeList);
DPRINT("RtlpDphCoalesceFreeIntoAvailable(%p %lu)\n", DphRoot, LeaveOnFreeList);
while (Node)
{
@ -1411,7 +1411,8 @@ RtlpDphProcessStartupInitialization()
/* Per-process DPH init is done */
RtlpDphPageHeapListInitialized = TRUE;
DPRINT1("Page heap: pid 0x%X: page heap enabled with flags 0x%X.\n", Teb->ClientId.UniqueProcess, RtlpDphGlobalFlags);
DPRINT1("Page heap: pid 0x%p: page heap enabled with flags 0x%X.\n",
Teb->ClientId.UniqueProcess, RtlpDphGlobalFlags);
return Status;
}
@ -1554,8 +1555,9 @@ RtlpPageHeapCreate(ULONG Flags,
if (RtlpDphDebugOptions & DPH_DEBUG_VERBOSE)
{
DPRINT1("Page heap: process 0x%X created heap @ %p (%p, flags 0x%X)\n",
NtCurrentTeb()->ClientId.UniqueProcess, (PUCHAR)DphRoot - PAGE_SIZE, DphRoot->NormalHeap, DphRoot->ExtraFlags);
DPRINT1("Page heap: process 0x%p created heap @ %p (%p, flags 0x%X)\n",
NtCurrentTeb()->ClientId.UniqueProcess, (PUCHAR)DphRoot - PAGE_SIZE,
DphRoot->NormalHeap, DphRoot->ExtraFlags);
}
/* Perform internal validation if required */
@ -1641,7 +1643,8 @@ RtlpPageHeapDestroy(HANDLE HeapPtr)
/* Report success */
if (RtlpDphDebugOptions & DPH_DEBUG_VERBOSE)
DPRINT1("Page heap: process 0x%X destroyed heap @ %p (%p)\n", NtCurrentTeb()->ClientId.UniqueProcess, HeapPtr, NormalHeap);
DPRINT1("Page heap: process 0x%p destroyed heap @ %p (%p)\n",
NtCurrentTeb()->ClientId.UniqueProcess, HeapPtr, NormalHeap);
return NULL;
}

View file

@ -274,8 +274,7 @@ RtlImageDirectoryEntryToData(
MappedAsImage = FALSE;
}
NtHeader = RtlImageNtHeader (BaseAddress);
NtHeader = RtlImageNtHeader(BaseAddress);
if (NtHeader == NULL)
return NULL;
@ -292,7 +291,7 @@ RtlImageDirectoryEntryToData(
return (PVOID)((ULONG_PTR)BaseAddress + Va);
/* image mapped as ordinary file, we must find raw pointer */
return RtlImageRvaToVa (NtHeader, BaseAddress, Va, NULL);
return RtlImageRvaToVa(NtHeader, BaseAddress, Va, NULL);
}
@ -341,13 +340,13 @@ RtlImageRvaToVa(
if (SectionHeader)
Section = *SectionHeader;
if (Section == NULL ||
Rva < SWAPD(Section->VirtualAddress) ||
Rva >= SWAPD(Section->VirtualAddress) + SWAPD(Section->Misc.VirtualSize))
if ((Section == NULL) ||
(Rva < SWAPD(Section->VirtualAddress)) ||
(Rva >= SWAPD(Section->VirtualAddress) + SWAPD(Section->Misc.VirtualSize)))
{
Section = RtlImageRvaToSection (NtHeader, BaseAddress, Rva);
if (Section == NULL)
return 0;
return NULL;
if (SectionHeader)
*SectionHeader = Section;
@ -418,7 +417,7 @@ LdrProcessRelocationBlockLongLong(
case IMAGE_REL_BASED_MIPS_JMPADDR:
default:
DPRINT1("Unknown/unsupported fixup type %hu.\n", Type);
DPRINT1("Address %x, Current %d, Count %d, *TypeOffset %x\n", Address, i, Count, SWAPW(*TypeOffset));
DPRINT1("Address %x, Current %u, Count %u, *TypeOffset %x\n", Address, i, Count, SWAPW(*TypeOffset));
return (PIMAGE_BASE_RELOCATION)NULL;
}

View file

@ -210,11 +210,9 @@ RtlInitNlsTables(IN PUSHORT AnsiTableBase,
CaseTableBase == NULL)
return;
RtlInitCodePageTable (AnsiTableBase,
&NlsTable->AnsiTableInfo);
RtlInitCodePageTable(AnsiTableBase, &NlsTable->AnsiTableInfo);
RtlInitCodePageTable (OemTableBase,
&NlsTable->OemTableInfo);
RtlInitCodePageTable(OemTableBase, &NlsTable->OemTableInfo);
NlsTable->UpperCaseTable = (PUSHORT)CaseTableBase + 2;
NlsTable->LowerCaseTable = (PUSHORT)CaseTableBase + *((PUSHORT)CaseTableBase + 1) + 2;

View file

@ -409,12 +409,15 @@ RtlpCallQueryRegistryRoutine(IN PRTL_QUERY_REGISTRY_TABLE QueryTable,
return (Status == STATUS_BUFFER_TOO_SMALL) ? STATUS_SUCCESS : Status;
}
_Success_(return!=NULL || BufferSize==0)
_When_(BufferSize!=NULL,__drv_allocatesMem(Mem))
PVOID
NTAPI
RtlpAllocDeallocQueryBuffer(IN OUT PSIZE_T BufferSize,
IN PVOID OldBuffer,
IN SIZE_T OldBufferSize,
OUT PNTSTATUS Status)
RtlpAllocDeallocQueryBuffer(
_In_opt_ PSIZE_T BufferSize,
_In_opt_ __drv_freesMem(Mem) PVOID OldBuffer,
_In_ SIZE_T OldBufferSize,
_Out_opt_ _On_failure_(_Post_satisfies_(*Status < 0)) PNTSTATUS Status)
{
PVOID Buffer = NULL;

View file

@ -216,16 +216,17 @@ LdrFindResource_U(PVOID BaseAddress,
_SEH2_TRY
{
if (ResourceInfo)
if (ResourceInfo)
{
DPRINT( "module %p type %ws name %ws lang %04lx level %ld\n",
DPRINT( "module %p type %ws name %ws lang %04lx level %lu\n",
BaseAddress, (LPCWSTR)ResourceInfo->Type,
Level > 1 ? (LPCWSTR)ResourceInfo->Name : L"",
Level > 2 ? ResourceInfo->Language : 0, Level );
}
status = find_entry( BaseAddress, ResourceInfo, Level, &res, FALSE );
if (status == STATUS_SUCCESS) *ResourceDataEntry = res;
if (NT_SUCCESS(status))
*ResourceDataEntry = res;
}
_SEH2_EXCEPT(page_fault(_SEH2_GetExceptionCode()))
{
@ -263,16 +264,17 @@ LdrFindResourceDirectory_U(IN PVOID BaseAddress,
_SEH2_TRY
{
if (info)
if (info)
{
DPRINT( "module %p type %ws name %ws lang %04lx level %ld\n",
DPRINT( "module %p type %ws name %ws lang %04lx level %lu\n",
BaseAddress, (LPCWSTR)info->Type,
level > 1 ? (LPCWSTR)info->Name : L"",
level > 2 ? info->Language : 0, level );
}
status = find_entry( BaseAddress, info, level, &res, TRUE );
if (status == STATUS_SUCCESS) *addr = res;
if (NT_SUCCESS(status))
*addr = res;
}
_SEH2_EXCEPT(page_fault(_SEH2_GetExceptionCode()))
{
@ -346,7 +348,7 @@ LdrEnumResources(
_In_ PLDR_RESOURCE_INFO ResourceInfo,
_In_ ULONG Level,
_Inout_ ULONG *ResourceCount,
_Out_opt_ LDR_ENUM_RESOURCE_INFO *Resources)
_Out_writes_to_(*ResourceCount,*ResourceCount) LDR_ENUM_RESOURCE_INFO *Resources)
{
PUCHAR ResourceData;
NTSTATUS Status;

View file

@ -310,7 +310,7 @@ VOID
NTAPI
RtlDumpResource(PRTL_RESOURCE Resource)
{
DbgPrint("RtlDumpResource(%p):\n\tactive count = %i\n\twaiting readers = %i\n\twaiting writers = %i\n",
DbgPrint("RtlDumpResource(%p):\n\tactive count = %d\n\twaiting readers = %u\n\twaiting writers = %u\n",
Resource,
Resource->NumberActive,
Resource->SharedWaiters,
@ -318,7 +318,7 @@ RtlDumpResource(PRTL_RESOURCE Resource)
if (Resource->NumberActive != 0)
{
DbgPrint("\towner thread = %08x\n",
DbgPrint("\towner thread = %p\n",
Resource->OwningThread);
}
}

View file

@ -57,7 +57,7 @@ RtlpConvertToAutoInheritSecurityObject(IN PSECURITY_DESCRIPTOR ParentDescriptor,
UNIMPLEMENTED;
return STATUS_NOT_IMPLEMENTED;
}
/* PUBLIC FUNCTIONS ***********************************************************/
/*
@ -288,7 +288,7 @@ RtlNewSecurityGrantedAccess(IN ACCESS_MASK DesiredAccess,
BOOLEAN Granted, CallerToken;
TOKEN_STATISTICS TokenStats;
ULONG Size;
DPRINT1("RtlNewSecurityGrantedAccess(%p)\n", DesiredAccess);
DPRINT1("RtlNewSecurityGrantedAccess(%lx)\n", DesiredAccess);
/* Has the caller passed a token? */
if (!Token)

View file

@ -584,14 +584,17 @@ RtlInitUnicodeString(
IN PCWSTR SourceString)
{
SIZE_T Size;
CONST SIZE_T MaxSize = (MAXUSHORT & ~1) - sizeof(WCHAR); // an even number
CONST SIZE_T MaxSize = (MAXUSHORT & ~1) - sizeof(UNICODE_NULL); // an even number
if (SourceString)
{
Size = wcslen(SourceString) * sizeof(WCHAR);
if (Size > MaxSize) Size = MaxSize;
__analysis_assume(Size <= MaxSize);
if (Size > MaxSize)
Size = MaxSize;
DestinationString->Length = (USHORT)Size;
DestinationString->MaximumLength = (USHORT)Size + sizeof(WCHAR);
DestinationString->MaximumLength = (USHORT)Size + sizeof(UNICODE_NULL);
}
else
{

View file

@ -156,7 +156,7 @@ RtlFindUnicodePrefix(PUNICODE_PREFIX_TABLE PrefixTable,
RTL_GENERIC_COMPARE_RESULTS Result;
DPRINT("RtlFindUnicodePrefix(): Table %p, FullName %wZ, "
"CaseInsensitive %b\n", PrefixTable, FullName, CaseInsensitiveIndex);
"CaseInsensitive %lu\n", PrefixTable, FullName, CaseInsensitiveIndex);
/* Find out how many names there are */
NameCount = ComputeUnicodeNameLength(FullName);
@ -467,7 +467,7 @@ RtlNextUnicodePrefix(PUNICODE_PREFIX_TABLE PrefixTable,
PRTL_SPLAY_LINKS SplayLinks;
PUNICODE_PREFIX_TABLE_ENTRY Entry, CaseMatchEntry = NULL;
DPRINT("RtlNextUnicodePrefix(): Table %p Restart %b\n",
DPRINT("RtlNextUnicodePrefix(): Table %p Restart %u\n",
PrefixTable, Restart);
/* We might need this entry 2/3rd of the time, so cache it now */

View file

@ -456,7 +456,7 @@ RtlpQueueIoWorkerThread(IN OUT PRTLP_WORKITEM WorkItem)
/* Couldn't find an appropriate thread, see if we can use the persistent thread (if it exists) for now */
if (ThreadPoolIOWorkerThreads == 0)
{
DPRINT1("Failed to find a worker thread for the work item 0x%p!\n");
DPRINT1("Failed to find a worker thread for the work item 0x%p!\n", WorkItem);
ASSERT(IsListEmpty(&ThreadPoolIOWorkerThreadsList));
return STATUS_NO_MEMORY;
}