]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/DevicePathDxe/DevicePathToText.c
Add some ASSERT()s.
[mirror_edk2.git] / MdeModulePkg / Universal / DevicePathDxe / DevicePathToText.c
index a9f6afcf4a177f58778e41bfbc8eed1ceee9cf10..d45c267ffbbcfe5c9387c0444bc5820e66032d85 100644 (file)
@@ -14,41 +14,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include "DevicePath.h"\r
 \r
-/**\r
-  Adjusts the size of a previously allocated buffer.\r
-\r
-  @param OldPool         A pointer to the buffer whose size is being adjusted.\r
-  @param OldSize         The size of the current buffer.\r
-  @param NewSize         The size of the new buffer.\r
-\r
-  @return A pointer to the new buffer or NULL if allocation fails.\r
-\r
-**/\r
-VOID *\r
-ReallocatePool (\r
-  IN VOID                 *OldPool,\r
-  IN UINTN                OldSize,\r
-  IN UINTN                NewSize\r
-  )\r
-{\r
-  VOID  *NewPool;\r
-\r
-  NewPool = NULL;\r
-  if (NewSize != 0) {\r
-    NewPool = AllocateZeroPool (NewSize);\r
-  }\r
-\r
-  if (OldPool != NULL) {\r
-    if (NewPool != NULL) {\r
-      CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize);\r
-    }\r
-\r
-    FreePool (OldPool);\r
-  }\r
-\r
-  return NewPool;\r
-}\r
-\r
 /**\r
   Concatenates a formatted unicode string to allocated pool. The caller must\r
   free the resulting buffer.\r
@@ -90,10 +55,10 @@ CatPrint (
     Size = StrSize (AppendStr) - sizeof (UINT16);\r
     Size = Size + StrSize (Str->Str);\r
     Str->Str = ReallocatePool (\r
-                Str->Str,\r
-                StrSize (Str->Str),\r
-                Size\r
-                );\r
+                 StrSize (Str->Str),\r
+                 Size,\r
+                 Str->Str\r
+                 );\r
     ASSERT (Str->Str != NULL);\r
   }\r
 \r
@@ -108,9 +73,9 @@ CatPrint (
 }\r
 \r
 /**\r
-  Converts a PCI device path structure to its string representive.\r
+  Converts a PCI device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -135,9 +100,9 @@ DevPathToTextPci (
 }\r
 \r
 /**\r
-  Converts a PC Card device path structure to its string representive.\r
+  Converts a PC Card device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -162,9 +127,9 @@ DevPathToTextPccard (
 }\r
 \r
 /**\r
-  Converts a Memory Map device path structure to its string representive.\r
+  Converts a Memory Map device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -195,9 +160,9 @@ DevPathToTextMemMap (
 }\r
 \r
 /**\r
-  Converts a Vendor device path structure to its string representive.\r
+  Converts a Vendor device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -243,7 +208,7 @@ DevPathToTextVendor (
       } else if (CompareGuid (&Vendor->Guid, &gEfiVTUTF8Guid)) {\r
         CatPrint (Str, L"VenUft8()");\r
         return ;\r
-      } else if (CompareGuid (&Vendor->Guid, &mEfiDevicePathMessagingUartFlowControlGuid)) {\r
+      } else if (CompareGuid (&Vendor->Guid, &gEfiUartDevicePathGuid)) {\r
         FlowControlMap = (((UART_FLOW_CONTROL_DEVICE_PATH *) Vendor)->FlowControlMap);\r
         switch (FlowControlMap & 0x00000003) {\r
         case 0:\r
@@ -263,7 +228,7 @@ DevPathToTextVendor (
         }\r
 \r
         return ;\r
-      } else if (CompareGuid (&Vendor->Guid, &mEfiDevicePathMessagingSASGuid)) {\r
+      } else if (CompareGuid (&Vendor->Guid, &gEfiSasDevicePathGuid)) {\r
         CatPrint (\r
           Str,\r
           L"SAS(0x%lx,0x%lx,0x%x,",\r
@@ -322,9 +287,9 @@ DevPathToTextVendor (
 }\r
 \r
 /**\r
-  Converts a Controller device path structure to its string representive.\r
+  Converts a Controller device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -353,9 +318,9 @@ DevPathToTextController (
 }\r
 \r
 /**\r
-  Converts a ACPI device path structure to its string representive.\r
+  Converts a ACPI device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -439,9 +404,9 @@ EisaIdToText (
 }\r
 \r
 /**\r
-  Converts a ACPI extended HID device path structure to its string representive.\r
+  Converts a ACPI extended HID device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -523,9 +488,9 @@ DevPathToTextAcpiEx (
 }\r
 \r
 /**\r
-  Converts a ACPI address device path structure to its string representive.\r
+  Converts a ACPI address device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -560,9 +525,9 @@ DevPathToTextAcpiAdr (
 }\r
 \r
 /**\r
-  Converts a ATAPI device path structure to its string representive.\r
+  Converts a ATAPI device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -598,9 +563,9 @@ DevPathToTextAtapi (
 }\r
 \r
 /**\r
-  Converts a SCSI device path structure to its string representive.\r
+  Converts a SCSI device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -625,9 +590,9 @@ DevPathToTextScsi (
 }\r
 \r
 /**\r
-  Converts a Fibre device path structure to its string representive.\r
+  Converts a Fibre device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -652,9 +617,9 @@ DevPathToTextFibre (
 }\r
 \r
 /**\r
-  Converts a 1394 device path structure to its string representive.\r
+  Converts a 1394 device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -682,9 +647,9 @@ DevPathToText1394 (
 }\r
 \r
 /**\r
-  Converts a USB device path structure to its string representive.\r
+  Converts a USB device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -709,9 +674,9 @@ DevPathToTextUsb (
 }\r
 \r
 /**\r
-  Converts a USB WWID device path structure to its string representive.\r
+  Converts a USB WWID device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -743,6 +708,7 @@ DevPathToTextUsbWWID (
     // In case no NULL terminator in SerialNumber, create a new one with NULL terminator\r
     //\r
     NewStr = AllocateCopyPool ((Length + 1) * sizeof (CHAR16), SerialNumberStr);\r
+    ASSERT (NewStr != NULL);\r
     NewStr [Length] = 0;\r
     SerialNumberStr = NewStr;\r
   }\r
@@ -758,9 +724,9 @@ DevPathToTextUsbWWID (
 }\r
 \r
 /**\r
-  Converts a Logic Unit device path structure to its string representive.\r
+  Converts a Logic Unit device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -785,9 +751,9 @@ DevPathToTextLogicalUnit (
 }\r
 \r
 /**\r
-  Converts a USB class device path structure to its string representive.\r
+  Converts a USB class device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -921,9 +887,9 @@ DevPathToTextUsbClass (
 }\r
 \r
 /**\r
-  Converts a SATA device path structure to its string representive.\r
+  Converts a SATA device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -954,9 +920,9 @@ DevPathToTextSata (
 }\r
 \r
 /**\r
-  Converts a I20 device path structure to its string representive.\r
+  Converts a I20 device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -981,9 +947,9 @@ DevPathToTextI2O (
 }\r
 \r
 /**\r
-  Converts a MAC address device path structure to its string representive.\r
+  Converts a MAC address device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -1022,9 +988,9 @@ DevPathToTextMacAddr (
 }\r
 \r
 /**\r
-  Converts a IPv4 device path structure to its string representive.\r
+  Converts a IPv4 device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -1074,9 +1040,9 @@ DevPathToTextIPv4 (
 }\r
 \r
 /**\r
-  Converts a IPv6 device path structure to its string representive.\r
+  Converts a IPv6 device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -1162,9 +1128,9 @@ DevPathToTextIPv6 (
 }\r
 \r
 /**\r
-  Converts an Infini Band device path structure to its string representive.\r
+  Converts an Infini Band device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -1197,9 +1163,9 @@ DevPathToTextInfiniBand (
 }\r
 \r
 /**\r
-  Converts a UART device path structure to its string representive.\r
+  Converts a UART device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -1289,9 +1255,9 @@ DevPathToTextUart (
 }\r
 \r
 /**\r
-  Converts an iSCSI device path structure to its string representive.\r
+  Converts an iSCSI device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -1337,9 +1303,9 @@ DevPathToTextiSCSI (
 }\r
 \r
 /**\r
-  Converts a Hard drive device path structure to its string representive.\r
+  Converts a Hard drive device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -1395,9 +1361,9 @@ DevPathToTextHardDrive (
 }\r
 \r
 /**\r
-  Converts a CDROM device path structure to its string representive.\r
+  Converts a CDROM device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -1427,9 +1393,9 @@ DevPathToTextCDROM (
 }\r
 \r
 /**\r
-  Converts a File device path structure to its string representive.\r
+  Converts a File device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -1454,9 +1420,9 @@ DevPathToTextFilePath (
 }\r
 \r
 /**\r
-  Converts a Media protocol device path structure to its string representive.\r
+  Converts a Media protocol device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -1481,9 +1447,9 @@ DevPathToTextMediaProtocol (
 }\r
 \r
 /**\r
-  Converts a Firmware Volume device path structure to its string representive.\r
+  Converts a Firmware Volume device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -1508,9 +1474,9 @@ DevPathToTextFv (
 }\r
 \r
 /**\r
-  Converts a Firmware Volume File device path structure to its string representive.\r
+  Converts a Firmware Volume File device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -1535,9 +1501,9 @@ DevPathToTextFvFile (
 }\r
 \r
 /**\r
-  Converts a BIOS Boot Specification device path structure to its string representive.\r
+  Converts a BIOS Boot Specification device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -1604,9 +1570,9 @@ DevPathToTextBBS (
 }\r
 \r
 /**\r
-  Converts an End-of-Device-Path structure to its string representive.\r
+  Converts an End-of-Device-Path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -1628,9 +1594,9 @@ DevPathToTextEndInstance (
 }\r
 \r
 /**\r
-  Converts an unknown device path structure to its string representive.\r
+  Converts an unknown device path structure to its string representative.\r
 \r
-  @param Str             The string representive of input device.\r
+  @param Str             The string representative of input device.\r
   @param DevPath         The input device path structure.\r
   @param DisplayOnly     If DisplayOnly is TRUE, then the shorter text representation\r
                          of the display node is used, where applicable. If DisplayOnly\r
@@ -1752,7 +1718,7 @@ ConvertDeviceNodeToText (
   // Shrink pool used for string allocation\r
   //\r
   NewSize = (Str.Len + 1) * sizeof (CHAR16);\r
-  Str.Str = ReallocatePool (Str.Str, NewSize, NewSize);\r
+  Str.Str = ReallocatePool (NewSize, NewSize, Str.Str);\r
   ASSERT (Str.Str != NULL);\r
   Str.Str[Str.Len] = 0;\r
   return Str.Str;\r
@@ -1841,7 +1807,7 @@ ConvertDevicePathToText (
   }\r
 \r
   NewSize = (Str.Len + 1) * sizeof (CHAR16);\r
-  Str.Str = ReallocatePool (Str.Str, NewSize, NewSize);\r
+  Str.Str = ReallocatePool (NewSize, NewSize, Str.Str);\r
   ASSERT (Str.Str != NULL);\r
   Str.Str[Str.Len] = 0;\r
   return Str.Str;\r