]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Mem/Pool.c
Fix comparisons of enumerated types which may cause warnings for some compilers.
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Mem / Pool.c
index ce70cff51353efce46f5eae472e24d00d2a30197..e0f0869e53df5ea1b552fce780290c11ff3894e2 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
   UEFI Memory pool management functions.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
@@ -15,7 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "DxeMain.h"\r
 #include "Imem.h"\r
 \r
-#define POOL_FREE_SIGNATURE   EFI_SIGNATURE_32('p','f','r','0')\r
+#define POOL_FREE_SIGNATURE   SIGNATURE_32('p','f','r','0')\r
 typedef struct {\r
   UINT32          Signature;\r
   UINT32          Index;\r
@@ -23,7 +23,7 @@ typedef struct {
 } POOL_FREE;\r
 \r
 \r
-#define POOL_HEAD_SIGNATURE   EFI_SIGNATURE_32('p','h','d','0')\r
+#define POOL_HEAD_SIGNATURE   SIGNATURE_32('p','h','d','0')\r
 typedef struct {\r
   UINT32          Signature;\r
   UINT32          Size;\r
@@ -32,9 +32,9 @@ typedef struct {
   CHAR8           Data[1];\r
 } POOL_HEAD;\r
 \r
-#define SIZE_OF_POOL_HEAD EFI_FIELD_OFFSET(POOL_HEAD,Data)\r
+#define SIZE_OF_POOL_HEAD OFFSET_OF(POOL_HEAD,Data)\r
 \r
-#define POOL_TAIL_SIGNATURE   EFI_SIGNATURE_32('p','t','a','l')\r
+#define POOL_TAIL_SIGNATURE   SIGNATURE_32('p','t','a','l')\r
 typedef struct {\r
   UINT32      Signature;\r
   UINT32      Size;\r
@@ -60,7 +60,7 @@ typedef struct {
 // Globals\r
 //\r
 \r
-#define POOL_SIGNATURE  EFI_SIGNATURE_32('p','l','s','t')\r
+#define POOL_SIGNATURE  SIGNATURE_32('p','l','s','t')\r
 typedef struct {\r
     INTN             Signature;\r
     UINTN            Used;\r
@@ -120,7 +120,7 @@ LookupPoolHead (
   POOL            *Pool;\r
   UINTN           Index;\r
 \r
-  if (MemoryType >= 0 && MemoryType < EfiMaxMemoryType) {\r
+  if ((UINT32)MemoryType < EfiMaxMemoryType) {\r
     return &mPoolHead[MemoryType];\r
   }\r
 \r
@@ -128,7 +128,7 @@ LookupPoolHead (
   // MemoryType values in the range 0x80000000..0xFFFFFFFF are reserved for use by UEFI \r
   // OS loaders that are provided by operating system vendors\r
   //\r
-  if (MemoryType < 0) {\r
+  if ((INT32)MemoryType < 0) {\r
 \r
     for (Link = mPoolHeadList.ForwardLink; Link != &mPoolHeadList; Link = Link->ForwardLink) {\r
       Pool = CR(Link, POOL, Link, POOL_SIGNATURE);\r
@@ -167,7 +167,7 @@ LookupPoolHead (
   @param  Buffer                 The address to return a pointer to the allocated\r
                                  pool\r
 \r
-  @retval EFI_INVALID_PARAMETER  PoolType not valid\r
+  @retval EFI_INVALID_PARAMETER  PoolType not valid or Buffer is NULL. \r
   @retval EFI_OUT_OF_RESOURCES   Size exceeds max pool size or allocation failed.\r
   @retval EFI_SUCCESS            Pool successfully allocated.\r
 \r
@@ -190,6 +190,10 @@ CoreAllocatePool (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
+  if (Buffer == NULL) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
   *Buffer = NULL;\r
 \r
   //\r
@@ -546,7 +550,7 @@ CoreFreePoolI (
   // portion of that memory type has been freed.  If it has, then free the\r
   // list entry for that memory type\r
   //\r
-  if (Pool->MemoryType < 0 && Pool->Used == 0) {\r
+  if ((INT32)Pool->MemoryType < 0 && Pool->Used == 0) {\r
     RemoveEntryList (&Pool->Link);\r
     CoreFreePoolI (Pool);\r
   }\r