From 4e6d2d7136fd55ce0c9e71744cccb56650654792 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Tue, 8 Dec 2009 02:18:42 +0000 Subject: [PATCH] Cleanup test code, improve comments. svn path=/trunk/; revision=44465 --- reactos/lib/rtl/bitmap.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/reactos/lib/rtl/bitmap.c b/reactos/lib/rtl/bitmap.c index b06f446fe03..1af0cbb89c7 100644 --- a/reactos/lib/rtl/bitmap.c +++ b/reactos/lib/rtl/bitmap.c @@ -83,11 +83,12 @@ RtlpGetLengthOfRunClear( /* Calculate length up to where we read */ Length = (Buffer - BitMapHeader->Buffer) * 32 - StartingIndex; Length += BitPos - 32; - + + /* Make sure we don't go past the last bit */ if (Length > BitMapHeader->SizeOfBitMap - StartingIndex) Length = BitMapHeader->SizeOfBitMap - StartingIndex; - /* The result is guaranteed to be < BitMapHeader->SizeOfBitMap */ + /* Return the result */ return Length; } @@ -132,10 +133,11 @@ RtlpGetLengthOfRunSet( Length = (Buffer - BitMapHeader->Buffer) * 32 - StartingIndex; Length += BitPos - 32; + /* Make sure we don't go past the last bit */ if (Length > BitMapHeader->SizeOfBitMap - StartingIndex) Length = BitMapHeader->SizeOfBitMap - StartingIndex; - /* The result is guaranteed to be < BitMapHeader->SizeOfBitMap */ + /* Return the result */ return Length; } @@ -436,12 +438,10 @@ RtlFindClearBits( /* Loop until something is found or the end is reached */ while (CurrentBit + NumberToFind < BitMapHeader->SizeOfBitMap) { - ULONG test; /* Search for the next clear run, by skipping a set run */ - test = RtlpGetLengthOfRunSet(BitMapHeader, + CurrentBit += RtlpGetLengthOfRunSet(BitMapHeader, CurrentBit, MAXULONG); - CurrentBit += test; /* Get length of the clear bit run */ CurrentLength = RtlpGetLengthOfRunClear(BitMapHeader, -- 2.17.1