From 57b4ecb94bceac2484dd9367b2ad111b05e17d97 Mon Sep 17 00:00:00 2001 From: qhuang8 Date: Wed, 17 Sep 2008 13:29:44 +0000 Subject: [PATCH] =?utf8?q?Fix=20several=20code=20review=20minor=20comments?= =?utf8?q?:=201.=20Line=2079:Use=20the=20pre-initialized=20global=20variab?= =?utf8?q?le=20mPoolHeadList=20=3D=20INITIALIZE=5FLIST=5FHEAD=5FVARIABLE?= =?utf8?q?=20(mPoolHeadList)=20to=20remove=20the=20statement=20in=20line?= =?utf8?q?=20102=202.=20Line=20337:=20The=20debug=20print=20statement:=20?= =?utf8?q?=E2=80=9CAddr=20=3D=20%x=E2=80=9D=20should=20change=20to=20?= =?utf8?q?=E2=80=9CAddr=20=3D=20%p=E2=80=9D=20since=20the=20expected=20Buf?= =?utf8?q?fer=20is=20VOID=20*;=20How=20about=20=E2=80=9C(len=20%x)=20%,d?= =?utf8?q?=E2=80=9D=20=3F=20The=20Size=20&=20Pool->Used=20belong=20to=20ty?= =?utf8?q?pe=20UINTN=3F=20Cast=20it=20to=20UINT64=20and=20use=20%lx=203.Li?= =?utf8?q?ne=20413,=20418,=20425,=20477:=20Use=20=E2=80=9CBuffer=20!=3D=20?= =?utf8?q?NULL=E2=80=9D=20instead=20of=20=E2=80=9CNULL=20!=3D=20Buffer?= =?utf8?q?=E2=80=9D=204.=20Line=20451:=20The=20debug=20print=20statement:?= =?utf8?q?=20=E2=80=9CFreePool=20=3D=20%x=E2=80=9D=20should=20change=20to?= =?utf8?q?=20FreePool=20=3D=20%p=E2=80=9D=20since=20Head->Data=20is=20poin?= =?utf8?q?ter;=20How=20about=20=E2=80=9C(len=20%x)=20%,d=E2=80=9D=20=3F=20?= =?utf8?q?The=20Head->Size&=20Pool->Used=20belong=20to=20type=20UINTN=3F?= =?utf8?q?=20Cast=20it=20to=20UINT64=20and=20use=20%lx?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5916 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Core/Dxe/Mem/Pool.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Mem/Pool.c b/MdeModulePkg/Core/Dxe/Mem/Pool.c index c60761a045..2764a8ef9f 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; } -- 2.39.2