]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseLib/SafeString.c
MdePkg: Apply uncrustify changes
[mirror_edk2.git] / MdePkg / Library / BaseLib / SafeString.c
index 149a9c04ba30e586cd2be75c9f4a6f47d1786955..f338a32a3a415ece743fd6ee00c3152980d65919 100644 (file)
 **/\r
 BOOLEAN\r
 InternalSafeStringIsOverlap (\r
-  IN VOID    *Base1,\r
-  IN UINTN   Size1,\r
-  IN VOID    *Base2,\r
-  IN UINTN   Size2\r
+  IN VOID   *Base1,\r
+  IN UINTN  Size1,\r
+  IN VOID   *Base2,\r
+  IN UINTN  Size2\r
   )\r
 {\r
   if ((((UINTN)Base1 >= (UINTN)Base2) && ((UINTN)Base1 < (UINTN)Base2 + Size2)) ||\r
-      (((UINTN)Base2 >= (UINTN)Base1) && ((UINTN)Base2 < (UINTN)Base1 + Size1))) {\r
+      (((UINTN)Base2 >= (UINTN)Base1) && ((UINTN)Base2 < (UINTN)Base1 + Size1)))\r
+  {\r
     return TRUE;\r
   }\r
+\r
   return FALSE;\r
 }\r
 \r
