]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Disk/PartitionDxe/Gpt.c
Modified for use reversion field and fix a typo.
[mirror_edk2.git] / MdeModulePkg / Universal / Disk / PartitionDxe / Gpt.c
index ef3c766e536ecfcdf0cab564965e6d417a5e5808..8cb78abfc1ab64132f5731a963621c5fcc11dba7 100644 (file)
@@ -79,7 +79,7 @@ PartitionRestoreGptTable (
 \r
 \r
 /**\r
-  Restore Partition Table to its alternate place\r
+  Restore Partition Table to its alternate place.\r
   (Primary -> Backup or Backup -> Primary)\r
 \r
   @param[in]    PartHeader    Partition table header structure\r
@@ -97,7 +97,7 @@ PartitionCheckGptEntry (
 \r
 \r
 /**\r
-  Checks the CRC32 value in the table header\r
+  Checks the CRC32 value in the table header.\r
 \r
   @param  MaxSize   Max Size limit\r
   @param  Size      The size of the table\r
@@ -116,7 +116,7 @@ PartitionCheckCrcAltSize (
 \r
 \r
 /**\r
-  Checks the CRC32 value in the table header\r
+  Checks the CRC32 value in the table header.\r
 \r
   @param  MaxSize   Max Size limit\r
   @param  Hdr       Table to check\r
@@ -133,7 +133,7 @@ PartitionCheckCrc (
 \r
 \r
 /**\r
-  Updates the CRC32 value in the table header\r
+  Updates the CRC32 value in the table header.\r
 \r
   @param  Size   The size of the table\r
   @param  Hdr    Table to update\r
@@ -147,7 +147,7 @@ PartitionSetCrcAltSize (
 \r
 \r
 /**\r
-  Updates the CRC32 value in the table header\r
+  Updates the CRC32 value in the table header.\r
 \r
   @param  Hdr    Table to update\r
 \r
@@ -189,7 +189,7 @@ PartitionInstallGptChildHandles (
   EFI_PARTITION_ENTRY         *PartEntry;\r
   EFI_PARTITION_ENTRY_STATUS  *PEntryStatus;\r
   UINTN                       Index;\r
-  EFI_STATUS                  GptValid;\r
+  EFI_STATUS                  GptValidStatus;\r
   HARDDRIVE_DEVICE_PATH       HdDev;\r
 \r
   ProtectiveMbr = NULL;\r
@@ -202,9 +202,9 @@ PartitionInstallGptChildHandles (
   LastBlock     = BlockIo->Media->LastBlock;\r
 \r
   DEBUG ((EFI_D_INFO, " BlockSize : %d \n", BlockSize));\r
-  DEBUG ((EFI_D_INFO, " LastBlock : %x \n", LastBlock));\r
+  DEBUG ((EFI_D_INFO, " LastBlock : %lx \n", LastBlock));\r
 \r
-  GptValid = EFI_NOT_FOUND;\r
+  GptValidStatus = EFI_NOT_FOUND;\r
 \r
   //\r
   // Allocate a buffer for the Protective MBR\r
@@ -225,7 +225,7 @@ PartitionInstallGptChildHandles (
                       ProtectiveMbr\r
                       );\r
   if (EFI_ERROR (Status)) {\r
-    GptValid = Status;\r
+    GptValidStatus = Status;\r
     goto Done;\r
   }\r
   //\r
@@ -247,7 +247,6 @@ PartitionInstallGptChildHandles (
   }\r
 \r
   BackupHeader = AllocateZeroPool (sizeof (EFI_PARTITION_TABLE_HEADER));\r
-\r
   if (BackupHeader == NULL) {\r
     goto Done;\r
   }\r
@@ -304,8 +303,8 @@ PartitionInstallGptChildHandles (
                     PartEntry\r
                     );\r
   if (EFI_ERROR (Status)) {\r
-    GptValid = Status;\r
-    DEBUG ((EFI_D_INFO, " Partition Entry ReadBlocks error\n"));\r
+    GptValidStatus = Status;\r
+    DEBUG ((EFI_D_ERROR, " Partition Entry ReadBlocks error\n"));\r
     goto Done;\r
   }\r
 \r
@@ -327,7 +326,7 @@ PartitionInstallGptChildHandles (
   //\r
   // If we got this far the GPT layout of the disk is valid and we should return true\r
   //\r
-  GptValid = EFI_SUCCESS;\r
+  GptValidStatus = EFI_SUCCESS;\r
 \r
   //\r
   // Create child device handles\r
@@ -355,12 +354,12 @@ PartitionInstallGptChildHandles (
     HdDev.PartitionSize   = PartEntry[Index].EndingLBA - PartEntry[Index].StartingLBA + 1;\r
     CopyMem (HdDev.Signature, &PartEntry[Index].UniquePartitionGUID, sizeof (EFI_GUID));\r
 \r
-    DEBUG ((EFI_D_INFO, " Index : %d\n", Index));\r
-    DEBUG ((EFI_D_INFO, " Start LBA : %x\n", HdDev.PartitionStart));\r
-    DEBUG ((EFI_D_INFO, " End LBA : %x\n", PartEntry[Index].EndingLBA));\r
-    DEBUG ((EFI_D_INFO, " Partition size: %x\n", HdDev.PartitionSize));\r
-    DEBUG ((EFI_D_INFO, " Start : %x", MultU64x32 (PartEntry[Index].StartingLBA, BlockSize)));\r
-    DEBUG ((EFI_D_INFO, " End : %x\n", MultU64x32 (PartEntry[Index].EndingLBA, BlockSize)));\r
+    DEBUG ((EFI_D_INFO, " Index : %d\n", (UINT32) Index));\r
+    DEBUG ((EFI_D_INFO, " Start LBA : %lx\n", (UINT64) HdDev.PartitionStart));\r
+    DEBUG ((EFI_D_INFO, " End LBA : %lx\n", (UINT64) PartEntry[Index].EndingLBA));\r
+    DEBUG ((EFI_D_INFO, " Partition size: %lx\n", (UINT64) HdDev.PartitionSize));\r
+    DEBUG ((EFI_D_INFO, " Start : %lx", MultU64x32 (PartEntry[Index].StartingLBA, BlockSize)));\r
+    DEBUG ((EFI_D_INFO, " End : %lx\n", MultU64x32 (PartEntry[Index].EndingLBA, BlockSize)));\r
 \r
     Status = PartitionInstallChildHandle (\r
               This,\r
@@ -395,7 +394,7 @@ Done:
     FreePool (PEntryStatus);\r
   }\r
 \r
-  return GptValid;\r
+  return GptValidStatus;\r
 }\r
 \r
 \r
@@ -450,7 +449,7 @@ PartitionValidGptTable (
       !PartitionCheckCrc (BlockSize, &PartHdr->Header) ||\r
       PartHdr->MyLBA != Lba\r
       ) {\r
-    DEBUG ((EFI_D_INFO, " !Valid efi partition table header\n"));\r
+    DEBUG ((EFI_D_INFO, "Invalid efi partition table header\n"));\r
     FreePool (PartHdr);\r
     return FALSE;\r
   }\r
@@ -608,7 +607,10 @@ PartitionRestoreGptTable (
 \r
 Done:\r
   FreePool (PartHdr);\r
-  FreePool (Ptr);\r
+\r
+  if (Ptr != NULL) {\r
+    FreePool (Ptr);\r
+  }\r
 \r
   if (EFI_ERROR (Status)) {\r
     return FALSE;\r
@@ -619,7 +621,7 @@ Done:
 \r
 \r
 /**\r
-  Restore Partition Table to its alternate place\r
+  Restore Partition Table to its alternate place.\r
   (Primary -> Backup or Backup -> Primary)\r
 \r
   @param[in]    PartHeader    Partition table header structure\r
@@ -681,7 +683,7 @@ PartitionCheckGptEntry (
 \r
 \r
 /**\r
-  Updates the CRC32 value in the table header\r
+  Updates the CRC32 value in the table header.\r
 \r
   @param  Hdr    Table to update\r
 \r
@@ -696,7 +698,7 @@ PartitionSetCrc (
 \r
 \r
 /**\r
-  Updates the CRC32 value in the table header\r
+  Updates the CRC32 value in the table header.\r
 \r
   @param  Size   The size of the table\r
   @param  Hdr    Table to update\r
@@ -707,7 +709,6 @@ PartitionSetCrcAltSize (
   IN UINTN                 Size,\r
   IN OUT EFI_TABLE_HEADER  *Hdr\r
   )\r
-\r
 {\r
   UINT32  Crc;\r
 \r
@@ -718,7 +719,7 @@ PartitionSetCrcAltSize (
 \r
 \r
 /**\r
-  Checks the CRC32 value in the table header\r
+  Checks the CRC32 value in the table header.\r
 \r
   @param  MaxSize   Max Size limit\r
   @param  Hdr       Table to check\r
@@ -738,7 +739,7 @@ PartitionCheckCrc (
 \r
 \r
 /**\r
-  Checks the CRC32 value in the table header\r
+  Checks the CRC32 value in the table header.\r
 \r
   @param  MaxSize   Max Size limit\r
   @param  Size      The size of the table\r
@@ -768,7 +769,7 @@ PartitionCheckCrcAltSize (
     return FALSE;\r
   }\r
 \r
-  if (MaxSize && Size > MaxSize) {\r
+  if ((MaxSize != 0) && (Size > MaxSize)) {\r
     DEBUG ((EFI_D_ERROR, "CheckCrc32: Size > MaxSize\n"));\r
     return FALSE;\r
   }\r