From 0bacae2af970217c3fda1320f1ff47b2fa8dfa8d Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 2 Jun 2013 19:04:02 +0000 Subject: [PATCH] [PSDK] - Add proper definition for DBG_UNREFERENCED_PARAMETER and DBG_UNREFERENCED_LOCAL_VARIABLE [NTOSKRNL/RTL] - Fix a number of warnings about unreferenced local variables - Add 2 assertions that unmapping a section succeeds svn path=/trunk/; revision=59151 --- reactos/include/psdk/ntdef.h | 4 ++-- reactos/include/psdk/winnt.h | 4 ++-- reactos/ntoskrnl/cache/section/data.c | 1 + reactos/ntoskrnl/cache/section/swapout.c | 1 + reactos/ntoskrnl/inbv/inbv.c | 2 ++ reactos/ntoskrnl/kdbg/i386/i386-dis.c | 10 +++++----- reactos/ntoskrnl/mm/ARM3/expool.c | 2 ++ reactos/ntoskrnl/mm/ARM3/pagfault.c | 11 ++++++----- reactos/ntoskrnl/mm/ARM3/section.c | 5 +++-- reactos/ntoskrnl/mm/ARM3/sysldr.c | 3 +-- reactos/ntoskrnl/mm/i386/page.c | 7 ++++--- reactos/ntoskrnl/mm/rmap.c | 6 +++--- reactos/ntoskrnl/mm/section.c | 6 ++++-- 13 files changed, 36 insertions(+), 26 deletions(-) diff --git a/reactos/include/psdk/ntdef.h b/reactos/include/psdk/ntdef.h index b8689c3ed96..5f6a2583a32 100644 --- a/reactos/include/psdk/ntdef.h +++ b/reactos/include/psdk/ntdef.h @@ -310,8 +310,8 @@ /* Use to silence unused variable warnings when it is intentional */ #define UNREFERENCED_PARAMETER(P) {(P)=(P);} #define UNREFERENCED_LOCAL_VARIABLE(L) {(L)=(L);} -#define DBG_UNREFERENCED_PARAMETER(P) -#define DBG_UNREFERENCED_LOCAL_VARIABLE(L) +#define DBG_UNREFERENCED_PARAMETER(P) {(P)=(P);} +#define DBG_UNREFERENCED_LOCAL_VARIABLE(L) {(L)=(L);} /* min/max helper macros */ #ifndef NOMINMAX diff --git a/reactos/include/psdk/winnt.h b/reactos/include/psdk/winnt.h index acc04ffa7fd..fdd77df55ff 100644 --- a/reactos/include/psdk/winnt.h +++ b/reactos/include/psdk/winnt.h @@ -131,8 +131,8 @@ #define UNREFERENCED_PARAMETER(P) {(P)=(P);} #define UNREFERENCED_LOCAL_VARIABLE(L) {(L)=(L);} -#define DBG_UNREFERENCED_PARAMETER(P) -#define DBG_UNREFERENCED_LOCAL_VARIABLE(L) +#define DBG_UNREFERENCED_PARAMETER(P) {(L)=(L);} +#define DBG_UNREFERENCED_LOCAL_VARIABLE(L) {(L)=(L);} #ifndef DECLSPEC_ALIGN # if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS) diff --git a/reactos/ntoskrnl/cache/section/data.c b/reactos/ntoskrnl/cache/section/data.c index b253753ce67..36662961461 100644 --- a/reactos/ntoskrnl/cache/section/data.c +++ b/reactos/ntoskrnl/cache/section/data.c @@ -456,6 +456,7 @@ MmCreateCacheSection(PROS_SECTION_OBJECT *SectionObject, &Information); Iosb.Information = Information; DPRINT("Query => %x\n", Status); + DBG_UNREFERENCED_LOCAL_VARIABLE(Iosb); if (!NT_SUCCESS(Status)) { diff --git a/reactos/ntoskrnl/cache/section/swapout.c b/reactos/ntoskrnl/cache/section/swapout.c index 801acfbb2aa..e0f2b9d3090 100644 --- a/reactos/ntoskrnl/cache/section/swapout.c +++ b/reactos/ntoskrnl/cache/section/swapout.c @@ -298,6 +298,7 @@ MmPageOutCacheSection(PMMSUPPORT AddressSpace, ASSERT(KeGetCurrentIrql() <= APC_LEVEL); Entry = MmGetPageEntrySectionSegment(Segment, &TotalOffset); + DBG_UNREFERENCED_LOCAL_VARIABLE(Entry); if (MmIsPageSwapEntry(Process, PAddress)) { diff --git a/reactos/ntoskrnl/inbv/inbv.c b/reactos/ntoskrnl/inbv/inbv.c index a99677ca268..901b770b33b 100644 --- a/reactos/ntoskrnl/inbv/inbv.c +++ b/reactos/ntoskrnl/inbv/inbv.c @@ -815,6 +815,8 @@ DisplayBootBitmap(IN BOOLEAN TextMode) #ifdef CORE_6781_resolved /* Draw the SKU text if it exits */ if (Text) InbvBitBlt(Text, 180, 121); +#else + DBG_UNREFERENCED_LOCAL_VARIABLE(Text); #endif /* Draw the progress bar bit */ diff --git a/reactos/ntoskrnl/kdbg/i386/i386-dis.c b/reactos/ntoskrnl/kdbg/i386/i386-dis.c index 4e117229def..93b4194dc81 100644 --- a/reactos/ntoskrnl/kdbg/i386/i386-dis.c +++ b/reactos/ntoskrnl/kdbg/i386/i386-dis.c @@ -3840,7 +3840,7 @@ static void OP_sI (int bytemode, int sizeflag) { bfd_signed_vma op; - bfd_signed_vma mask = -1; + //bfd_signed_vma mask = -1; switch (bytemode) { @@ -3849,7 +3849,7 @@ OP_sI (int bytemode, int sizeflag) op = *codep++; if ((op & 0x80) != 0) op -= 0x100; - mask = 0xffffffff; + //mask = 0xffffffff; break; case v_mode: USED_REX (REX_MODE64); @@ -3858,11 +3858,11 @@ OP_sI (int bytemode, int sizeflag) else if (sizeflag & DFLAG) { op = get32s (); - mask = 0xffffffff; + //mask = 0xffffffff; } else { - mask = 0xffffffff; + //mask = 0xffffffff; op = get16 (); if ((op & 0x8000) != 0) op -= 0x10000; @@ -3871,7 +3871,7 @@ OP_sI (int bytemode, int sizeflag) break; case w_mode: op = get16 (); - mask = 0xffffffff; + //mask = 0xffffffff; if ((op & 0x8000) != 0) op -= 0x10000; break; diff --git a/reactos/ntoskrnl/mm/ARM3/expool.c b/reactos/ntoskrnl/mm/ARM3/expool.c index ee330ca2f8c..d07805f812b 100644 --- a/reactos/ntoskrnl/mm/ARM3/expool.c +++ b/reactos/ntoskrnl/mm/ARM3/expool.c @@ -615,6 +615,7 @@ ExpRemovePoolTracker(IN ULONG Key, Table = PoolTrackTable; TableMask = PoolTrackTableMask; TableSize = PoolTrackTableSize; + DBG_UNREFERENCED_LOCAL_VARIABLE(TableSize); // // Compute the hash for this key, and loop all the possible buckets @@ -717,6 +718,7 @@ ExpInsertPoolTracker(IN ULONG Key, Table = PoolTrackTable; TableMask = PoolTrackTableMask; TableSize = PoolTrackTableSize; + DBG_UNREFERENCED_LOCAL_VARIABLE(TableSize); // // Compute the hash for this key, and loop all the possible buckets diff --git a/reactos/ntoskrnl/mm/ARM3/pagfault.c b/reactos/ntoskrnl/mm/ARM3/pagfault.c index b99f77e04c9..d217616b10c 100644 --- a/reactos/ntoskrnl/mm/ARM3/pagfault.c +++ b/reactos/ntoskrnl/mm/ARM3/pagfault.c @@ -529,6 +529,7 @@ MiCompleteProtoPteFault(IN BOOLEAN StoreInstruction, PageTablePte = MiAddressToPte(PointerPte); Pfn2 = MiGetPfnEntry(PageTablePte->u.Hard.PageFrameNumber); //Pfn2->u2.ShareCount++; + DBG_UNREFERENCED_LOCAL_VARIABLE(Pfn2); /* Check where we should be getting the protection information from */ if (PointerPte->u.Soft.PageFileHigh == MI_PTE_LOOKUP_NEEDED) @@ -986,19 +987,19 @@ MiDispatchFault(IN BOOLEAN StoreInstruction, DPRINT("oooh, shiny, a soft fault! 0x%lx\n", PageFrameIndex); Pfn1 = MI_PFN_ELEMENT(PageFrameIndex); ASSERT(Pfn1->u3.e1.PageLocation != ActiveAndValid); - + /* Should not yet happen in ReactOS */ ASSERT(Pfn1->u3.e1.ReadInProgress == 0); ASSERT(Pfn1->u4.InPageError == 0); - + /* Get the page */ MiUnlinkPageFromList(Pfn1); - + /* Bump its reference count */ ASSERT(Pfn1->u2.ShareCount == 0); InterlockedIncrement16((PSHORT)&Pfn1->u3.e2.ReferenceCount); Pfn1->u2.ShareCount++; - + /* Make it valid again */ /* This looks like another macro.... */ Pfn1->u3.e1.PageLocation = ActiveAndValid; @@ -1009,7 +1010,7 @@ MiDispatchFault(IN BOOLEAN StoreInstruction, MmProtectToPteMask[PointerProtoPte->u.Trans.Protection]; TempPte.u.Hard.Valid = 1; TempPte.u.Hard.Accessed = 1; - + /* Is the PTE writeable? */ if (((Pfn1->u3.e1.Modified) && (TempPte.u.Hard.Write)) && (TempPte.u.Hard.CopyOnWrite == 0)) diff --git a/reactos/ntoskrnl/mm/ARM3/section.c b/reactos/ntoskrnl/mm/ARM3/section.c index 3ea75c7c3bf..1e86307599e 100644 --- a/reactos/ntoskrnl/mm/ARM3/section.c +++ b/reactos/ntoskrnl/mm/ARM3/section.c @@ -1995,7 +1995,7 @@ MiRemoveMappedPtes(IN PVOID BaseAddress, IN PCONTROL_AREA ControlArea, IN PMMSUPPORT Ws) { - PMMPTE PointerPte, FirstPte; + PMMPTE PointerPte;//, FirstPte; PMMPDE PointerPde, SystemMapPde; PMMPFN Pfn1, Pfn2; MMPTE PteContents; @@ -2004,7 +2004,7 @@ MiRemoveMappedPtes(IN PVOID BaseAddress, /* Get the PTE and loop each one */ PointerPte = MiAddressToPte(BaseAddress); - FirstPte = PointerPte; + //FirstPte = PointerPte; while (NumberOfPtes) { /* Check if the PTE is already valid */ @@ -2041,6 +2041,7 @@ MiRemoveMappedPtes(IN PVOID BaseAddress, /* Dereference the PDE and the PTE */ Pfn2 = MiGetPfnEntry(PFN_FROM_PTE(PointerPde)); //MiDecrementShareCount(Pfn2, PFN_FROM_PTE(PointerPde)); + DBG_UNREFERENCED_LOCAL_VARIABLE(Pfn2); MiDecrementShareCount(Pfn1, PFN_FROM_PTE(&PteContents)); /* Release the PFN lock */ diff --git a/reactos/ntoskrnl/mm/ARM3/sysldr.c b/reactos/ntoskrnl/mm/ARM3/sysldr.c index 554843bde25..0a511b160c3 100644 --- a/reactos/ntoskrnl/mm/ARM3/sysldr.c +++ b/reactos/ntoskrnl/mm/ARM3/sysldr.c @@ -1559,7 +1559,6 @@ MmFreeDriverInitialization(IN PLDR_DATA_TABLE_ENTRY LdrEntry) ULONG i; PIMAGE_NT_HEADERS NtHeader; PIMAGE_SECTION_HEADER Section, DiscardSection; - ULONG PagesDeleted; /* Get the base address and the page count */ DllBase = LdrEntry->DllBase; @@ -1604,7 +1603,7 @@ MmFreeDriverInitialization(IN PLDR_DATA_TABLE_ENTRY LdrEntry) if (!PageCount) return; /* Delete this many PTEs */ - PagesDeleted = MiDeleteSystemPageableVm(StartPte, PageCount, 0, NULL); + MiDeleteSystemPageableVm(StartPte, PageCount, 0, NULL); } VOID diff --git a/reactos/ntoskrnl/mm/i386/page.c b/reactos/ntoskrnl/mm/i386/page.c index 2047f03f0db..52c5f578a53 100644 --- a/reactos/ntoskrnl/mm/i386/page.c +++ b/reactos/ntoskrnl/mm/i386/page.c @@ -252,11 +252,11 @@ MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create) { PMMPDE PdeBase; ULONG PdeOffset = MiGetPdeOffset(Address); - + /* Nobody but page fault should ask for creating the PDE, * Which imples that Process is the current one */ ASSERT(Create == FALSE); - + PdeBase = MmCreateHyperspaceMapping(PTE_TO_PFN(Process->Pcb.DirectoryTableBase[0])); if (PdeBase == NULL) { @@ -301,6 +301,7 @@ MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create) PsGetCurrentProcess(), NULL, NULL); + DBG_UNREFERENCED_LOCAL_VARIABLE(Status); ASSERT(KeAreAllApcsDisabled() == TRUE); ASSERT(PointerPde->u.Hard.Valid == 1); } @@ -575,7 +576,7 @@ Mmi386MakeKernelPageTableGlobal(PVOID Address) { PMMPDE PointerPde = MiAddressToPde(Address); PMMPTE PointerPte = MiAddressToPte(Address); - + if (PointerPde->u.Hard.Valid == 0) { if(!MiSynchronizeSystemPde(PointerPde)) diff --git a/reactos/ntoskrnl/mm/rmap.c b/reactos/ntoskrnl/mm/rmap.c index cc35180478e..d177f3c04cd 100644 --- a/reactos/ntoskrnl/mm/rmap.c +++ b/reactos/ntoskrnl/mm/rmap.c @@ -451,10 +451,10 @@ NTAPI MmGetSegmentRmap(PFN_NUMBER Page, PULONG RawOffset) { PCACHE_SECTION_PAGE_TABLE Result = NULL; - PMM_RMAP_ENTRY current_entry, previous_entry; + PMM_RMAP_ENTRY current_entry;//, previous_entry; ExAcquireFastMutex(&RmapListLock); - previous_entry = NULL; + //previous_entry = NULL; current_entry = MmGetRmapListHeadPage(Page); while (current_entry != NULL) { @@ -466,7 +466,7 @@ MmGetSegmentRmap(PFN_NUMBER Page, PULONG RawOffset) ExReleaseFastMutex(&RmapListLock); return Result; } - previous_entry = current_entry; + //previous_entry = current_entry; current_entry = current_entry->Next; } ExReleaseFastMutex(&RmapListLock); diff --git a/reactos/ntoskrnl/mm/section.c b/reactos/ntoskrnl/mm/section.c index 8d321dfd7cb..42ccf97a2b0 100644 --- a/reactos/ntoskrnl/mm/section.c +++ b/reactos/ntoskrnl/mm/section.c @@ -2287,9 +2287,9 @@ MmWritePageSectionView(PMMSUPPORT AddressSpace, */ if (DirectMapped && !Private) { - LARGE_INTEGER SOffset; + //LARGE_INTEGER SOffset; ASSERT(SwapEntry == 0); - SOffset.QuadPart = Offset.QuadPart + Segment->Image.FileOffset; + //SOffset.QuadPart = Offset.QuadPart + Segment->Image.FileOffset; #ifndef NEWCC CcRosMarkDirtyCacheSegment(Bcb, Offset.LowPart); #endif @@ -4116,12 +4116,14 @@ MiRosUnmapViewOfSection(IN PEPROCESS Process, ((char*)ImageBaseAddress + (ULONG_PTR)SectionSegments[i].Image.VirtualAddress); Status = MmUnmapViewOfSegment(AddressSpace, SBaseAddress); + NT_ASSERT(NT_SUCCESS(Status)); } } } else { Status = MmUnmapViewOfSegment(AddressSpace, BaseAddress); + NT_ASSERT(NT_SUCCESS(Status)); } MmUnlockAddressSpace(AddressSpace);