Author: sginsberg Date: Tue Oct 20 18:47:01 2009 New Revision: 43653
URL: http://svn.reactos.org/svn/reactos?rev=43653&view=rev Log: - Add several missing assertions documented on the MSDN page "Checked Build ASSERTs" - Fix a typo in MmProbeAndLockPages; assignment within an ASSERT isn't such a good idea! (was harmless though)
Modified: trunk/reactos/ntoskrnl/io/iomgr/driver.c trunk/reactos/ntoskrnl/io/iomgr/iomdl.c trunk/reactos/ntoskrnl/io/iomgr/irp.c trunk/reactos/ntoskrnl/mm/ARM3/contmem.c trunk/reactos/ntoskrnl/mm/ARM3/iosup.c trunk/reactos/ntoskrnl/mm/ARM3/mdlsup.c
Modified: trunk/reactos/ntoskrnl/io/iomgr/driver.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/driver.c?... ============================================================================== --- trunk/reactos/ntoskrnl/io/iomgr/driver.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/iomgr/driver.c [iso-8859-1] Tue Oct 20 18:47:01 2009 @@ -1403,9 +1403,19 @@ /* Loop all Major Functions */ for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++) { - /* Set each function that was set to NULL to internal routine */ + /* + * Make sure the driver didn't set any dispatch entry point to NULL! + * Doing so is illegal; drivers shouldn't touch entry points they + * do not implement. + */ + ASSERT(DriverObject->MajorFunction[i] != NULL); + + /* Check if it did so anyway */ if (!DriverObject->MajorFunction[i]) + { + /* Fix it up */ DriverObject->MajorFunction[i] = IopInvalidDeviceRequest; + } }
/* Return the Status */
Modified: trunk/reactos/ntoskrnl/io/iomgr/iomdl.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/iomdl.c?r... ============================================================================== --- trunk/reactos/ntoskrnl/io/iomgr/iomdl.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/iomgr/iomdl.c [iso-8859-1] Tue Oct 20 18:47:01 2009 @@ -28,6 +28,9 @@ PMDL Mdl = NULL, p; ULONG Flags = 0; ULONG Size; + + /* Make sure we got a valid length */ + ASSERT(Length != 0);
/* Fail if allocation is over 2GB */ if (Length & 0x80000000) return NULL;
Modified: trunk/reactos/ntoskrnl/io/iomgr/irp.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr/irp.c?rev... ============================================================================== --- trunk/reactos/ntoskrnl/io/iomgr/irp.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/iomgr/irp.c [iso-8859-1] Tue Oct 20 18:47:01 2009 @@ -1133,6 +1133,9 @@ { PDRIVER_OBJECT DriverObject; PIO_STACK_LOCATION StackPtr; + + /* Make sure this is a valid IRP */ + ASSERT(Irp->Type == IO_TYPE_IRP);
/* Get the Driver Object */ DriverObject = DeviceObject->DriverObject;
Modified: trunk/reactos/ntoskrnl/mm/ARM3/contmem.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/contmem.c?... ============================================================================== --- trunk/reactos/ntoskrnl/mm/ARM3/contmem.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/ARM3/contmem.c [iso-8859-1] Tue Oct 20 18:47:01 2009 @@ -173,8 +173,13 @@ { PVOID BaseAddress; PFN_NUMBER SizeInPages; - MI_PFN_CACHE_ATTRIBUTE CacheAttribute; + MI_PFN_CACHE_ATTRIBUTE CacheAttribute; + + // + // Verify count and cache type + // ASSERT(NumberOfBytes != 0); + ASSERT(CacheType <= MmWriteCombined);
// // Compute size requested @@ -352,7 +357,12 @@ IN MEMORY_CACHING_TYPE CacheType OPTIONAL) { PFN_NUMBER LowestPfn, HighestPfn, BoundaryPfn; - ASSERT (NumberOfBytes != 0); + + // + // Verify count and cache type + // + ASSERT(NumberOfBytes != 0); + ASSERT(CacheType <= MmWriteCombined);
// // Convert the lowest address into a PFN @@ -396,7 +406,12 @@ IN PHYSICAL_ADDRESS HighestAcceptableAddress) { PFN_NUMBER HighestPfn; - + + // + // Verify byte count + // + ASSERT(NumberOfBytes != 0); + // // Convert and normalize the highest address into a PFN //
Modified: trunk/reactos/ntoskrnl/mm/ARM3/iosup.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/iosup.c?re... ============================================================================== --- trunk/reactos/ntoskrnl/mm/ARM3/iosup.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/ARM3/iosup.c [iso-8859-1] Tue Oct 20 18:47:01 2009 @@ -57,7 +57,22 @@ PMMPFN Pfn1 = NULL; MI_PFN_CACHE_ATTRIBUTE CacheAttribute; BOOLEAN IsIoMapping; - + + // + // Must be called with a non-zero count + // + ASSERT(NumberOfBytes != 0); + + // + // Make sure the upper bits are 0 if this system + // can't describe more than 4 GB of physical memory. + // FIXME: This doesn't respect PAE, but we currently don't + // define a PAE build flag since there is no such build. + // +#if !defined(_M_AMD64) + ASSERT(PhysicalAddress.HighPart == 0); +#endif + // // Normalize and validate the caching attributes //
Modified: trunk/reactos/ntoskrnl/mm/ARM3/mdlsup.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/ARM3/mdlsup.c?r... ============================================================================== --- trunk/reactos/ntoskrnl/mm/ARM3/mdlsup.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/mm/ARM3/mdlsup.c [iso-8859-1] Tue Oct 20 18:47:01 2009 @@ -507,8 +507,13 @@ // Get the PTE // PointerPte = MiAddressToPte(BaseAddress); + + // + // This should be a resident system PTE + // ASSERT(PointerPte >= MmSystemPtesStart[SystemPteSpace]); ASSERT(PointerPte <= MmSystemPtesEnd[SystemPteSpace]); + ASSERT(PointerPte->u.Hard.Valid == 1);
// // Check if the caller wants us to free advanced pages @@ -715,7 +720,7 @@ // // Sanity check // - ASSERT(MdlPages = (PPFN_NUMBER)(Mdl + 1)); + ASSERT(MdlPages == (PPFN_NUMBER)(Mdl + 1));
// // Check what kind of operation this is