@@ -69,7 +71,7 @@ InternalSafeStringNoStrOverlap (
   IN UINTN   Size2\r
   )\r
 {\r
-  return !InternalSafeStringIsOverlap (Str1, Size1 * sizeof(CHAR16), Str2, Size2 * sizeof(CHAR16));\r
+  return !InternalSafeStringIsOverlap (Str1, Size1 * sizeof (CHAR16), Str2, Size2 * sizeof (CHAR16));\r
 }\r
 \r
 /**\r
@@ -87,10 +89,10 @@ InternalSafeStringNoStrOverlap (
 **/\r
 BOOLEAN\r
 InternalSafeStringNoAsciiStrOverlap (\r
-  IN CHAR8   *Str1,\r
-  IN UINTN   Size1,\r
-  IN CHAR8   *Str2,\r
-  IN UINTN   Size2\r
+  IN CHAR8  *Str1,\r
+  IN UINTN  Size1,\r
+  IN CHAR8  *Str2,\r
+  IN UINTN  Size2\r
   )\r
 {\r
   return !InternalSafeStringIsOverlap (Str1, Size1, Str2, Size2);\r
@@ -115,13 +117,13 @@ InternalSafeStringNoAsciiStrOverlap (
 UINTN\r
 EFIAPI\r
 StrnLenS (\r
-  IN CONST CHAR16              *String,\r
-  IN UINTN                     MaxSize\r
+  IN CONST CHAR16  *String,\r
+  IN UINTN         MaxSize\r
   )\r
 {\r
-  UINTN                             Length;\r
+  UINTN  Length;\r
 \r
-  ASSERT (((UINTN) String & BIT0) == 0);\r
+  ASSERT (((UINTN)String & BIT0) == 0);\r
 \r
   //\r
   // If String is a null pointer or MaxSize is 0, then the StrnLenS function returns zero.\r
@@ -141,8 +143,10 @@ StrnLenS (
     if (Length >= MaxSize - 1) {\r
       return MaxSize;\r
     }\r
+\r
     Length++;\r
   }\r
+\r
   return Length;\r
 }\r
 \r
@@ -170,8 +174,8 @@ StrnLenS (
 UINTN\r
 EFIAPI\r
 StrnSizeS (\r
-  IN CONST CHAR16              *String,\r
-  IN UINTN                     MaxSize\r
+  IN CONST CHAR16  *String,\r
+  IN UINTN         MaxSize\r
   )\r
 {\r
   //\r
@@ -220,15 +224,15 @@ StrnSizeS (
 RETURN_STATUS\r
 EFIAPI\r
 StrCpyS (\r
-  OUT CHAR16       *Destination,\r
-  IN  UINTN        DestMax,\r
-  IN  CONST CHAR16 *Source\r
+  OUT CHAR16        *Destination,\r
+  IN  UINTN         DestMax,\r
+  IN  CONST CHAR16  *Source\r
   )\r
 {\r
-  UINTN            SourceLen;\r
+  UINTN  SourceLen;\r
 \r
-  ASSERT (((UINTN) Destination & BIT0) == 0);\r
-  ASSERT (((UINTN) Source & BIT0) == 0);\r
+  ASSERT (((UINTN)Destination & BIT0) == 0);\r
+  ASSERT (((UINTN)Source & BIT0) == 0);\r
 \r
   //\r
   // 1. Neither Destination nor Source shall be a null pointer.\r
@@ -266,6 +270,7 @@ StrCpyS (
   while (*Source != 0) {\r
     *(Destination++) = *(Source++);\r
   }\r
+\r
   *Destination = 0;\r
 \r
   return RETURN_SUCCESS;\r
@@ -303,16 +308,16 @@ StrCpyS (
 RETURN_STATUS\r
 EFIAPI\r
 StrnCpyS (\r
-  OUT CHAR16       *Destination,\r
-  IN  UINTN        DestMax,\r
-  IN  CONST CHAR16 *Source,\r
-  IN  UINTN        Length\r
+  OUT CHAR16        *Destination,\r
+  IN  UINTN         DestMax,\r
+  IN  CONST CHAR16  *Source,\r
+  IN  UINTN         Length\r
   )\r
 {\r
-  UINTN            SourceLen;\r
+  UINTN  SourceLen;\r
 \r
-  ASSERT (((UINTN) Destination & BIT0) == 0);\r
-  ASSERT (((UINTN) Source & BIT0) == 0);\r
+  ASSERT (((UINTN)Destination & BIT0) == 0);\r
+  ASSERT (((UINTN)Source & BIT0) == 0);\r
 \r
   //\r
   // 1. Neither Destination nor Source shall be a null pointer.\r
@@ -347,6 +352,7 @@ StrnCpyS (
   if (SourceLen > Length) {\r
     SourceLen = Length;\r
   }\r
+\r
   SAFE_STRING_CONSTRAINT_CHECK (InternalSafeStringNoStrOverlap (Destination, DestMax, (CHAR16 *)Source, SourceLen + 1), RETURN_ACCESS_DENIED);\r
 \r
   //\r
@@ -359,6 +365,7 @@ StrnCpyS (
     *(Destination++) = *(Source++);\r
     SourceLen--;\r
   }\r
+\r
   *Destination = 0;\r
 \r
   return RETURN_SUCCESS;\r
@@ -396,17 +403,17 @@ StrnCpyS (
 RETURN_STATUS\r
 EFIAPI\r
 StrCatS (\r
-  IN OUT CHAR16       *Destination,\r
-  IN     UINTN        DestMax,\r
-  IN     CONST CHAR16 *Source\r
+  IN OUT CHAR16        *Destination,\r
+  IN     UINTN         DestMax,\r
+  IN     CONST CHAR16  *Source\r
   )\r
 {\r
-  UINTN               DestLen;\r
-  UINTN               CopyLen;\r
-  UINTN               SourceLen;\r
+  UINTN  DestLen;\r
+  UINTN  CopyLen;\r
+  UINTN  SourceLen;\r
 \r
-  ASSERT (((UINTN) Destination & BIT0) == 0);\r
-  ASSERT (((UINTN) Source & BIT0) == 0);\r
+  ASSERT (((UINTN)Destination & BIT0) == 0);\r
+  ASSERT (((UINTN)Source & BIT0) == 0);\r
 \r
   //\r
   // Let CopyLen denote the value DestMax - StrnLenS(Destination, DestMax) upon entry to StrCatS.\r
@@ -457,6 +464,7 @@ StrCatS (
   while (*Source != 0) {\r
     *(Destination++) = *(Source++);\r
   }\r
+\r
   *Destination = 0;\r
 \r
   return RETURN_SUCCESS;\r
@@ -497,18 +505,18 @@ StrCatS (
 RETURN_STATUS\r
 EFIAPI\r
 StrnCatS (\r
-  IN OUT CHAR16       *Destination,\r
-  IN     UINTN        DestMax,\r
-  IN     CONST CHAR16 *Source,\r
-  IN     UINTN        Length\r
+  IN OUT CHAR16        *Destination,\r
+  IN     UINTN         DestMax,\r
+  IN     CONST CHAR16  *Source,\r
+  IN     UINTN         Length\r
   )\r
 {\r
-  UINTN               DestLen;\r
-  UINTN               CopyLen;\r
-  UINTN               SourceLen;\r
+  UINTN  DestLen;\r
+  UINTN  CopyLen;\r
+  UINTN  SourceLen;\r
 \r
-  ASSERT (((UINTN) Destination & BIT0) == 0);\r
-  ASSERT (((UINTN) Source & BIT0) == 0);\r
+  ASSERT (((UINTN)Destination & BIT0) == 0);\r
+  ASSERT (((UINTN)Source & BIT0) == 0);\r
 \r
   //\r
   // Let CopyLen denote the value DestMax - StrnLenS(Destination, DestMax) upon entry to StrnCatS.\r
@@ -554,6 +562,7 @@ StrnCatS (
   if (SourceLen > Length) {\r
     SourceLen = Length;\r
   }\r
+\r
   SAFE_STRING_CONSTRAINT_CHECK (InternalSafeStringNoStrOverlap (Destination, DestMax, (CHAR16 *)Source, SourceLen + 1), RETURN_ACCESS_DENIED);\r
 \r
   //\r
@@ -568,6 +577,7 @@ StrnCatS (
     *(Destination++) = *(Source++);\r
     SourceLen--;\r
   }\r
+\r
   *Destination = 0;\r
 \r
   return RETURN_SUCCESS;\r
@@ -619,12 +629,12 @@ StrnCatS (
 RETURN_STATUS\r
 EFIAPI\r
 StrDecimalToUintnS (\r
-  IN  CONST CHAR16             *String,\r
-  OUT       CHAR16             **EndPointer   OPTIONAL,\r
-  OUT       UINTN              *Data\r
+  IN  CONST CHAR16  *String,\r
+  OUT       CHAR16  **EndPointer   OPTIONAL,\r
+  OUT       UINTN   *Data\r
   )\r
 {\r
-  ASSERT (((UINTN) String & BIT0) == 0);\r
+  ASSERT (((UINTN)String & BIT0) == 0);\r
 \r
   //\r
   // 1. Neither String nor Data shall be a null pointer.\r
@@ -640,7 +650,7 @@ StrDecimalToUintnS (
   }\r
 \r
   if (EndPointer != NULL) {\r
-    *EndPointer = (CHAR16 *) String;\r
+    *EndPointer = (CHAR16 *)String;\r
   }\r
 \r
   //\r
@@ -668,8 +678,9 @@ StrDecimalToUintnS (
     if (*Data > ((MAX_UINTN - (*String - L'0')) / 10)) {\r
       *Data = MAX_UINTN;\r
       if (EndPointer != NULL) {\r
-        *EndPointer = (CHAR16 *) String;\r
+        *EndPointer = (CHAR16 *)String;\r
       }\r
+\r
       return RETURN_UNSUPPORTED;\r
     }\r
 \r
@@ -678,8 +689,9 @@ StrDecimalToUintnS (
   }\r
 \r
   if (EndPointer != NULL) {\r
-    *EndPointer = (CHAR16 *) String;\r
+    *EndPointer = (CHAR16 *)String;\r
   }\r
+\r
   return RETURN_SUCCESS;\r
 }\r
 \r
@@ -729,12 +741,12 @@ StrDecimalToUintnS (
 RETURN_STATUS\r
 EFIAPI\r
 StrDecimalToUint64S (\r
-  IN  CONST CHAR16             *String,\r
-  OUT       CHAR16             **EndPointer   OPTIONAL,\r
-  OUT       UINT64             *Data\r
+  IN  CONST CHAR16  *String,\r
+  OUT       CHAR16  **EndPointer   OPTIONAL,\r
+  OUT       UINT64  *Data\r
   )\r
 {\r
-  ASSERT (((UINTN) String & BIT0) == 0);\r
+  ASSERT (((UINTN)String & BIT0) == 0);\r
 \r
   //\r
   // 1. Neither String nor Data shall be a null pointer.\r
@@ -750,7 +762,7 @@ StrDecimalToUint64S (
   }\r
 \r
   if (EndPointer != NULL) {\r
-    *EndPointer = (CHAR16 *) String;\r
+    *EndPointer = (CHAR16 *)String;\r
   }\r
 \r
   //\r
@@ -778,8 +790,9 @@ StrDecimalToUint64S (
     if (*Data > DivU64x32 (MAX_UINT64 - (*String - L'0'), 10)) {\r
       *Data = MAX_UINT64;\r
       if (EndPointer != NULL) {\r
-        *EndPointer = (CHAR16 *) String;\r
+        *EndPointer = (CHAR16 *)String;\r
       }\r
+\r
       return RETURN_UNSUPPORTED;\r
     }\r
 \r
@@ -788,8 +801,9 @@ StrDecimalToUint64S (
   }\r
 \r
   if (EndPointer != NULL) {\r
-    *EndPointer = (CHAR16 *) String;\r
+    *EndPointer = (CHAR16 *)String;\r
   }\r
+\r
   return RETURN_SUCCESS;\r
 }\r
 \r
@@ -844,12 +858,12 @@ StrDecimalToUint64S (
 RETURN_STATUS\r
 EFIAPI\r
 StrHexToUintnS (\r
-  IN  CONST CHAR16             *String,\r
-  OUT       CHAR16             **EndPointer   OPTIONAL,\r
-  OUT       UINTN              *Data\r
+  IN  CONST CHAR16  *String,\r
+  OUT       CHAR16  **EndPointer   OPTIONAL,\r
+  OUT       UINTN   *Data\r
   )\r
 {\r
-  ASSERT (((UINTN) String & BIT0) == 0);\r
+  ASSERT (((UINTN)String & BIT0) == 0);\r
 \r
   //\r
   // 1. Neither String nor Data shall be a null pointer.\r
@@ -865,7 +879,7 @@ StrHexToUintnS (
   }\r
 \r
   if (EndPointer != NULL) {\r
-    *EndPointer = (CHAR16 *) String;\r
+    *EndPointer = (CHAR16 *)String;\r
   }\r
 \r
   //\r
@@ -887,6 +901,7 @@ StrHexToUintnS (
       *Data = 0;\r
       return RETURN_SUCCESS;\r
     }\r
+\r
     //\r
     // Skip the 'X'\r
     //\r
@@ -904,8 +919,9 @@ StrHexToUintnS (
     if (*Data > ((MAX_UINTN - InternalHexCharToUintn (*String)) >> 4)) {\r
       *Data = MAX_UINTN;\r
       if (EndPointer != NULL) {\r
-        *EndPointer = (CHAR16 *) String;\r
+        *EndPointer = (CHAR16 *)String;\r
       }\r
+\r
       return RETURN_UNSUPPORTED;\r
     }\r
 \r
@@ -914,8 +930,9 @@ StrHexToUintnS (
   }\r
 \r
   if (EndPointer != NULL) {\r
-    *EndPointer = (CHAR16 *) String;\r
+    *EndPointer = (CHAR16 *)String;\r
   }\r
+\r
   return RETURN_SUCCESS;\r
 }\r
 \r
@@ -970,12 +987,12 @@ StrHexToUintnS (
 RETURN_STATUS\r
 EFIAPI\r
 StrHexToUint64S (\r
-  IN  CONST CHAR16             *String,\r
-  OUT       CHAR16             **EndPointer   OPTIONAL,\r
-  OUT       UINT64             *Data\r
+  IN  CONST CHAR16  *String,\r
+  OUT       CHAR16  **EndPointer   OPTIONAL,\r
+  OUT       UINT64  *Data\r
   )\r
 {\r
-  ASSERT (((UINTN) String & BIT0) == 0);\r
+  ASSERT (((UINTN)String & BIT0) == 0);\r
 \r
   //\r
   // 1. Neither String nor Data shall be a null pointer.\r
@@ -991,7 +1008,7 @@ StrHexToUint64S (
   }\r
 \r
   if (EndPointer != NULL) {\r
-    *EndPointer = (CHAR16 *) String;\r
+    *EndPointer = (CHAR16 *)String;\r
   }\r
 \r
   //\r
@@ -1013,6 +1030,7 @@ StrHexToUint64S (
       *Data = 0;\r
       return RETURN_SUCCESS;\r
     }\r
+\r
     //\r
     // Skip the 'X'\r
     //\r
@@ -1030,8 +1048,9 @@ StrHexToUint64S (
     if (*Data > RShiftU64 (MAX_UINT64 - InternalHexCharToUintn (*String), 4)) {\r
       *Data = MAX_UINT64;\r
       if (EndPointer != NULL) {\r
-        *EndPointer = (CHAR16 *) String;\r
+        *EndPointer = (CHAR16 *)String;\r
       }\r
+\r
       return RETURN_UNSUPPORTED;\r
     }\r
 \r
@@ -1040,8 +1059,9 @@ StrHexToUint64S (
   }\r
 \r
   if (EndPointer != NULL) {\r
-    *EndPointer = (CHAR16 *) String;\r
+    *EndPointer = (CHAR16 *)String;\r
   }\r
+\r
   return RETURN_SUCCESS;\r
 }\r
 \r
@@ -1098,27 +1118,27 @@ StrHexToUint64S (
 RETURN_STATUS\r
 EFIAPI\r
 StrToIpv6Address (\r
-  IN  CONST CHAR16       *String,\r
-  OUT CHAR16             **EndPointer  OPTIONAL,\r
-  OUT IPv6_ADDRESS       *Address,\r
-  OUT UINT8              *PrefixLength OPTIONAL\r
+  IN  CONST CHAR16  *String,\r
+  OUT CHAR16        **EndPointer  OPTIONAL,\r
+  OUT IPv6_ADDRESS  *Address,\r
+  OUT UINT8         *PrefixLength OPTIONAL\r
   )\r
 {\r
-  RETURN_STATUS          Status;\r
-  UINTN                  AddressIndex;\r
-  UINTN                  Uintn;\r
-  IPv6_ADDRESS           LocalAddress;\r
-  UINT8                  LocalPrefixLength;\r
-  CONST CHAR16           *Pointer;\r
-  CHAR16                 *End;\r
-  UINTN                  CompressStart;\r
-  BOOLEAN                ExpectPrefix;\r
+  RETURN_STATUS  Status;\r
+  UINTN          AddressIndex;\r
+  UINTN          Uintn;\r
+  IPv6_ADDRESS   LocalAddress;\r
+  UINT8          LocalPrefixLength;\r
+  CONST CHAR16   *Pointer;\r
+  CHAR16         *End;\r
+  UINTN          CompressStart;\r
+  BOOLEAN        ExpectPrefix;\r
 \r
   LocalPrefixLength = MAX_UINT8;\r
   CompressStart     = ARRAY_SIZE (Address->Addr);\r
   ExpectPrefix      = FALSE;\r
 \r
-  ASSERT (((UINTN) String & BIT0) == 0);\r
+  ASSERT (((UINTN)String & BIT0) == 0);\r
 \r
   //\r
   // 1. None of String or Guid shall be a null pointer.\r
@@ -1146,7 +1166,7 @@ StrToIpv6Address (
         return RETURN_UNSUPPORTED;\r
       }\r
 \r
-      if (CompressStart != ARRAY_SIZE (Address->Addr) || AddressIndex == ARRAY_SIZE (Address->Addr)) {\r
+      if ((CompressStart != ARRAY_SIZE (Address->Addr)) || (AddressIndex == ARRAY_SIZE (Address->Addr))) {\r
         //\r
         // "::" can only appear once.\r
         // "::" can only appear when address is not full length.\r
@@ -1166,6 +1186,7 @@ StrToIpv6Address (
             //\r
             return RETURN_UNSUPPORTED;\r
           }\r
+\r
           Pointer++;\r
         }\r
       }\r
@@ -1188,33 +1209,35 @@ StrToIpv6Address (
         // Get X.\r
         //\r
         Status = StrHexToUintnS (Pointer, &End, &Uintn);\r
-        if (RETURN_ERROR (Status) || End - Pointer > 4) {\r
+        if (RETURN_ERROR (Status) || (End - Pointer > 4)) {\r
           //\r
           // Number of hexadecimal digit characters is no more than 4.\r
           //\r
           return RETURN_UNSUPPORTED;\r
         }\r
+\r
         Pointer = End;\r
         //\r
         // Uintn won't exceed MAX_UINT16 if number of hexadecimal digit characters is no more than 4.\r
         //\r
         ASSERT (AddressIndex + 1 < ARRAY_SIZE (Address->Addr));\r
-        LocalAddress.Addr[AddressIndex] = (UINT8) ((UINT16) Uintn >> 8);\r
-        LocalAddress.Addr[AddressIndex + 1] = (UINT8) Uintn;\r
-        AddressIndex += 2;\r
+        LocalAddress.Addr[AddressIndex]     = (UINT8)((UINT16)Uintn >> 8);\r
+        LocalAddress.Addr[AddressIndex + 1] = (UINT8)Uintn;\r
+        AddressIndex                       += 2;\r
       } else {\r
         //\r
         // Get P, then exit the loop.\r
         //\r
         Status = StrDecimalToUintnS (Pointer, &End, &Uintn);\r
-        if (RETURN_ERROR (Status) || End == Pointer || Uintn > 128) {\r
+        if (RETURN_ERROR (Status) || (End == Pointer) || (Uintn > 128)) {\r
           //\r
           // Prefix length should not exceed 128.\r
           //\r
           return RETURN_UNSUPPORTED;\r
         }\r
-        LocalPrefixLength = (UINT8) Uintn;\r
-        Pointer = End;\r
+\r
+        LocalPrefixLength = (UINT8)Uintn;\r
+        Pointer           = End;\r
         break;\r
       }\r
     }\r
@@ -1237,18 +1260,21 @@ StrToIpv6Address (
       //\r
       break;\r
     }\r
+\r
     Pointer++;\r
   }\r
 \r
-  if ((AddressIndex == ARRAY_SIZE (Address->Addr) && CompressStart != ARRAY_SIZE (Address->Addr)) ||\r
-    (AddressIndex != ARRAY_SIZE (Address->Addr) && CompressStart == ARRAY_SIZE (Address->Addr))\r
-      ) {\r
+  if (((AddressIndex == ARRAY_SIZE (Address->Addr)) && (CompressStart != ARRAY_SIZE (Address->Addr))) ||\r
+      ((AddressIndex != ARRAY_SIZE (Address->Addr)) && (CompressStart == ARRAY_SIZE (Address->Addr)))\r
+      )\r
+  {\r
     //\r
     // Full length of address shall not have compressing zeros.\r
     // Non-full length of address shall have compressing zeros.\r
     //\r
     return RETURN_UNSUPPORTED;\r
   }\r
+\r
   CopyMem (&Address->Addr[0], &LocalAddress.Addr[0], CompressStart);\r
   ZeroMem (&Address->Addr[CompressStart], ARRAY_SIZE (Address->Addr) - AddressIndex);\r
   if (AddressIndex > CompressStart) {\r
@@ -1262,8 +1288,9 @@ StrToIpv6Address (
   if (PrefixLength != NULL) {\r
     *PrefixLength = LocalPrefixLength;\r
   }\r
+\r
   if (EndPointer != NULL) {\r
-    *EndPointer = (CHAR16 *) Pointer;\r
+    *EndPointer = (CHAR16 *)Pointer;\r
   }\r
 \r
   return RETURN_SUCCESS;\r
@@ -1313,22 +1340,22 @@ StrToIpv6Address (
 RETURN_STATUS\r
 EFIAPI\r
 StrToIpv4Address (\r
-  IN  CONST CHAR16       *String,\r
-  OUT CHAR16             **EndPointer  OPTIONAL,\r
-  OUT IPv4_ADDRESS       *Address,\r
-  OUT UINT8              *PrefixLength OPTIONAL\r
+  IN  CONST CHAR16  *String,\r
+  OUT CHAR16        **EndPointer  OPTIONAL,\r
+  OUT IPv4_ADDRESS  *Address,\r
+  OUT UINT8         *PrefixLength OPTIONAL\r
   )\r
 {\r
-  RETURN_STATUS          Status;\r
-  UINTN                  AddressIndex;\r
-  UINTN                  Uintn;\r
-  IPv4_ADDRESS           LocalAddress;\r
-  UINT8                  LocalPrefixLength;\r
-  CHAR16                 *Pointer;\r
+  RETURN_STATUS  Status;\r
+  UINTN          AddressIndex;\r
+  UINTN          Uintn;\r
+  IPv4_ADDRESS   LocalAddress;\r
+  UINT8          LocalPrefixLength;\r
+  CHAR16         *Pointer;\r
 \r
   LocalPrefixLength = MAX_UINT8;\r
 \r
-  ASSERT (((UINTN) String & BIT0) == 0);\r
+  ASSERT (((UINTN)String & BIT0) == 0);\r
 \r
   //\r
   // 1. None of String or Guid shall be a null pointer.\r
@@ -1336,7 +1363,7 @@ StrToIpv4Address (
   SAFE_STRING_CONSTRAINT_CHECK ((String != NULL), RETURN_INVALID_PARAMETER);\r
   SAFE_STRING_CONSTRAINT_CHECK ((Address != NULL), RETURN_INVALID_PARAMETER);\r
 \r
-  for (Pointer = (CHAR16 *) String, AddressIndex = 0; AddressIndex < ARRAY_SIZE (Address->Addr) + 1;) {\r
+  for (Pointer = (CHAR16 *)String, AddressIndex = 0; AddressIndex < ARRAY_SIZE (Address->Addr) + 1;) {\r
     if (!InternalIsDecimalDigitCharacter (*Pointer)) {\r
       //\r
       // D or P contains invalid characters.\r
@@ -1347,10 +1374,11 @@ StrToIpv4Address (
     //\r
     // Get D or P.\r
     //\r
-    Status = StrDecimalToUintnS ((CONST CHAR16 *) Pointer, &Pointer, &Uintn);\r
+    Status = StrDecimalToUintnS ((CONST CHAR16 *)Pointer, &Pointer, &Uintn);\r
     if (RETURN_ERROR (Status)) {\r
       return RETURN_UNSUPPORTED;\r
     }\r
+\r
     if (AddressIndex == ARRAY_SIZE (Address->Addr)) {\r
       //\r
       // It's P.\r
@@ -1358,7 +1386,8 @@ StrToIpv4Address (
       if (Uintn > 32) {\r
         return RETURN_UNSUPPORTED;\r
       }\r
-      LocalPrefixLength = (UINT8) Uintn;\r
+\r
+      LocalPrefixLength = (UINT8)Uintn;\r
     } else {\r
       //\r
       // It's D.\r
@@ -1366,7 +1395,8 @@ StrToIpv4Address (
       if (Uintn > MAX_UINT8) {\r
         return RETURN_UNSUPPORTED;\r
       }\r
-      LocalAddress.Addr[AddressIndex] = (UINT8) Uintn;\r
+\r
+      LocalAddress.Addr[AddressIndex] = (UINT8)Uintn;\r
       AddressIndex++;\r
     }\r
 \r
@@ -1406,6 +1436,7 @@ StrToIpv4Address (
   if (PrefixLength != NULL) {\r
     *PrefixLength = LocalPrefixLength;\r
   }\r
+\r
   if (EndPointer != NULL) {\r
     *EndPointer = Pointer;\r
   }\r
@@ -1458,14 +1489,14 @@ StrToIpv4Address (
 RETURN_STATUS\r
 EFIAPI\r
 StrToGuid (\r
-  IN  CONST CHAR16       *String,\r
-  OUT GUID               *Guid\r
+  IN  CONST CHAR16  *String,\r
+  OUT GUID          *Guid\r
   )\r
 {\r
-  RETURN_STATUS          Status;\r
-  GUID                   LocalGuid;\r
+  RETURN_STATUS  Status;\r
+  GUID           LocalGuid;\r
 \r
-  ASSERT (((UINTN) String & BIT0) == 0);\r
+  ASSERT (((UINTN)String & BIT0) == 0);\r
 \r
   //\r
   // 1. None of String or Guid shall be a null pointer.\r
@@ -1476,49 +1507,53 @@ StrToGuid (
   //\r
   // Get aabbccdd in big-endian.\r
   //\r
-  Status = StrHexToBytes (String, 2 * sizeof (LocalGuid.Data1), (UINT8 *) &LocalGuid.Data1, sizeof (LocalGuid.Data1));\r
-  if (RETURN_ERROR (Status) || String[2 * sizeof (LocalGuid.Data1)] != L'-') {\r
+  Status = StrHexToBytes (String, 2 * sizeof (LocalGuid.Data1), (UINT8 *)&LocalGuid.Data1, sizeof (LocalGuid.Data1));\r
+  if (RETURN_ERROR (Status) || (String[2 * sizeof (LocalGuid.Data1)] != L'-')) {\r
     return RETURN_UNSUPPORTED;\r
   }\r
+\r
   //\r
   // Convert big-endian to little-endian.\r
   //\r
   LocalGuid.Data1 = SwapBytes32 (LocalGuid.Data1);\r
-  String += 2 * sizeof (LocalGuid.Data1) + 1;\r
+  String         += 2 * sizeof (LocalGuid.Data1) + 1;\r
 \r
   //\r
   // Get eeff in big-endian.\r
   //\r
-  Status = StrHexToBytes (String, 2 * sizeof (LocalGuid.Data2), (UINT8 *) &LocalGuid.Data2, sizeof (LocalGuid.Data2));\r
-  if (RETURN_ERROR (Status) || String[2 * sizeof (LocalGuid.Data2)] != L'-') {\r
+  Status = StrHexToBytes (String, 2 * sizeof (LocalGuid.Data2), (UINT8 *)&LocalGuid.Data2, sizeof (LocalGuid.Data2));\r
+  if (RETURN_ERROR (Status) || (String[2 * sizeof (LocalGuid.Data2)] != L'-')) {\r
     return RETURN_UNSUPPORTED;\r
   }\r
+\r
   //\r
   // Convert big-endian to little-endian.\r
   //\r
   LocalGuid.Data2 = SwapBytes16 (LocalGuid.Data2);\r
-  String += 2 * sizeof (LocalGuid.Data2) + 1;\r
+  String         += 2 * sizeof (LocalGuid.Data2) + 1;\r
 \r
   //\r
   // Get gghh in big-endian.\r
   //\r
-  Status = StrHexToBytes (String, 2 * sizeof (LocalGuid.Data3), (UINT8 *) &LocalGuid.Data3, sizeof (LocalGuid.Data3));\r
-  if (RETURN_ERROR (Status) || String[2 * sizeof (LocalGuid.Data3)] != L'-') {\r
+  Status = StrHexToBytes (String, 2 * sizeof (LocalGuid.Data3), (UINT8 *)&LocalGuid.Data3, sizeof (LocalGuid.Data3));\r
+  if (RETURN_ERROR (Status) || (String[2 * sizeof (LocalGuid.Data3)] != L'-')) {\r
     return RETURN_UNSUPPORTED;\r
   }\r
+\r
   //\r
   // Convert big-endian to little-endian.\r
   //\r
   LocalGuid.Data3 = SwapBytes16 (LocalGuid.Data3);\r
-  String += 2 * sizeof (LocalGuid.Data3) + 1;\r
+  String         += 2 * sizeof (LocalGuid.Data3) + 1;\r
 \r
   //\r
   // Get iijj.\r
   //\r
   Status = StrHexToBytes (String, 2 * 2, &LocalGuid.Data4[0], 2);\r
-  if (RETURN_ERROR (Status) || String[2 * 2] != L'-') {\r
+  if (RETURN_ERROR (Status) || (String[2 * 2] != L'-')) {\r
     return RETURN_UNSUPPORTED;\r
   }\r
+\r
   String += 2 * 2 + 1;\r
 \r
   //\r
@@ -1569,15 +1604,15 @@ StrToGuid (
 RETURN_STATUS\r
 EFIAPI\r
 StrHexToBytes (\r
-  IN  CONST CHAR16       *String,\r
-  IN  UINTN              Length,\r
-  OUT UINT8              *Buffer,\r
-  IN  UINTN              MaxBufferSize\r
+  IN  CONST CHAR16  *String,\r
+  IN  UINTN         Length,\r
+  OUT UINT8         *Buffer,\r
+  IN  UINTN         MaxBufferSize\r
   )\r
 {\r
-  UINTN                  Index;\r
+  UINTN  Index;\r
 \r
-  ASSERT (((UINTN) String & BIT0) == 0);\r
+  ASSERT (((UINTN)String & BIT0) == 0);\r
 \r
   //\r
   // 1. None of String or Buffer shall be a null pointer.\r
@@ -1610,6 +1645,7 @@ StrHexToBytes (
       break;\r
     }\r
   }\r
+\r
   if (Index != Length) {\r
     return RETURN_UNSUPPORTED;\r
   }\r
@@ -1617,18 +1653,18 @@ StrHexToBytes (
   //\r
   // Convert the hex string to bytes.\r
   //\r
-  for(Index = 0; Index < Length; Index++) {\r
-\r
+  for (Index = 0; Index < Length; Index++) {\r
     //\r
     // For even characters, write the upper nibble for each buffer byte,\r
     // and for even characters, the lower nibble.\r
     //\r
     if ((Index & BIT0) == 0) {\r
-      Buffer[Index / 2]  = (UINT8) InternalHexCharToUintn (String[Index]) << 4;\r
+      Buffer[Index / 2] = (UINT8)InternalHexCharToUintn (String[Index]) << 4;\r
     } else {\r
-      Buffer[Index / 2] |= (UINT8) InternalHexCharToUintn (String[Index]);\r
+      Buffer[Index / 2] |= (UINT8)InternalHexCharToUintn (String[Index]);\r
     }\r
   }\r
+\r
   return RETURN_SUCCESS;\r
 }\r
 \r
@@ -1649,11 +1685,11 @@ StrHexToBytes (
 UINTN\r
 EFIAPI\r
 AsciiStrnLenS (\r
-  IN CONST CHAR8               *String,\r
-  IN UINTN                     MaxSize\r
+  IN CONST CHAR8  *String,\r
+  IN UINTN        MaxSize\r
   )\r
 {\r
-  UINTN                             Length;\r
+  UINTN  Length;\r
 \r
   //\r
   // If String is a null pointer or MaxSize is 0, then the AsciiStrnLenS function returns zero.\r
@@ -1673,8 +1709,10 @@ AsciiStrnLenS (
     if (Length >= MaxSize - 1) {\r
       return MaxSize;\r
     }\r
+\r
     Length++;\r
   }\r
+\r
   return Length;\r
 }\r
 \r
@@ -1700,8 +1738,8 @@ AsciiStrnLenS (
 UINTN\r
 EFIAPI\r
 AsciiStrnSizeS (\r
-  IN CONST CHAR8               *String,\r
-  IN UINTN                     MaxSize\r
+  IN CONST CHAR8  *String,\r
+  IN UINTN        MaxSize\r
   )\r
 {\r
   //\r
@@ -1753,7 +1791,7 @@ AsciiStrCpyS (
   IN  CONST CHAR8  *Source\r
   )\r
 {\r
-  UINTN            SourceLen;\r
+  UINTN  SourceLen;\r
 \r
   //\r
   // 1. Neither Destination nor Source shall be a null pointer.\r
@@ -1791,6 +1829,7 @@ AsciiStrCpyS (
   while (*Source != 0) {\r
     *(Destination++) = *(Source++);\r
   }\r
+\r
   *Destination = 0;\r
 \r
   return RETURN_SUCCESS;\r
@@ -1831,7 +1870,7 @@ AsciiStrnCpyS (
   IN  UINTN        Length\r
   )\r
 {\r
-  UINTN            SourceLen;\r
+  UINTN  SourceLen;\r
 \r
   //\r
   // 1. Neither Destination nor Source shall be a null pointer.\r
@@ -1866,6 +1905,7 @@ AsciiStrnCpyS (
   if (SourceLen > Length) {\r
     SourceLen = Length;\r
   }\r
+\r
   SAFE_STRING_CONSTRAINT_CHECK (InternalSafeStringNoAsciiStrOverlap (Destination, DestMax, (CHAR8 *)Source, SourceLen + 1), RETURN_ACCESS_DENIED);\r
 \r
   //\r
@@ -1878,6 +1918,7 @@ AsciiStrnCpyS (
     *(Destination++) = *(Source++);\r
     SourceLen--;\r
   }\r
+\r
   *Destination = 0;\r
 \r
   return RETURN_SUCCESS;\r
@@ -1917,9 +1958,9 @@ AsciiStrCatS (
   IN     CONST CHAR8  *Source\r
   )\r
 {\r
-  UINTN               DestLen;\r
-  UINTN               CopyLen;\r
-  UINTN               SourceLen;\r
+  UINTN  DestLen;\r
+  UINTN  CopyLen;\r
+  UINTN  SourceLen;\r
 \r
   //\r
   // Let CopyLen denote the value DestMax - AsciiStrnLenS(Destination, DestMax) upon entry to AsciiStrCatS.\r
@@ -1970,6 +2011,7 @@ AsciiStrCatS (
   while (*Source != 0) {\r
     *(Destination++) = *(Source++);\r
   }\r
+\r
   *Destination = 0;\r
 \r
   return RETURN_SUCCESS;\r
@@ -2013,9 +2055,9 @@ AsciiStrnCatS (
   IN     UINTN        Length\r
   )\r
 {\r
-  UINTN               DestLen;\r
-  UINTN               CopyLen;\r
-  UINTN               SourceLen;\r
+  UINTN  DestLen;\r
+  UINTN  CopyLen;\r
+  UINTN  SourceLen;\r
 \r
   //\r
   // Let CopyLen denote the value DestMax - AsciiStrnLenS(Destination, DestMax) upon entry to AsciiStrnCatS.\r
@@ -2061,6 +2103,7 @@ AsciiStrnCatS (
   if (SourceLen > Length) {\r
     SourceLen = Length;\r
   }\r
+\r
   SAFE_STRING_CONSTRAINT_CHECK (InternalSafeStringNoAsciiStrOverlap (Destination, DestMax, (CHAR8 *)Source, SourceLen + 1), RETURN_ACCESS_DENIED);\r
 \r
   //\r
@@ -2075,6 +2118,7 @@ AsciiStrnCatS (
     *(Destination++) = *(Source++);\r
     SourceLen--;\r
   }\r
+\r
   *Destination = 0;\r
 \r
   return RETURN_SUCCESS;\r
@@ -2124,9 +2168,9 @@ AsciiStrnCatS (
 RETURN_STATUS\r
 EFIAPI\r
 AsciiStrDecimalToUintnS (\r
-  IN  CONST CHAR8              *String,\r
-  OUT       CHAR8              **EndPointer   OPTIONAL,\r
-  OUT       UINTN              *Data\r
+  IN  CONST CHAR8  *String,\r
+  OUT       CHAR8  **EndPointer   OPTIONAL,\r
+  OUT       UINTN  *Data\r
   )\r
 {\r
   //\r
@@ -2143,7 +2187,7 @@ AsciiStrDecimalToUintnS (
   }\r
 \r
   if (EndPointer != NULL) {\r
-    *EndPointer = (CHAR8 *) String;\r
+    *EndPointer = (CHAR8 *)String;\r
   }\r
 \r
   //\r
@@ -2171,8 +2215,9 @@ AsciiStrDecimalToUintnS (
     if (*Data > ((MAX_UINTN - (*String - '0')) / 10)) {\r
       *Data = MAX_UINTN;\r
       if (EndPointer != NULL) {\r
-        *EndPointer = (CHAR8 *) String;\r
+        *EndPointer = (CHAR8 *)String;\r
       }\r
+\r
       return RETURN_UNSUPPORTED;\r
     }\r
 \r
@@ -2181,8 +2226,9 @@ AsciiStrDecimalToUintnS (
   }\r
 \r
   if (EndPointer != NULL) {\r
-    *EndPointer = (CHAR8 *) String;\r
+    *EndPointer = (CHAR8 *)String;\r
   }\r
+\r
   return RETURN_SUCCESS;\r
 }\r
 \r
@@ -2230,9 +2276,9 @@ AsciiStrDecimalToUintnS (
 RETURN_STATUS\r
 EFIAPI\r
 AsciiStrDecimalToUint64S (\r
-  IN  CONST CHAR8              *String,\r
-  OUT       CHAR8              **EndPointer   OPTIONAL,\r
-  OUT       UINT64             *Data\r
+  IN  CONST CHAR8   *String,\r
+  OUT       CHAR8   **EndPointer   OPTIONAL,\r
+  OUT       UINT64  *Data\r
   )\r
 {\r
   //\r
@@ -2249,7 +2295,7 @@ AsciiStrDecimalToUint64S (
   }\r
 \r
   if (EndPointer != NULL) {\r
-    *EndPointer = (CHAR8 *) String;\r
+    *EndPointer = (CHAR8 *)String;\r
   }\r
 \r
   //\r
@@ -2277,8 +2323,9 @@ AsciiStrDecimalToUint64S (
     if (*Data > DivU64x32 (MAX_UINT64 - (*String - '0'), 10)) {\r
       *Data = MAX_UINT64;\r
       if (EndPointer != NULL) {\r
-        *EndPointer = (CHAR8 *) String;\r
+        *EndPointer = (CHAR8 *)String;\r
       }\r
+\r
       return RETURN_UNSUPPORTED;\r
     }\r
 \r
@@ -2287,8 +2334,9 @@ AsciiStrDecimalToUint64S (
   }\r
 \r
   if (EndPointer != NULL) {\r
-    *EndPointer = (CHAR8 *) String;\r
+    *EndPointer = (CHAR8 *)String;\r
   }\r
+\r
   return RETURN_SUCCESS;\r
 }\r
 \r
@@ -2340,9 +2388,9 @@ AsciiStrDecimalToUint64S (
 RETURN_STATUS\r
 EFIAPI\r
 AsciiStrHexToUintnS (\r
-  IN  CONST CHAR8              *String,\r
-  OUT       CHAR8              **EndPointer   OPTIONAL,\r
-  OUT       UINTN              *Data\r
+  IN  CONST CHAR8  *String,\r
+  OUT       CHAR8  **EndPointer   OPTIONAL,\r
+  OUT       UINTN  *Data\r
   )\r
 {\r
   //\r
@@ -2359,7 +2407,7 @@ AsciiStrHexToUintnS (
   }\r
 \r
   if (EndPointer != NULL) {\r
-    *EndPointer = (CHAR8 *) String;\r
+    *EndPointer = (CHAR8 *)String;\r
   }\r
 \r
   //\r
@@ -2381,6 +2429,7 @@ AsciiStrHexToUintnS (
       *Data = 0;\r
       return RETURN_SUCCESS;\r
     }\r
+\r
     //\r
     // Skip the 'X'\r
     //\r
@@ -2398,8 +2447,9 @@ AsciiStrHexToUintnS (
     if (*Data > ((MAX_UINTN - InternalAsciiHexCharToUintn (*String)) >> 4)) {\r
       *Data = MAX_UINTN;\r
       if (EndPointer != NULL) {\r
-        *EndPointer = (CHAR8 *) String;\r
+        *EndPointer = (CHAR8 *)String;\r
       }\r
+\r
       return RETURN_UNSUPPORTED;\r
     }\r
 \r
@@ -2408,8 +2458,9 @@ AsciiStrHexToUintnS (
   }\r
 \r
   if (EndPointer != NULL) {\r
-    *EndPointer = (CHAR8 *) String;\r
+    *EndPointer = (CHAR8 *)String;\r
   }\r
+\r
   return RETURN_SUCCESS;\r
 }\r
 \r
@@ -2461,9 +2512,9 @@ AsciiStrHexToUintnS (
 RETURN_STATUS\r
 EFIAPI\r
 AsciiStrHexToUint64S (\r
-  IN  CONST CHAR8              *String,\r
-  OUT       CHAR8              **EndPointer   OPTIONAL,\r
-  OUT       UINT64             *Data\r
+  IN  CONST CHAR8   *String,\r
+  OUT       CHAR8   **EndPointer   OPTIONAL,\r
+  OUT       UINT64  *Data\r
   )\r
 {\r
   //\r
@@ -2480,7 +2531,7 @@ AsciiStrHexToUint64S (
   }\r
 \r
   if (EndPointer != NULL) {\r
-    *EndPointer = (CHAR8 *) String;\r
+    *EndPointer = (CHAR8 *)String;\r
   }\r
 \r
   //\r
@@ -2502,6 +2553,7 @@ AsciiStrHexToUint64S (
       *Data = 0;\r
       return RETURN_SUCCESS;\r
     }\r
+\r
     //\r
     // Skip the 'X'\r
     //\r
@@ -2519,8 +2571,9 @@ AsciiStrHexToUint64S (
     if (*Data > RShiftU64 (MAX_UINT64 - InternalAsciiHexCharToUintn (*String), 4)) {\r
       *Data = MAX_UINT64;\r
       if (EndPointer != NULL) {\r
-        *EndPointer = (CHAR8 *) String;\r
+        *EndPointer = (CHAR8 *)String;\r
       }\r
+\r
       return RETURN_UNSUPPORTED;\r
     }\r
 \r
@@ -2529,8 +2582,9 @@ AsciiStrHexToUint64S (
   }\r
 \r
   if (EndPointer != NULL) {\r
-    *EndPointer = (CHAR8 *) String;\r
+    *EndPointer = (CHAR8 *)String;\r
   }\r
+\r
   return RETURN_SUCCESS;\r
 }\r
 \r
@@ -2577,14 +2631,14 @@ AsciiStrHexToUint64S (
 RETURN_STATUS\r
 EFIAPI\r
 UnicodeStrToAsciiStrS (\r
-  IN      CONST CHAR16              *Source,\r
-  OUT     CHAR8                     *Destination,\r
-  IN      UINTN                     DestMax\r
+  IN      CONST CHAR16  *Source,\r
+  OUT     CHAR8         *Destination,\r
+  IN      UINTN         DestMax\r
   )\r
 {\r
-  UINTN            SourceLen;\r
+  UINTN  SourceLen;\r
 \r
-  ASSERT (((UINTN) Source & BIT0) == 0);\r
+  ASSERT (((UINTN)Source & BIT0) == 0);\r
 \r
   //\r
   // 1. Neither Destination nor Source shall be a null pointer.\r
@@ -2598,6 +2652,7 @@ UnicodeStrToAsciiStrS (
   if (ASCII_RSIZE_MAX != 0) {\r
     SAFE_STRING_CONSTRAINT_CHECK ((DestMax <= ASCII_RSIZE_MAX), RETURN_INVALID_PARAMETER);\r
   }\r
+\r
   if (RSIZE_MAX != 0) {\r
     SAFE_STRING_CONSTRAINT_CHECK ((DestMax <= RSIZE_MAX), RETURN_INVALID_PARAMETER);\r
   }\r
@@ -2616,7 +2671,7 @@ UnicodeStrToAsciiStrS (
   //\r
   // 5. Copying shall not take place between objects that overlap.\r
   //\r
-  SAFE_STRING_CONSTRAINT_CHECK (!InternalSafeStringIsOverlap (Destination, DestMax, (VOID *)Source, (SourceLen + 1) * sizeof(CHAR16)), RETURN_ACCESS_DENIED);\r
+  SAFE_STRING_CONSTRAINT_CHECK (!InternalSafeStringIsOverlap (Destination, DestMax, (VOID *)Source, (SourceLen + 1) * sizeof (CHAR16)), RETURN_ACCESS_DENIED);\r
 \r
   //\r
   // convert string\r
@@ -2627,8 +2682,9 @@ UnicodeStrToAsciiStrS (
     // non-zero value in the upper 8 bits, then ASSERT().\r
     //\r
     ASSERT (*Source < 0x100);\r
-    *(Destination++) = (CHAR8) *(Source++);\r
+    *(Destination++) = (CHAR8)*(Source++);\r
   }\r
+\r
   *Destination = '\0';\r
 \r
   return RETURN_SUCCESS;\r
@@ -2682,16 +2738,16 @@ UnicodeStrToAsciiStrS (
 RETURN_STATUS\r
 EFIAPI\r
 UnicodeStrnToAsciiStrS (\r
-  IN      CONST CHAR16              *Source,\r
-  IN      UINTN                     Length,\r
-  OUT     CHAR8                     *Destination,\r
-  IN      UINTN                     DestMax,\r
-  OUT     UINTN                     *DestinationLength\r
+  IN      CONST CHAR16  *Source,\r
+  IN      UINTN         Length,\r
+  OUT     CHAR8         *Destination,\r
+  IN      UINTN         DestMax,\r
+  OUT     UINTN         *DestinationLength\r
   )\r
 {\r
-  UINTN            SourceLen;\r
+  UINTN  SourceLen;\r
 \r
-  ASSERT (((UINTN) Source & BIT0) == 0);\r
+  ASSERT (((UINTN)Source & BIT0) == 0);\r
 \r
   //\r
   // 1. None of Destination, Source or DestinationLength shall be a null\r
@@ -2709,6 +2765,7 @@ UnicodeStrnToAsciiStrS (
     SAFE_STRING_CONSTRAINT_CHECK ((Length <= ASCII_RSIZE_MAX), RETURN_INVALID_PARAMETER);\r
     SAFE_STRING_CONSTRAINT_CHECK ((DestMax <= ASCII_RSIZE_MAX), RETURN_INVALID_PARAMETER);\r
   }\r
+\r
   if (RSIZE_MAX != 0) {\r
     SAFE_STRING_CONSTRAINT_CHECK ((Length <= RSIZE_MAX), RETURN_INVALID_PARAMETER);\r
     SAFE_STRING_CONSTRAINT_CHECK ((DestMax <= RSIZE_MAX), RETURN_INVALID_PARAMETER);\r
@@ -2734,7 +2791,8 @@ UnicodeStrnToAsciiStrS (
   if (SourceLen > Length) {\r
     SourceLen = Length;\r
   }\r
-  SAFE_STRING_CONSTRAINT_CHECK (!InternalSafeStringIsOverlap (Destination, DestMax, (VOID *)Source, (SourceLen + 1) * sizeof(CHAR16)), RETURN_ACCESS_DENIED);\r
+\r
+  SAFE_STRING_CONSTRAINT_CHECK (!InternalSafeStringIsOverlap (Destination, DestMax, (VOID *)Source, (SourceLen + 1) * sizeof (CHAR16)), RETURN_ACCESS_DENIED);\r
 \r
   *DestinationLength = 0;\r
 \r
@@ -2747,10 +2805,11 @@ UnicodeStrnToAsciiStrS (
     // 8 bits, then ASSERT().\r
     //\r
     ASSERT (*Source < 0x100);\r
-    *(Destination++) = (CHAR8) *(Source++);\r
+    *(Destination++) = (CHAR8)*(Source++);\r
     SourceLen--;\r
     (*DestinationLength)++;\r
   }\r
+\r
   *Destination = 0;\r
 \r
   return RETURN_SUCCESS;\r
@@ -2795,14 +2854,14 @@ UnicodeStrnToAsciiStrS (
 RETURN_STATUS\r
 EFIAPI\r
 AsciiStrToUnicodeStrS (\r
-  IN      CONST CHAR8               *Source,\r
-  OUT     CHAR16                    *Destination,\r
-  IN      UINTN                     DestMax\r
+  IN      CONST CHAR8  *Source,\r
+  OUT     CHAR16       *Destination,\r
+  IN      UINTN        DestMax\r
   )\r
 {\r
-  UINTN            SourceLen;\r
+  UINTN  SourceLen;\r
 \r
-  ASSERT (((UINTN) Destination & BIT0) == 0);\r
+  ASSERT (((UINTN)Destination & BIT0) == 0);\r
 \r
   //\r
   // 1. Neither Destination nor Source shall be a null pointer.\r
@@ -2816,6 +2875,7 @@ AsciiStrToUnicodeStrS (
   if (RSIZE_MAX != 0) {\r
     SAFE_STRING_CONSTRAINT_CHECK ((DestMax <= RSIZE_MAX), RETURN_INVALID_PARAMETER);\r
   }\r
+\r
   if (ASCII_RSIZE_MAX != 0) {\r
     SAFE_STRING_CONSTRAINT_CHECK ((DestMax <= ASCII_RSIZE_MAX), RETURN_INVALID_PARAMETER);\r
   }\r
@@ -2834,7 +2894,7 @@ AsciiStrToUnicodeStrS (
   //\r
   // 5. Copying shall not take place between objects that overlap.\r
   //\r
-  SAFE_STRING_CONSTRAINT_CHECK (!InternalSafeStringIsOverlap (Destination, DestMax * sizeof(CHAR16), (VOID *)Source, SourceLen + 1), RETURN_ACCESS_DENIED);\r
+  SAFE_STRING_CONSTRAINT_CHECK (!InternalSafeStringIsOverlap (Destination, DestMax * sizeof (CHAR16), (VOID *)Source, SourceLen + 1), RETURN_ACCESS_DENIED);\r
 \r
   //\r
   // Convert string\r
@@ -2842,6 +2902,7 @@ AsciiStrToUnicodeStrS (
   while (*Source != '\0') {\r
     *(Destination++) = (CHAR16)(UINT8)*(Source++);\r
   }\r
+\r
   *Destination = '\0';\r
 \r
   return RETURN_SUCCESS;\r
@@ -2892,16 +2953,16 @@ AsciiStrToUnicodeStrS (
 RETURN_STATUS\r
 EFIAPI\r
 AsciiStrnToUnicodeStrS (\r
-  IN      CONST CHAR8               *Source,\r
-  IN      UINTN                     Length,\r
-  OUT     CHAR16                    *Destination,\r
-  IN      UINTN                     DestMax,\r
-  OUT     UINTN                     *DestinationLength\r
+  IN      CONST CHAR8  *Source,\r
+  IN      UINTN        Length,\r
+  OUT     CHAR16       *Destination,\r
+  IN      UINTN        DestMax,\r
+  OUT     UINTN        *DestinationLength\r
   )\r
 {\r
-  UINTN            SourceLen;\r
+  UINTN  SourceLen;\r
 \r
-  ASSERT (((UINTN) Destination & BIT0) == 0);\r
+  ASSERT (((UINTN)Destination & BIT0) == 0);\r
 \r
   //\r
   // 1. None of Destination, Source or DestinationLength shall be a null\r
@@ -2919,6 +2980,7 @@ AsciiStrnToUnicodeStrS (
     SAFE_STRING_CONSTRAINT_CHECK ((Length <= RSIZE_MAX), RETURN_INVALID_PARAMETER);\r
     SAFE_STRING_CONSTRAINT_CHECK ((DestMax <= RSIZE_MAX), RETURN_INVALID_PARAMETER);\r
   }\r
+\r
   if (ASCII_RSIZE_MAX != 0) {\r
     SAFE_STRING_CONSTRAINT_CHECK ((Length <= ASCII_RSIZE_MAX), RETURN_INVALID_PARAMETER);\r
     SAFE_STRING_CONSTRAINT_CHECK ((DestMax <= ASCII_RSIZE_MAX), RETURN_INVALID_PARAMETER);\r
@@ -2944,7 +3006,8 @@ AsciiStrnToUnicodeStrS (
   if (SourceLen > Length) {\r
     SourceLen = Length;\r
   }\r
-  SAFE_STRING_CONSTRAINT_CHECK (!InternalSafeStringIsOverlap (Destination, DestMax * sizeof(CHAR16), (VOID *)Source, SourceLen + 1), RETURN_ACCESS_DENIED);\r
+\r
+  SAFE_STRING_CONSTRAINT_CHECK (!InternalSafeStringIsOverlap (Destination, DestMax * sizeof (CHAR16), (VOID *)Source, SourceLen + 1), RETURN_ACCESS_DENIED);\r
 \r
   *DestinationLength = 0;\r
 \r
@@ -2956,6 +3019,7 @@ AsciiStrnToUnicodeStrS (
     SourceLen--;\r
     (*DestinationLength)++;\r
   }\r
+\r
   *Destination = 0;\r
 \r
   return RETURN_SUCCESS;\r
@@ -3012,21 +3076,21 @@ AsciiStrnToUnicodeStrS (
 RETURN_STATUS\r
 EFIAPI\r
 AsciiStrToIpv6Address (\r
-  IN  CONST CHAR8        *String,\r
-  OUT CHAR8              **EndPointer  OPTIONAL,\r
-  OUT IPv6_ADDRESS       *Address,\r
-  OUT UINT8              *PrefixLength OPTIONAL\r
+  IN  CONST CHAR8   *String,\r
+  OUT CHAR8         **EndPointer  OPTIONAL,\r
+  OUT IPv6_ADDRESS  *Address,\r
+  OUT UINT8         *PrefixLength OPTIONAL\r
   )\r
 {\r
-  RETURN_STATUS          Status;\r
-  UINTN                  AddressIndex;\r
-  UINTN                  Uintn;\r
-  IPv6_ADDRESS           LocalAddress;\r
-  UINT8                  LocalPrefixLength;\r
-  CONST CHAR8            *Pointer;\r
-  CHAR8                  *End;\r
-  UINTN                  CompressStart;\r
-  BOOLEAN                ExpectPrefix;\r
+  RETURN_STATUS  Status;\r
+  UINTN          AddressIndex;\r
+  UINTN          Uintn;\r
+  IPv6_ADDRESS   LocalAddress;\r
+  UINT8          LocalPrefixLength;\r
+  CONST CHAR8    *Pointer;\r
+  CHAR8          *End;\r
+  UINTN          CompressStart;\r
+  BOOLEAN        ExpectPrefix;\r
 \r
   LocalPrefixLength = MAX_UINT8;\r
   CompressStart     = ARRAY_SIZE (Address->Addr);\r
@@ -3058,7 +3122,7 @@ AsciiStrToIpv6Address (
         return RETURN_UNSUPPORTED;\r
       }\r
 \r
-      if (CompressStart != ARRAY_SIZE (Address->Addr) || AddressIndex == ARRAY_SIZE (Address->Addr)) {\r
+      if ((CompressStart != ARRAY_SIZE (Address->Addr)) || (AddressIndex == ARRAY_SIZE (Address->Addr))) {\r
         //\r
         // "::" can only appear once.\r
         // "::" can only appear when address is not full length.\r
@@ -3078,6 +3142,7 @@ AsciiStrToIpv6Address (
             //\r
             return RETURN_UNSUPPORTED;\r
           }\r
+\r
           Pointer++;\r
         }\r
       }\r
@@ -3100,33 +3165,35 @@ AsciiStrToIpv6Address (
         // Get X.\r
         //\r
         Status = AsciiStrHexToUintnS (Pointer, &End, &Uintn);\r
-        if (RETURN_ERROR (Status) || End - Pointer > 4) {\r
+        if (RETURN_ERROR (Status) || (End - Pointer > 4)) {\r
           //\r
           // Number of hexadecimal digit characters is no more than 4.\r
           //\r
           return RETURN_UNSUPPORTED;\r
         }\r
+\r
         Pointer = End;\r
         //\r
         // Uintn won't exceed MAX_UINT16 if number of hexadecimal digit characters is no more than 4.\r
         //\r
         ASSERT (AddressIndex + 1 < ARRAY_SIZE (Address->Addr));\r
-        LocalAddress.Addr[AddressIndex] = (UINT8) ((UINT16) Uintn >> 8);\r
-        LocalAddress.Addr[AddressIndex + 1] = (UINT8) Uintn;\r
-        AddressIndex += 2;\r
+        LocalAddress.Addr[AddressIndex]     = (UINT8)((UINT16)Uintn >> 8);\r
+        LocalAddress.Addr[AddressIndex + 1] = (UINT8)Uintn;\r
+        AddressIndex                       += 2;\r
       } else {\r
         //\r
         // Get P, then exit the loop.\r
         //\r
         Status = AsciiStrDecimalToUintnS (Pointer, &End, &Uintn);\r
-        if (RETURN_ERROR (Status) || End == Pointer || Uintn > 128) {\r
+        if (RETURN_ERROR (Status) || (End == Pointer) || (Uintn > 128)) {\r
           //\r
           // Prefix length should not exceed 128.\r
           //\r
           return RETURN_UNSUPPORTED;\r
         }\r
-        LocalPrefixLength = (UINT8) Uintn;\r
-        Pointer = End;\r
+\r
+        LocalPrefixLength = (UINT8)Uintn;\r
+        Pointer           = End;\r
         break;\r
       }\r
     }\r
@@ -3149,18 +3216,21 @@ AsciiStrToIpv6Address (
       //\r
       break;\r
     }\r
+\r
     Pointer++;\r
   }\r
 \r
-  if ((AddressIndex == ARRAY_SIZE (Address->Addr) && CompressStart != ARRAY_SIZE (Address->Addr)) ||\r
-    (AddressIndex != ARRAY_SIZE (Address->Addr) && CompressStart == ARRAY_SIZE (Address->Addr))\r
-      ) {\r
+  if (((AddressIndex == ARRAY_SIZE (Address->Addr)) && (CompressStart != ARRAY_SIZE (Address->Addr))) ||\r
+      ((AddressIndex != ARRAY_SIZE (Address->Addr)) && (CompressStart == ARRAY_SIZE (Address->Addr)))\r
+      )\r
+  {\r
     //\r
     // Full length of address shall not have compressing zeros.\r
     // Non-full length of address shall have compressing zeros.\r
     //\r
     return RETURN_UNSUPPORTED;\r
   }\r
+\r
   CopyMem (&Address->Addr[0], &LocalAddress.Addr[0], CompressStart);\r
   ZeroMem (&Address->Addr[CompressStart], ARRAY_SIZE (Address->Addr) - AddressIndex);\r
   if (AddressIndex > CompressStart) {\r
@@ -3169,14 +3239,14 @@ AsciiStrToIpv6Address (
       &LocalAddress.Addr[CompressStart],\r
       AddressIndex - CompressStart\r
       );\r
-\r
   }\r
 \r
   if (PrefixLength != NULL) {\r
     *PrefixLength = LocalPrefixLength;\r
   }\r
+\r
   if (EndPointer != NULL) {\r
-    *EndPointer = (CHAR8 *) Pointer;\r
+    *EndPointer = (CHAR8 *)Pointer;\r
   }\r
 \r
   return RETURN_SUCCESS;\r
@@ -3224,18 +3294,18 @@ AsciiStrToIpv6Address (
 RETURN_STATUS\r
 EFIAPI\r
 AsciiStrToIpv4Address (\r
-  IN  CONST CHAR8        *String,\r
-  OUT CHAR8              **EndPointer  OPTIONAL,\r
-  OUT IPv4_ADDRESS       *Address,\r
-  OUT UINT8              *PrefixLength OPTIONAL\r
+  IN  CONST CHAR8   *String,\r
+  OUT CHAR8         **EndPointer  OPTIONAL,\r
+  OUT IPv4_ADDRESS  *Address,\r
+  OUT UINT8         *PrefixLength OPTIONAL\r
   )\r
 {\r
-  RETURN_STATUS          Status;\r
-  UINTN                  AddressIndex;\r
-  UINTN                  Uintn;\r
-  IPv4_ADDRESS           LocalAddress;\r
-  UINT8                  LocalPrefixLength;\r
-  CHAR8                  *Pointer;\r
+  RETURN_STATUS  Status;\r
+  UINTN          AddressIndex;\r
+  UINTN          Uintn;\r
+  IPv4_ADDRESS   LocalAddress;\r
+  UINT8          LocalPrefixLength;\r
+  CHAR8          *Pointer;\r
 \r
   LocalPrefixLength = MAX_UINT8;\r
 \r
@@ -3245,7 +3315,7 @@ AsciiStrToIpv4Address (
   SAFE_STRING_CONSTRAINT_CHECK ((String != NULL), RETURN_INVALID_PARAMETER);\r
   SAFE_STRING_CONSTRAINT_CHECK ((Address != NULL), RETURN_INVALID_PARAMETER);\r
 \r
-  for (Pointer = (CHAR8 *) String, AddressIndex = 0; AddressIndex < ARRAY_SIZE (Address->Addr) + 1;) {\r
+  for (Pointer = (CHAR8 *)String, AddressIndex = 0; AddressIndex < ARRAY_SIZE (Address->Addr) + 1;) {\r
     if (!InternalAsciiIsDecimalDigitCharacter (*Pointer)) {\r
       //\r
       // D or P contains invalid characters.\r
@@ -3256,10 +3326,11 @@ AsciiStrToIpv4Address (
     //\r
     // Get D or P.\r
     //\r
-    Status = AsciiStrDecimalToUintnS ((CONST CHAR8 *) Pointer, &Pointer, &Uintn);\r
+    Status = AsciiStrDecimalToUintnS ((CONST CHAR8 *)Pointer, &Pointer, &Uintn);\r
     if (RETURN_ERROR (Status)) {\r
       return RETURN_UNSUPPORTED;\r
     }\r
+\r
     if (AddressIndex == ARRAY_SIZE (Address->Addr)) {\r
       //\r
       // It's P.\r
@@ -3267,7 +3338,8 @@ AsciiStrToIpv4Address (
       if (Uintn > 32) {\r
         return RETURN_UNSUPPORTED;\r
       }\r
-      LocalPrefixLength = (UINT8) Uintn;\r
+\r
+      LocalPrefixLength = (UINT8)Uintn;\r
     } else {\r
       //\r
       // It's D.\r
@@ -3275,7 +3347,8 @@ AsciiStrToIpv4Address (
       if (Uintn > MAX_UINT8) {\r
         return RETURN_UNSUPPORTED;\r
       }\r
-      LocalAddress.Addr[AddressIndex] = (UINT8) Uintn;\r
+\r
+      LocalAddress.Addr[AddressIndex] = (UINT8)Uintn;\r
       AddressIndex++;\r
     }\r
 \r
@@ -3315,6 +3388,7 @@ AsciiStrToIpv4Address (
   if (PrefixLength != NULL) {\r
     *PrefixLength = LocalPrefixLength;\r
   }\r
+\r
   if (EndPointer != NULL) {\r
     *EndPointer = Pointer;\r
   }\r
@@ -3365,12 +3439,12 @@ AsciiStrToIpv4Address (
 RETURN_STATUS\r
 EFIAPI\r
 AsciiStrToGuid (\r
-  IN  CONST CHAR8        *String,\r
-  OUT GUID               *Guid\r
+  IN  CONST CHAR8  *String,\r
+  OUT GUID         *Guid\r
   )\r
 {\r
-  RETURN_STATUS          Status;\r
-  GUID                   LocalGuid;\r
+  RETURN_STATUS  Status;\r
+  GUID           LocalGuid;\r
 \r
   //\r
   // None of String or Guid shall be a null pointer.\r
@@ -3381,49 +3455,53 @@ AsciiStrToGuid (
   //\r
   // Get aabbccdd in big-endian.\r
   //\r
-  Status = AsciiStrHexToBytes (String, 2 * sizeof (LocalGuid.Data1), (UINT8 *) &LocalGuid.Data1, sizeof (LocalGuid.Data1));\r
-  if (RETURN_ERROR (Status) || String[2 * sizeof (LocalGuid.Data1)] != '-') {\r
+  Status = AsciiStrHexToBytes (String, 2 * sizeof (LocalGuid.Data1), (UINT8 *)&LocalGuid.Data1, sizeof (LocalGuid.Data1));\r
+  if (RETURN_ERROR (Status) || (String[2 * sizeof (LocalGuid.Data1)] != '-')) {\r
     return RETURN_UNSUPPORTED;\r
   }\r
+\r
   //\r
   // Convert big-endian to little-endian.\r
   //\r
   LocalGuid.Data1 = SwapBytes32 (LocalGuid.Data1);\r
-  String += 2 * sizeof (LocalGuid.Data1) + 1;\r
+  String         += 2 * sizeof (LocalGuid.Data1) + 1;\r
 \r
   //\r
   // Get eeff in big-endian.\r
   //\r
-  Status = AsciiStrHexToBytes (String, 2 * sizeof (LocalGuid.Data2), (UINT8 *) &LocalGuid.Data2, sizeof (LocalGuid.Data2));\r
-  if (RETURN_ERROR (Status) || String[2 * sizeof (LocalGuid.Data2)] != '-') {\r
+  Status = AsciiStrHexToBytes (String, 2 * sizeof (LocalGuid.Data2), (UINT8 *)&LocalGuid.Data2, sizeof (LocalGuid.Data2));\r
+  if (RETURN_ERROR (Status) || (String[2 * sizeof (LocalGuid.Data2)] != '-')) {\r
     return RETURN_UNSUPPORTED;\r
   }\r
+\r
   //\r
   // Convert big-endian to little-endian.\r
   //\r
   LocalGuid.Data2 = SwapBytes16 (LocalGuid.Data2);\r
-  String += 2 * sizeof (LocalGuid.Data2) + 1;\r
+  String         += 2 * sizeof (LocalGuid.Data2) + 1;\r
 \r
   //\r
   // Get gghh in big-endian.\r
   //\r
-  Status = AsciiStrHexToBytes (String, 2 * sizeof (LocalGuid.Data3), (UINT8 *) &LocalGuid.Data3, sizeof (LocalGuid.Data3));\r
-  if (RETURN_ERROR (Status) || String[2 * sizeof (LocalGuid.Data3)] != '-') {\r
+  Status = AsciiStrHexToBytes (String, 2 * sizeof (LocalGuid.Data3), (UINT8 *)&LocalGuid.Data3, sizeof (LocalGuid.Data3));\r
+  if (RETURN_ERROR (Status) || (String[2 * sizeof (LocalGuid.Data3)] != '-')) {\r
     return RETURN_UNSUPPORTED;\r
   }\r
+\r
   //\r
   // Convert big-endian to little-endian.\r
   //\r
   LocalGuid.Data3 = SwapBytes16 (LocalGuid.Data3);\r
-  String += 2 * sizeof (LocalGuid.Data3) + 1;\r
+  String         += 2 * sizeof (LocalGuid.Data3) + 1;\r
 \r
   //\r
   // Get iijj.\r
   //\r
   Status = AsciiStrHexToBytes (String, 2 * 2, &LocalGuid.Data4[0], 2);\r
-  if (RETURN_ERROR (Status) || String[2 * 2] != '-') {\r
+  if (RETURN_ERROR (Status) || (String[2 * 2] != '-')) {\r
     return RETURN_UNSUPPORTED;\r
   }\r
+\r
   String += 2 * 2 + 1;\r
 \r
   //\r
@@ -3472,13 +3550,13 @@ AsciiStrToGuid (
 RETURN_STATUS\r
 EFIAPI\r
 AsciiStrHexToBytes (\r
-  IN  CONST CHAR8        *String,\r
-  IN  UINTN              Length,\r
-  OUT UINT8              *Buffer,\r
-  IN  UINTN              MaxBufferSize\r
+  IN  CONST CHAR8  *String,\r
+  IN  UINTN        Length,\r
+  OUT UINT8        *Buffer,\r
+  IN  UINTN        MaxBufferSize\r
   )\r
 {\r
-  UINTN                  Index;\r
+  UINTN  Index;\r
 \r
   //\r
   // 1. None of String or Buffer shall be a null pointer.\r
@@ -3511,6 +3589,7 @@ AsciiStrHexToBytes (
       break;\r
     }\r
   }\r
+\r
   if (Index != Length) {\r
     return RETURN_UNSUPPORTED;\r
   }\r
@@ -3518,17 +3597,17 @@ AsciiStrHexToBytes (
   //\r
   // Convert the hex string to bytes.\r
   //\r
-  for(Index = 0; Index < Length; Index++) {\r
-\r
+  for (Index = 0; Index < Length; Index++) {\r
     //\r
     // For even characters, write the upper nibble for each buffer byte,\r
     // and for even characters, the lower nibble.\r
     //\r
     if ((Index & BIT0) == 0) {\r
-      Buffer[Index / 2]  = (UINT8) InternalAsciiHexCharToUintn (String[Index]) << 4;\r
+      Buffer[Index / 2] = (UINT8)InternalAsciiHexCharToUintn (String[Index]) << 4;\r
     } else {\r
-      Buffer[Index / 2] |= (UINT8) InternalAsciiHexCharToUintn (String[Index]);\r
+      Buffer[Index / 2] |= (UINT8)InternalAsciiHexCharToUintn (String[Index]);\r
     }\r
   }\r
+\r
   return RETURN_SUCCESS;\r
 }\r