From 8a3e35d8c3c94e2588ab9d40bc619ea7ef31cca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 21 Nov 2002 20:32:54 +0000 Subject: [PATCH] AllocationBlock::Allocate() still had the 0xffff thing implemented, now also the numBlocks parameter is ASSERTed - when compiled with DEBUG turned off, BFS will enter the kernel debugger in this case (through the use of the DIE() macro). Same for AllocationBlock::Free() (but the 0xffff mode was already removed there). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2053 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/file_systems/bfs/BlockAllocator.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp b/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp index b7f2105ca8..6772eeff38 100644 --- a/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp +++ b/src/add-ons/kernel/file_systems/bfs/BlockAllocator.cpp @@ -120,15 +120,11 @@ void AllocationBlock::Allocate(uint16 start, uint16 numBlocks) { ASSERT(start < fNumBits); + ASSERT(start + numBlocks <= fNumBits); - if (numBlocks == 0xffff) { - // allocate all blocks after "start" - numBlocks = fNumBits - start; - } else if (start + numBlocks > fNumBits) { + if (start + numBlocks > fNumBits) { FATAL(("Allocation::Allocate(): tried to allocate too many blocks: %u (numBlocks = %u)!\n", numBlocks, fNumBits)); - DEBUGGER(("Allocation::Allocate(): tried to allocate too many blocks")); - - numBlocks = fNumBits - start; + DIE(("Allocation::Allocate(): tried to allocate too many blocks")); } int32 block = start >> 5; @@ -155,12 +151,11 @@ void AllocationBlock::Free(uint16 start, uint16 numBlocks) { ASSERT(start < fNumBits); + ASSERT(start + numBlocks <= fNumBits); if (start + numBlocks > fNumBits) { FATAL(("Allocation::Free(): tried to free too many blocks: %u (numBlocks = %u)!\n", numBlocks, fNumBits)); - DEBUGGER(("Allocation::Free(): tried to free too many blocks")); - - numBlocks = fNumBits - start; + DIE(("Allocation::Free(): tried to free too many blocks")); } int32 block = start >> 5;