From a087bbe98285d4994d7ca8cc53bb29f376e56551 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sat, 16 Feb 2013 17:21:34 +0000 Subject: [PATCH] [RTL] Fix a number of warnings found with VS /analyze svn path=/trunk/; revision=58318 --- reactos/lib/rtl/actctx.c | 16 +++++++++------- reactos/lib/rtl/assert.c | 4 ++-- reactos/lib/rtl/bootdata.c | 5 +++-- reactos/lib/rtl/crc32.c | 2 +- reactos/lib/rtl/dos8dot3.c | 8 ++++++-- reactos/lib/rtl/generictable.c | 1 + reactos/lib/rtl/heappage.c | 27 +++++++++++++++------------ reactos/lib/rtl/image.c | 15 +++++++-------- reactos/lib/rtl/nls.c | 6 ++---- reactos/lib/rtl/registry.c | 11 +++++++---- reactos/lib/rtl/res.c | 16 +++++++++------- reactos/lib/rtl/resource.c | 4 ++-- reactos/lib/rtl/security.c | 4 ++-- reactos/lib/rtl/unicode.c | 9 ++++++--- reactos/lib/rtl/unicodeprefix.c | 4 ++-- reactos/lib/rtl/workitem.c | 2 +- 16 files changed, 75 insertions(+), 59 deletions(-) diff --git a/reactos/lib/rtl/actctx.c b/reactos/lib/rtl/actctx.c index 0d55e033bae..e08034aa5be 100644 --- a/reactos/lib/rtl/actctx.c +++ b/reactos/lib/rtl/actctx.c @@ -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; diff --git a/reactos/lib/rtl/assert.c b/reactos/lib/rtl/assert.c index faa65ba1724..47cb0cc8ab4 100644 --- a/reactos/lib/rtl/assert.c +++ b/reactos/lib/rtl/assert.c @@ -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); diff --git a/reactos/lib/rtl/bootdata.c b/reactos/lib/rtl/bootdata.c index 215df851374..71c908a7978 100644 --- a/reactos/lib/rtl/bootdata.c +++ b/reactos/lib/rtl/bootdata.c @@ -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) diff --git a/reactos/lib/rtl/crc32.c b/reactos/lib/rtl/crc32.c index 760eebd4fa0..b814ea34fde 100644 --- a/reactos/lib/rtl/crc32.c +++ b/reactos/lib/rtl/crc32.c @@ -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) { diff --git a/reactos/lib/rtl/dos8dot3.c b/reactos/lib/rtl/dos8dot3.c index 7b8bc4bdea4..f2603514991 100644 --- a/reactos/lib/rtl/dos8dot3.c +++ b/reactos/lib/rtl/dos8dot3.c @@ -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; } diff --git a/reactos/lib/rtl/generictable.c b/reactos/lib/rtl/generictable.c index 6cb57fd6d7a..5eb5a16d202 100644 --- a/reactos/lib/rtl/generictable.c +++ b/reactos/lib/rtl/generictable.c @@ -345,6 +345,7 @@ RtlEnumerateGenericTable(IN PRTL_GENERIC_TABLE Table, } while(RtlLeftChild(FoundNode)); /* Splay it */ + _Analysis_assume_(FoundNode != NULL); Table->TableRoot = RtlSplay(FoundNode); } else diff --git a/reactos/lib/rtl/heappage.c b/reactos/lib/rtl/heappage.c index 44c4cfe36b4..1cc3099b6b6 100644 --- a/reactos/lib/rtl/heappage.c +++ b/reactos/lib/rtl/heappage.c @@ -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; } diff --git a/reactos/lib/rtl/image.c b/reactos/lib/rtl/image.c index d901644d3df..d1fdeca2f97 100644 --- a/reactos/lib/rtl/image.c +++ b/reactos/lib/rtl/image.c @@ -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; } diff --git a/reactos/lib/rtl/nls.c b/reactos/lib/rtl/nls.c index d6e181dd5ca..8352ea12fed 100644 --- a/reactos/lib/rtl/nls.c +++ b/reactos/lib/rtl/nls.c @@ -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; diff --git a/reactos/lib/rtl/registry.c b/reactos/lib/rtl/registry.c index 00e3eea5f73..5b9a0e61c9b 100644 --- a/reactos/lib/rtl/registry.c +++ b/reactos/lib/rtl/registry.c @@ -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; diff --git a/reactos/lib/rtl/res.c b/reactos/lib/rtl/res.c index a076295a4ea..a41a39223ff 100644 --- a/reactos/lib/rtl/res.c +++ b/reactos/lib/rtl/res.c @@ -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; diff --git a/reactos/lib/rtl/resource.c b/reactos/lib/rtl/resource.c index 20ae8e7b7ae..40f6970ea79 100644 --- a/reactos/lib/rtl/resource.c +++ b/reactos/lib/rtl/resource.c @@ -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); } } diff --git a/reactos/lib/rtl/security.c b/reactos/lib/rtl/security.c index 0088b50517c..9aa50df5b94 100644 --- a/reactos/lib/rtl/security.c +++ b/reactos/lib/rtl/security.c @@ -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) diff --git a/reactos/lib/rtl/unicode.c b/reactos/lib/rtl/unicode.c index 50a0e70ec5d..39006cd1ce8 100644 --- a/reactos/lib/rtl/unicode.c +++ b/reactos/lib/rtl/unicode.c @@ -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 { diff --git a/reactos/lib/rtl/unicodeprefix.c b/reactos/lib/rtl/unicodeprefix.c index f3d05a9e533..cc05b3771a4 100644 --- a/reactos/lib/rtl/unicodeprefix.c +++ b/reactos/lib/rtl/unicodeprefix.c @@ -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 */ diff --git a/reactos/lib/rtl/workitem.c b/reactos/lib/rtl/workitem.c index 5d4fae03eab..e4f2b842011 100644 --- a/reactos/lib/rtl/workitem.c +++ b/reactos/lib/rtl/workitem.c @@ -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; }