summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2008-09-17 13:29:44 +0000
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2008-09-17 13:29:44 +0000
commit57b4ecb94bceac2484dd9367b2ad111b05e17d97 (patch)
tree41f8c66a71360a0cc33ee005aec6f771954bafc7
parentd45fd260267ee70c093519eb1e4a1ef285549e85 (diff)
downloadedk2-57b4ecb94bceac2484dd9367b2ad111b05e17d97.zip
edk2-57b4ecb94bceac2484dd9367b2ad111b05e17d97.tar.gz
edk2-57b4ecb94bceac2484dd9367b2ad111b05e17d97.tar.bz2
Fix several code review minor comments:
1. Line 79:Use the pre-initialized global variable mPoolHeadList = INITIALIZE_LIST_HEAD_VARIABLE (mPoolHeadList) to remove the statement in line 102 2. Line 337: The debug print statement: “Addr = %x” should change to “Addr = %p” since the expected Buffer is VOID *; How about “(len %x) %,d” ? The Size & Pool->Used belong to type UINTN? Cast it to UINT64 and use %lx 3.Line 413, 418, 425, 477: Use “Buffer != NULL” instead of “NULL != Buffer” 4. Line 451: The debug print statement: “FreePool = %x” should change to FreePool = %p” since Head->Data is pointer; How about “(len %x) %,d” ? The Head->Size& Pool->Used belong to type UINTN? Cast it to UINT64 and use %lx git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5916 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--MdeModulePkg/Core/Dxe/Mem/Pool.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/MdeModulePkg/Core/Dxe/Mem/Pool.c b/MdeModulePkg/Core/Dxe/Mem/Pool.c
index c60761a..2764a8e 100644
--- a/MdeModulePkg/Core/Dxe/Mem/Pool.c
+++ b/MdeModulePkg/Core/Dxe/Mem/Pool.c
@@ -76,7 +76,7 @@ POOL mPoolHead[EfiMaxMemoryType];
//
// List of pool header to search for the appropriate memory type.
//
-LIST_ENTRY mPoolHeadList;
+LIST_ENTRY mPoolHeadList = INITIALIZE_LIST_HEAD_VARIABLE (mPoolHeadList);
/**
@@ -99,7 +99,6 @@ CoreInitializePool (
InitializeListHead (&mPoolHead[Type].FreeList[Index]);
}
}
- InitializeListHead (&mPoolHeadList);
}
@@ -333,10 +332,10 @@ Done:
DEBUG ((
DEBUG_POOL,
- "AllocatePoolI: Type %x, Addr %x (len %x) %,d\n", PoolType,
+ "AllocatePoolI: Type %x, Addr %p (len %lx) %,ld\n", PoolType,
Buffer,
- Size - POOL_OVERHEAD,
- Pool->Used
+ (UINT64)(Size - POOL_OVERHEAD),
+ (UINT64) Pool->Used
));
//
@@ -345,7 +344,7 @@ Done:
Pool->Used += Size;
} else {
- DEBUG ((DEBUG_ERROR | DEBUG_POOL, "AllocatePool: failed to allocate %d bytes\n", Size));
+ DEBUG ((DEBUG_ERROR | DEBUG_POOL, "AllocatePool: failed to allocate %ld bytes\n", (UINT64) Size));
}
return Buffer;
@@ -409,19 +408,19 @@ CoreFreePoolI (
UINTN Offset;
BOOLEAN AllFree;
- ASSERT(NULL != Buffer);
+ ASSERT(Buffer != NULL);
//
// Get the head & tail of the pool entry
//
Head = CR (Buffer, POOL_HEAD, Data, POOL_HEAD_SIGNATURE);
- ASSERT(NULL != Head);
+ ASSERT(Head != NULL);
if (Head->Signature != POOL_HEAD_SIGNATURE) {
return EFI_INVALID_PARAMETER;
}
Tail = HEAD_TO_TAIL (Head);
- ASSERT(NULL != Tail);
+ ASSERT(Tail != NULL);
//
// Debug
@@ -447,7 +446,7 @@ CoreFreePoolI (
return EFI_INVALID_PARAMETER;
}
Pool->Used -= Size;
- DEBUG ((DEBUG_POOL, "FreePool: %x (len %x) %,d\n", Head->Data, Head->Size - POOL_OVERHEAD, Pool->Used));
+ DEBUG ((DEBUG_POOL, "FreePool: %p (len %lx) %,ld\n", Head->Data, (UINT64)(Head->Size - POOL_OVERHEAD), (UINT64) Pool->Used));
//
// Determine the pool list
@@ -473,7 +472,7 @@ CoreFreePoolI (
// Put the pool entry onto the free pool list
//
Free = (POOL_FREE *) Head;
- ASSERT(NULL != Free);
+ ASSERT(Free != NULL);
Free->Signature = POOL_FREE_SIGNATURE;
Free->Index = (UINT32)Index;
InsertHeadList (&Pool->FreeList[Index], &Free->Link);
@@ -497,7 +496,7 @@ CoreFreePoolI (
FSize = LIST_TO_SIZE(Index);
while (Offset + FSize <= DEFAULT_PAGE_ALLOCATION) {
Free = (POOL_FREE *) &NewPage[Offset];
- ASSERT(NULL != Free);
+ ASSERT(Free != NULL);
if (Free->Signature != POOL_FREE_SIGNATURE) {
AllFree = FALSE;
}
@@ -514,7 +513,7 @@ CoreFreePoolI (
// Remove all of these pool entries from the free loop lists.
//
Free = (POOL_FREE *) &NewPage[0];
- ASSERT(NULL != Free);
+ ASSERT(Free != NULL);
Index = Free->Index;
Offset = 0;
@@ -522,7 +521,7 @@ CoreFreePoolI (
FSize = LIST_TO_SIZE(Index);
while (Offset + FSize <= DEFAULT_PAGE_ALLOCATION) {
Free = (POOL_FREE *) &NewPage[Offset];
- ASSERT(NULL != Free);
+ ASSERT(Free != NULL);
RemoveEntryList (&Free->Link);
Offset += FSize;
}