]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/GenericBdsLib/DevicePath.c
Clean up GenericBdsLib library Instance.
[mirror_edk2.git] / MdeModulePkg / Library / GenericBdsLib / DevicePath.c
index 7801def6b6c47d78ecdb4829fe93a725e32a9fab..fc6d420d5cbd7e38c91698ca5dd7409d3c489b1c 100644 (file)
@@ -21,45 +21,34 @@ EFI_GUID  mEfiDevicePathMessagingUartFlowControlGuid = DEVICE_PATH_MESSAGING_UAR
 EFI_GUID mEfiDevicePathMessagingSASGuid = DEVICE_PATH_MESSAGING_SAS;\r
 \r
 \r
-VOID *\r
-ReallocatePool (\r
-  IN VOID                 *OldPool,\r
-  IN UINTN                OldSize,\r
-  IN UINTN                NewSize\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Adjusts the size of a previously allocated buffer.\r
 \r
-Arguments:\r
-\r
-  OldPool               - A pointer to the buffer whose size is being adjusted.\r
-\r
-  OldSize               - The size of the current buffer.\r
 \r
-  NewSize               - The size of the new buffer.\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
-Returns:\r
+  @return The new buffer allocated. If allocatio failed, NULL will be returned.\r
 \r
-  EFI_SUCEESS           - The requested number of bytes were allocated.\r
-\r
-  EFI_OUT_OF_RESOURCES  - The pool requested could not be allocated.\r
-\r
-  EFI_INVALID_PARAMETER - The buffer was invalid.\r
-\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) {\r
+  if (NewSize != 0) {\r
     NewPool = AllocateZeroPool (NewSize);\r
   }\r
 \r
-  if (OldPool) {\r
-    if (NewPool) {\r
+  if (OldPool != NULL) {\r
+    if (NewPool != NULL) {\r
       CopyMem (NewPool, OldPool, OldSize < NewSize ? OldSize : NewSize);\r
     }\r
 \r
@@ -78,9 +67,11 @@ Returns:
                    allocated.\r
   @param  fmt      The format string\r
 \r
+  @param  ...      Variable argument list.\r
+\r
   @return Allocated buffer with the formatted string printed in it.\r
-  @return The caller must free the allocated buffer.   The buffer\r
-  @return allocation is not packed.\r
+          The caller must free the allocated buffer.   The buffer\r
+          allocation is not packed.\r
 \r
 **/\r
 CHAR16 *\r
@@ -92,37 +83,37 @@ CatPrint (
   )\r
 {\r
   UINT16  *AppendStr;\r
-  VA_LIST args;\r
-  UINTN   strsize;\r
+  VA_LIST Args;\r
+  UINTN   StringSize;\r
 \r
   AppendStr = AllocateZeroPool (0x1000);\r
   if (AppendStr == NULL) {\r
     return Str->str;\r
   }\r
 \r
-  VA_START (args, fmt);\r
-  UnicodeVSPrint (AppendStr, 0x1000, fmt, args);\r
-  VA_END (args);\r
+  VA_START (Args, fmt);\r
+  UnicodeVSPrint (AppendStr, 0x1000, fmt, Args);\r
+  VA_END (Args);\r
   if (NULL == Str->str) {\r
-    strsize   = StrSize (AppendStr);\r
-    Str->str  = AllocateZeroPool (strsize);\r
+    StringSize   = StrSize (AppendStr);\r
+    Str->str  = AllocateZeroPool (StringSize);\r
     ASSERT (Str->str != NULL);\r
   } else {\r
-    strsize = StrSize (AppendStr);\r
-    strsize += (StrSize (Str->str) - sizeof (UINT16));\r
+    StringSize = StrSize (AppendStr);\r
+    StringSize += (StrSize (Str->str) - sizeof (UINT16));\r
 \r
     Str->str = ReallocatePool (\r
                 Str->str,\r
                 StrSize (Str->str),\r
-                strsize\r
+                StringSize\r
                 );\r
     ASSERT (Str->str != NULL);\r
   }\r
 \r
   Str->maxlen = MAX_CHAR * sizeof (UINT16);\r
-  if (strsize < Str->maxlen) {\r
+  if (StringSize < Str->maxlen) {\r
     StrCat (Str->str, AppendStr);\r
-    Str->len = strsize - sizeof (UINT16);\r
+    Str->len = StringSize - sizeof (UINT16);\r
   }\r
 \r
   gBS->FreePool (AppendStr);\r
@@ -170,7 +161,7 @@ BdsLibUnpackDevicePath (
   // Allocate space for the unpacked path\r
   //\r
   NewPath = AllocateZeroPool (Size);\r
-  if (NewPath) {\r
+  if (NewPath != NULL) {\r
 \r
     ASSERT (((UINTN) NewPath) % MIN_ALIGNMENT_SIZE == 0);\r
 \r
@@ -198,6 +189,16 @@ BdsLibUnpackDevicePath (
   return NewPath;\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathPci (\r
   IN OUT POOL_PRINT       *Str,\r
@@ -210,6 +211,16 @@ DevPathPci (
   CatPrint (Str, L"Pci(%x|%x)", (UINTN) Pci->Device, (UINTN) Pci->Function);\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathPccard (\r
   IN OUT POOL_PRINT       *Str,\r
@@ -222,6 +233,16 @@ DevPathPccard (
   CatPrint (Str, L"Pcmcia(Function%x)", (UINTN) Pccard->FunctionNumber);\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathMemMap (\r
   IN OUT POOL_PRINT       *Str,\r
@@ -240,6 +261,16 @@ DevPathMemMap (
     );\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathController (\r
   IN OUT POOL_PRINT       *Str,\r
@@ -254,12 +285,13 @@ DevPathController (
 \r
 \r
 /**\r
-  Convert Vendor device path to device name\r
+  Convert Device Path to a Unicode string for printing.\r
 \r
-  @param  Str      The buffer store device name\r
-  @param  DevPath  Pointer to vendor device path\r
-\r
-  @return When it return, the device name have been stored in *Str.\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
 \r
 **/\r
 VOID\r
@@ -350,9 +382,9 @@ DevPathVendor (
         CatPrint (\r
           Str,\r
           L"%s,%s,%s,",\r
-          (Info & (0x1 << 4)) ? L"SATA" : L"SAS",\r
-          (Info & (0x1 << 5)) ? L"External" : L"Internal",\r
-          (Info & (0x1 << 6)) ? L"Expanded" : L"Direct"\r
+          ((Info & (0x1 << 4)) != 0) ? L"SATA" : L"SAS",\r
+          ((Info & (0x1 << 5)) != 0) ? L"External" : L"Internal",\r
+          ((Info & (0x1 << 6)) != 0) ? L"Expanded" : L"Direct"\r
           );\r
         if ((Info & 0x0f) == 1) {\r
           CatPrint (Str, L"0,");\r
@@ -393,6 +425,16 @@ DevPathVendor (
 }\r
 \r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathAcpi (\r
   IN OUT POOL_PRINT       *Str,\r
@@ -409,6 +451,16 @@ DevPathAcpi (
   }\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathExtendedAcpi (\r
   IN OUT POOL_PRINT       *Str,\r
@@ -443,7 +495,7 @@ DevPathExtendedAcpi (
   // find HIDSTR\r
   //\r
   Anchor = 16;\r
-  for (Index = Anchor; Index < Length && AsChar8Array[Index]; Index++) {\r
+  for (Index = Anchor; Index < Length && AsChar8Array[Index] != '\0'; Index++) {\r
     ;\r
   }\r
   if (Index > Anchor) {\r
@@ -453,7 +505,7 @@ DevPathExtendedAcpi (
   // find UIDSTR\r
   //\r
   Anchor = (UINT16) (Index + 1);\r
-  for (Index = Anchor; Index < Length && AsChar8Array[Index]; Index++) {\r
+  for (Index = Anchor; Index < Length && AsChar8Array[Index] != '\0'; Index++) {\r
     ;\r
   }\r
   if (Index > Anchor) {\r
@@ -463,7 +515,7 @@ DevPathExtendedAcpi (
   // find CIDSTR\r
   //\r
   Anchor = (UINT16) (Index + 1);\r
-  for (Index = Anchor; Index < Length && AsChar8Array[Index]; Index++) {\r
+  for (Index = Anchor; Index < Length && AsChar8Array[Index] != '\0'; Index++) {\r
     ;\r
   }\r
   if (Index > Anchor) {\r
@@ -520,6 +572,16 @@ DevPathExtendedAcpi (
 \r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathAdrAcpi (\r
   IN OUT POOL_PRINT       *Str,\r
@@ -542,6 +604,16 @@ DevPathAdrAcpi (
   CatPrint (Str, L")");\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathAtapi (\r
   IN OUT POOL_PRINT       *Str,\r
@@ -559,6 +631,16 @@ DevPathAtapi (
     );\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathScsi (\r
   IN OUT POOL_PRINT       *Str,\r
@@ -571,6 +653,16 @@ DevPathScsi (
   CatPrint (Str, L"Scsi(Pun%x,Lun%x)", (UINTN) Scsi->Pun, (UINTN) Scsi->Lun);\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathFibre (\r
   IN OUT POOL_PRINT       *Str,\r
@@ -583,18 +675,38 @@ DevPathFibre (
   CatPrint (Str, L"Fibre(Wwn%lx,Lun%x)", Fibre->WWN, Fibre->Lun);\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPath1394 (\r
   IN OUT POOL_PRINT       *Str,\r
   IN VOID                 *DevPath\r
   )\r
 {\r
-  F1394_DEVICE_PATH *F1394;\r
+  F1394_DEVICE_PATH *F1394Path;\r
 \r
-  F1394 = DevPath;\r
-  CatPrint (Str, L"1394(%g)", &F1394->Guid);\r
+  F1394Path = DevPath;\r
+  CatPrint (Str, L"1394(%g)", &F1394Path->Guid);\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathUsb (\r
   IN OUT POOL_PRINT       *Str,\r
@@ -607,6 +719,16 @@ DevPathUsb (
   CatPrint (Str, L"Usb(%x,%x)", (UINTN) Usb->ParentPortNumber, (UINTN) Usb->InterfaceNumber);\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathUsbWWID (\r
   IN OUT POOL_PRINT       *Str,\r
@@ -625,6 +747,16 @@ DevPathUsbWWID (
     );\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathLogicalUnit (\r
   IN OUT POOL_PRINT       *Str,\r
@@ -637,6 +769,16 @@ DevPathLogicalUnit (
   CatPrint (Str, L"Unit(%x)", (UINTN) LogicalUnit->Lun);\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathUsbClass (\r
   IN OUT POOL_PRINT       *Str,\r
@@ -657,6 +799,16 @@ DevPathUsbClass (
     );\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathSata (\r
   IN OUT POOL_PRINT       *Str,\r
@@ -675,95 +827,145 @@ DevPathSata (
     );\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathI2O (\r
   IN OUT POOL_PRINT       *Str,\r
   IN VOID                 *DevPath\r
   )\r
 {\r
-  I2O_DEVICE_PATH *I2O;\r
+  I2O_DEVICE_PATH *I2OPath;\r
 \r
-  I2O = DevPath;\r
-  CatPrint (Str, L"I2O(%x)", (UINTN) I2O->Tid);\r
+  I2OPath = DevPath;\r
+  CatPrint (Str, L"I2O(%x)", (UINTN) I2OPath->Tid);\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathMacAddr (\r
   IN OUT POOL_PRINT       *Str,\r
   IN VOID                 *DevPath\r
   )\r
 {\r
-  MAC_ADDR_DEVICE_PATH  *MAC;\r
+  MAC_ADDR_DEVICE_PATH  *MACDevPath;\r
   UINTN                 HwAddressSize;\r
   UINTN                 Index;\r
 \r
-  MAC           = DevPath;\r
+  MACDevPath           = DevPath;\r
 \r
   HwAddressSize = sizeof (EFI_MAC_ADDRESS);\r
-  if (MAC->IfType == 0x01 || MAC->IfType == 0x00) {\r
+  if (MACDevPath->IfType == 0x01 || MACDevPath->IfType == 0x00) {\r
     HwAddressSize = 6;\r
   }\r
 \r
   CatPrint (Str, L"Mac(");\r
 \r
   for (Index = 0; Index < HwAddressSize; Index++) {\r
-    CatPrint (Str, L"%02x", (UINTN) MAC->MacAddress.Addr[Index]);\r
+    CatPrint (Str, L"%02x", (UINTN) MACDevPath->MacAddress.Addr[Index]);\r
   }\r
 \r
   CatPrint (Str, L")");\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathIPv4 (\r
   IN OUT POOL_PRINT       *Str,\r
   IN VOID                 *DevPath\r
   )\r
 {\r
-  IPv4_DEVICE_PATH  *IP;\r
+  IPv4_DEVICE_PATH  *IPDevPath;\r
 \r
-  IP = DevPath;\r
+  IPDevPath = DevPath;\r
   CatPrint (\r
     Str,\r
     L"IPv4(%d.%d.%d.%d:%d)",\r
-    (UINTN) IP->RemoteIpAddress.Addr[0],\r
-    (UINTN) IP->RemoteIpAddress.Addr[1],\r
-    (UINTN) IP->RemoteIpAddress.Addr[2],\r
-    (UINTN) IP->RemoteIpAddress.Addr[3],\r
-    (UINTN) IP->RemotePort\r
+    (UINTN) IPDevPath->RemoteIpAddress.Addr[0],\r
+    (UINTN) IPDevPath->RemoteIpAddress.Addr[1],\r
+    (UINTN) IPDevPath->RemoteIpAddress.Addr[2],\r
+    (UINTN) IPDevPath->RemoteIpAddress.Addr[3],\r
+    (UINTN) IPDevPath->RemotePort\r
     );\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathIPv6 (\r
   IN OUT POOL_PRINT       *Str,\r
   IN VOID                 *DevPath\r
   )\r
 {\r
-  IPv6_DEVICE_PATH  *IP;\r
+  IPv6_DEVICE_PATH  *IPv6DevPath;\r
 \r
-  IP = DevPath;\r
+  IPv6DevPath = DevPath;\r
   CatPrint (\r
     Str,\r
     L"IPv6(%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x)",\r
-    (UINTN) IP->RemoteIpAddress.Addr[0],\r
-    (UINTN) IP->RemoteIpAddress.Addr[1],\r
-    (UINTN) IP->RemoteIpAddress.Addr[2],\r
-    (UINTN) IP->RemoteIpAddress.Addr[3],\r
-    (UINTN) IP->RemoteIpAddress.Addr[4],\r
-    (UINTN) IP->RemoteIpAddress.Addr[5],\r
-    (UINTN) IP->RemoteIpAddress.Addr[6],\r
-    (UINTN) IP->RemoteIpAddress.Addr[7],\r
-    (UINTN) IP->RemoteIpAddress.Addr[8],\r
-    (UINTN) IP->RemoteIpAddress.Addr[9],\r
-    (UINTN) IP->RemoteIpAddress.Addr[10],\r
-    (UINTN) IP->RemoteIpAddress.Addr[11],\r
-    (UINTN) IP->RemoteIpAddress.Addr[12],\r
-    (UINTN) IP->RemoteIpAddress.Addr[13],\r
-    (UINTN) IP->RemoteIpAddress.Addr[14],\r
-    (UINTN) IP->RemoteIpAddress.Addr[15]\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[0],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[1],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[2],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[3],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[4],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[5],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[6],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[7],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[8],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[9],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[10],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[11],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[12],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[13],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[14],\r
+    (UINTN) IPv6DevPath->RemoteIpAddress.Addr[15]\r
     );\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathInfiniBand (\r
   IN OUT POOL_PRINT       *Str,\r
@@ -784,6 +986,16 @@ DevPathInfiniBand (
     );\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathUart (\r
   IN OUT POOL_PRINT       *Str,\r
@@ -859,42 +1071,62 @@ DevPathUart (
   }\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathiSCSI (\r
   IN OUT POOL_PRINT       *Str,\r
   IN VOID                 *DevPath\r
   )\r
 {\r
-  ISCSI_DEVICE_PATH_WITH_NAME *iSCSI;\r
+  ISCSI_DEVICE_PATH_WITH_NAME *IScsi;\r
   UINT16                      Options;\r
 \r
   ASSERT (Str != NULL);\r
   ASSERT (DevPath != NULL);\r
 \r
-  iSCSI = DevPath;\r
+  IScsi = DevPath;\r
   CatPrint (\r
     Str,\r
     L"iSCSI(%s,%x,%lx,",\r
-    iSCSI->iSCSITargetName,\r
-    iSCSI->TargetPortalGroupTag,\r
-    iSCSI->Lun\r
+    IScsi->iSCSITargetName,\r
+    IScsi->TargetPortalGroupTag,\r
+    IScsi->Lun\r
     );\r
 \r
-  Options = iSCSI->LoginOption;\r
-  CatPrint (Str, L"%s,", ((Options >> 1) & 0x0001) ? L"CRC32C" : L"None");\r
-  CatPrint (Str, L"%s,", ((Options >> 3) & 0x0001) ? L"CRC32C" : L"None");\r
-  if ((Options >> 11) & 0x0001) {\r
+  Options = IScsi->LoginOption;\r
+  CatPrint (Str, L"%s,", (((Options >> 1) & 0x0001) != 0) ? L"CRC32C" : L"None");\r
+  CatPrint (Str, L"%s,", (((Options >> 3) & 0x0001) != 0) ? L"CRC32C" : L"None");\r
+  if (((Options >> 11) & 0x0001) != 0) {\r
     CatPrint (Str, L"%s,", L"None");\r
-  } else if ((Options >> 12) & 0x0001) {\r
+  } else if (((Options >> 12) & 0x0001) != 0) {\r
     CatPrint (Str, L"%s,", L"CHAP_UNI");\r
   } else {\r
     CatPrint (Str, L"%s,", L"CHAP_BI");\r
 \r
   }\r
 \r
-  CatPrint (Str, L"%s)", (iSCSI->NetworkProtocol == 0) ? L"TCP" : L"reserved");\r
+  CatPrint (Str, L"%s)", (IScsi->NetworkProtocol == 0) ? L"TCP" : L"reserved");\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathHardDrive (\r
   IN OUT POOL_PRINT       *Str,\r
@@ -935,6 +1167,16 @@ DevPathHardDrive (
   }\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathCDROM (\r
   IN OUT POOL_PRINT       *Str,\r
@@ -947,6 +1189,16 @@ DevPathCDROM (
   CatPrint (Str, L"CDROM(Entry%x)", (UINTN) Cd->BootEntry);\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathFilePath (\r
   IN OUT POOL_PRINT       *Str,\r
@@ -959,6 +1211,16 @@ DevPathFilePath (
   CatPrint (Str, L"%s", Fp->PathName);\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathMediaProtocol (\r
   IN OUT POOL_PRINT       *Str,\r
@@ -971,6 +1233,16 @@ DevPathMediaProtocol (
   CatPrint (Str, L"Media(%g)", &MediaProt->Protocol);\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathFvFilePath (\r
   IN OUT POOL_PRINT       *Str,\r
@@ -983,6 +1255,16 @@ DevPathFvFilePath (
   CatPrint (Str, L"%g", &FvFilePath->FvFileName);\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathBssBss (\r
   IN OUT POOL_PRINT       *Str,\r
@@ -1029,6 +1311,16 @@ DevPathBssBss (
   CatPrint (Str, L"Legacy-%s", Type);\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathEndInstance (\r
   IN OUT POOL_PRINT       *Str,\r
@@ -1038,6 +1330,16 @@ DevPathEndInstance (
   CatPrint (Str, L",");\r
 }\r
 \r
+/**\r
+  Convert Device Path to a Unicode string for printing.\r
+\r
+  @param Str             The buffer holding the output string.\r
+                         This buffer contains the length of the\r
+                         string and the maixmum length reserved\r
+                         for the string buffer.\r
+  @param DevPath         The device path.\r
+\r
+**/\r
 VOID\r
 DevPathNodeUnknown (\r
   IN OUT POOL_PRINT       *Str,\r
@@ -1289,12 +1591,12 @@ LibDuplicateDevicePathInstance (
   // Make a copy\r
   //\r
   NewDevPath = NULL;\r
-  if (Size) {\r
+  if (Size != 0) {\r
     NewDevPath = AllocateZeroPool (Size);\r
     ASSERT (NewDevPath != NULL);\r
   }\r
 \r
-  if (NewDevPath) {\r
+  if (NewDevPath != NULL) {\r
     CopyMem (NewDevPath, DevicePathInst, Size);\r
   }\r
 \r