]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix several code review minor comments:
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 17 Sep 2008 13:29:44 +0000 (13:29 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 17 Sep 2008 13:29:44 +0000 (13:29 +0000)
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

MdeModulePkg/Core/Dxe/Mem/Pool.c

index c60761a0455c375de063eeb300e8e6c5c8b7ff98..2764a8ef9ff3f50680c21d9a4b772245bdec5484 100644 (file)
@@ -76,7 +76,7 @@ POOL            mPoolHead[EfiMaxMemoryType];
 //\r
 // List of pool header to search for the appropriate memory type.\r
 //\r
-LIST_ENTRY      mPoolHeadList;\r
+LIST_ENTRY      mPoolHeadList = INITIALIZE_LIST_HEAD_VARIABLE (mPoolHeadList);\r
 \r
 \r
 /**\r
@@ -99,7 +99,6 @@ CoreInitializePool (
         InitializeListHead (&mPoolHead[Type].FreeList[Index]);\r
     }\r
   }\r
-  InitializeListHead (&mPoolHeadList);\r
 }\r
 \r
 \r
@@ -333,10 +332,10 @@ Done:
 \r
     DEBUG ((\r
       DEBUG_POOL,\r
-      "AllocatePoolI: Type %x, Addr %x (len %x) %,d\n", PoolType,\r
+      "AllocatePoolI: Type %x, Addr %p (len %lx) %,ld\n", PoolType,\r
       Buffer,\r
-      Size - POOL_OVERHEAD,\r
-      Pool->Used\r
+      (UINT64)(Size - POOL_OVERHEAD),\r
+      (UINT64) Pool->Used\r
       ));\r
 \r
     //\r
@@ -345,7 +344,7 @@ Done:
     Pool->Used += Size;\r
 \r
   } else {\r
-    DEBUG ((DEBUG_ERROR | DEBUG_POOL, "AllocatePool: failed to allocate %d bytes\n", Size));\r
+    DEBUG ((DEBUG_ERROR | DEBUG_POOL, "AllocatePool: failed to allocate %ld bytes\n", (UINT64) Size));\r
   }\r
 \r
   return Buffer;\r
@@ -409,19 +408,19 @@ CoreFreePoolI (
   UINTN       Offset;\r
   BOOLEAN     AllFree;\r
 \r
-  ASSERT(NULL != Buffer);\r
+  ASSERT(Buffer != NULL);\r
   //\r
   // Get the head & tail of the pool entry\r
   //\r
   Head = CR (Buffer, POOL_HEAD, Data, POOL_HEAD_SIGNATURE);\r
-  ASSERT(NULL != Head);\r
+  ASSERT(Head != NULL);\r
 \r
   if (Head->Signature != POOL_HEAD_SIGNATURE) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
   Tail = HEAD_TO_TAIL (Head);\r
-  ASSERT(NULL != Tail);\r
+  ASSERT(Tail != NULL);\r
 \r
   //\r
   // Debug\r
@@ -447,7 +446,7 @@ CoreFreePoolI (
     return EFI_INVALID_PARAMETER;\r
   }\r
   Pool->Used -= Size;\r
-  DEBUG ((DEBUG_POOL, "FreePool: %x (len %x) %,d\n", Head->Data, Head->Size - POOL_OVERHEAD, Pool->Used));\r
+  DEBUG ((DEBUG_POOL, "FreePool: %p (len %lx) %,ld\n", Head->Data, (UINT64)(Head->Size - POOL_OVERHEAD), (UINT64) Pool->Used));\r
 \r
   //\r
   // Determine the pool list\r
@@ -473,7 +472,7 @@ CoreFreePoolI (
     // Put the pool entry onto the free pool list\r
     //\r
     Free = (POOL_FREE *) Head;\r
-    ASSERT(NULL != Free);\r
+    ASSERT(Free != NULL);\r
     Free->Signature = POOL_FREE_SIGNATURE;\r
     Free->Index     = (UINT32)Index;\r
     InsertHeadList (&Pool->FreeList[Index], &Free->Link);\r
@@ -497,7 +496,7 @@ CoreFreePoolI (
         FSize = LIST_TO_SIZE(Index);\r
         while (Offset + FSize <= DEFAULT_PAGE_ALLOCATION) {\r
           Free = (POOL_FREE *) &NewPage[Offset];\r
-          ASSERT(NULL != Free);\r
+          ASSERT(Free != NULL);\r
           if (Free->Signature != POOL_FREE_SIGNATURE) {\r
             AllFree = FALSE;\r
           }\r
@@ -514,7 +513,7 @@ CoreFreePoolI (
         // Remove all of these pool entries from the free loop lists.\r
         //\r
         Free = (POOL_FREE *) &NewPage[0];\r
-        ASSERT(NULL != Free);\r
+        ASSERT(Free != NULL);\r
         Index = Free->Index;\r
         Offset = 0;\r
 \r
@@ -522,7 +521,7 @@ CoreFreePoolI (
           FSize = LIST_TO_SIZE(Index);\r
           while (Offset + FSize <= DEFAULT_PAGE_ALLOCATION) {\r
             Free = (POOL_FREE *) &NewPage[Offset];\r
-            ASSERT(NULL != Free);\r
+            ASSERT(Free != NULL);\r
             RemoveEntryList (&Free->Link);\r
             Offset += FSize;\r
           }\r