]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseLib/SafeString.c
MdePkg: Fix SafeString performing assertions on runtime checks
[mirror_edk2.git] / MdePkg / Library / BaseLib / SafeString.c
index 7dc03d2caab805efb244679dcb463cb87066d3bd..3bb23ca1a1300ebfea08931fb714c74922d1a438 100644 (file)
 \r
 #define SAFE_STRING_CONSTRAINT_CHECK(Expression, Status)  \\r
   do { \\r
-    ASSERT (Expression); \\r
     if (!(Expression)) { \\r
+      DEBUG ((DEBUG_VERBOSE, \\r
+        "%a(%d) %a: SAFE_STRING_CONSTRAINT_CHECK(%a) failed.  Return %r\n", \\r
+        __FILE__, __LINE__, __FUNCTION__, #Expression, Status)); \\r
       return Status; \\r
     } \\r
   } while (FALSE)\r
@@ -197,7 +199,6 @@ StrnSizeS (
 \r
   If Destination is not aligned on a 16-bit boundary, then ASSERT().\r
   If Source is not aligned on a 16-bit boundary, then ASSERT().\r
-  If an error would be returned, then the function will also ASSERT().\r
 \r
   If an error is returned, then the Destination is unmodified.\r
 \r
@@ -279,7 +280,6 @@ StrCpyS (
 \r
   If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().\r
   If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().\r
-  If an error would be returned, then the function will also ASSERT().\r
 \r
   If an error is returned, then the Destination is unmodified.\r
 \r
@@ -372,7 +372,6 @@ StrnCpyS (
 \r
   If Destination is not aligned on a 16-bit boundary, then ASSERT().\r
   If Source is not aligned on a 16-bit boundary, then ASSERT().\r
-  If an error would be returned, then the function will also ASSERT().\r
 \r
   If an error is returned, then the Destination is unmodified.\r
 \r
@@ -473,7 +472,6 @@ StrCatS (
 \r
   If Destination is not aligned on a 16-bit boundary, then ASSERT().\r
   If Source is not aligned on a 16-bit boundary, then ASSERT().\r
-  If an error would be returned, then the function will also ASSERT().\r
 \r
   If an error is returned, then the Destination is unmodified.\r
 \r
@@ -590,12 +588,7 @@ StrnCatS (
   be ignored. Then, the function stops at the first character that is a not a\r
   valid decimal character or a Null-terminator, whichever one comes first.\r
 \r
-  If String is NULL, then ASSERT().\r
-  If Data is NULL, then ASSERT().\r
   If String is not aligned in a 16-bit boundary, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
-  PcdMaximumUnicodeStringLength Unicode characters, not including the\r
-  Null-terminator, then ASSERT().\r
 \r
   If String has no valid decimal digits in the above format, then 0 is stored\r
   at the location pointed to by Data.\r
@@ -705,12 +698,7 @@ StrDecimalToUintnS (
   be ignored. Then, the function stops at the first character that is a not a\r
   valid decimal character or a Null-terminator, whichever one comes first.\r
 \r
-  If String is NULL, then ASSERT().\r
-  If Data is NULL, then ASSERT().\r
   If String is not aligned in a 16-bit boundary, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
-  PcdMaximumUnicodeStringLength Unicode characters, not including the\r
-  Null-terminator, then ASSERT().\r
 \r
   If String has no valid decimal digits in the above format, then 0 is stored\r
   at the location pointed to by Data.\r
@@ -825,12 +813,7 @@ StrDecimalToUint64S (
   the first character that is a not a valid hexadecimal character or NULL,\r
   whichever one comes first.\r
 \r
-  If String is NULL, then ASSERT().\r
-  If Data is NULL, then ASSERT().\r
   If String is not aligned in a 16-bit boundary, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
-  PcdMaximumUnicodeStringLength Unicode characters, not including the\r
-  Null-terminator, then ASSERT().\r
 \r
   If String has no valid hexadecimal digits in the above format, then 0 is\r
   stored at the location pointed to by Data.\r
@@ -956,12 +939,7 @@ StrHexToUintnS (
   the first character that is a not a valid hexadecimal character or NULL,\r
   whichever one comes first.\r
 \r
-  If String is NULL, then ASSERT().\r
-  If Data is NULL, then ASSERT().\r
   If String is not aligned in a 16-bit boundary, then ASSERT().\r
-  If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
-  PcdMaximumUnicodeStringLength Unicode characters, not including the\r
-  Null-terminator, then ASSERT().\r
 \r
   If String has no valid hexadecimal digits in the above format, then 0 is\r
   stored at the location pointed to by Data.\r
@@ -1091,16 +1069,8 @@ StrHexToUint64S (
   "::" can be used to compress one or more groups of X when X contains only 0.\r
   The "::" can only appear once in the String.\r
 \r
-  If String is NULL, then ASSERT().\r
-\r
-  If Address is NULL, then ASSERT().\r
-\r
   If String is not aligned in a 16-bit boundary, then ASSERT().\r
 \r
-  If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
-  PcdMaximumUnicodeStringLength Unicode characters, not including the\r
-  Null-terminator, then ASSERT().\r
-\r
   If EndPointer is not NULL and Address is translated from String, a pointer\r
   to the character that stopped the scan is stored at the location pointed to\r
   by EndPointer.\r
@@ -1317,16 +1287,8 @@ StrToIpv6Address (
   When /P is in the String, the function stops at the first character that is not\r
   a valid decimal digit character after P is converted.\r
 \r
-  If String is NULL, then ASSERT().\r
-\r
-  If Address is NULL, then ASSERT().\r
-\r
   If String is not aligned in a 16-bit boundary, then ASSERT().\r
 \r
-  If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
-  PcdMaximumUnicodeStringLength Unicode characters, not including the\r
-  Null-terminator, then ASSERT().\r
-\r
   If EndPointer is not NULL and Address is translated from String, a pointer\r
   to the character that stopped the scan is stored at the location pointed to\r
   by EndPointer.\r
@@ -1482,8 +1444,6 @@ StrToIpv4Address (
                   oo          Data4[48:55]\r
                   pp          Data4[56:63]\r
 \r
-  If String is NULL, then ASSERT().\r
-  If Guid is NULL, then ASSERT().\r
   If String is not aligned in a 16-bit boundary, then ASSERT().\r
 \r
   @param  String                   Pointer to a Null-terminated Unicode string.\r
@@ -1589,17 +1549,6 @@ StrToGuid (
 \r
   If String is not aligned in a 16-bit boundary, then ASSERT().\r
 \r
-  If String is NULL, then ASSERT().\r
-\r
-  If Buffer is NULL, then ASSERT().\r
-\r
-  If Length is not multiple of 2, then ASSERT().\r
-\r
-  If PcdMaximumUnicodeStringLength is not zero and Length is greater than\r
-  PcdMaximumUnicodeStringLength, then ASSERT().\r
-\r
-  If MaxBufferSize is less than (Length / 2), then ASSERT().\r
-\r
   @param  String                   Pointer to a Null-terminated Unicode string.\r
   @param  Length                   The number of Unicode characters to decode.\r
   @param  Buffer                   Pointer to the converted bytes array.\r
@@ -1779,8 +1728,6 @@ AsciiStrnSizeS (
 \r
   This function is similar as strcpy_s defined in C11.\r
 \r
-  If an error would be returned, then the function will also ASSERT().\r
-\r
   If an error is returned, then the Destination is unmodified.\r
 \r
   @param  Destination              A pointer to a Null-terminated Ascii string.\r
@@ -1856,8 +1803,6 @@ AsciiStrCpyS (
 \r
   This function is similar as strncpy_s defined in C11.\r
 \r
-  If an error would be returned, then the function will also ASSERT().\r
-\r
   If an error is returned, then the Destination is unmodified.\r
 \r
   @param  Destination              A pointer to a Null-terminated Ascii string.\r
@@ -1944,8 +1889,6 @@ AsciiStrnCpyS (
 \r
   This function is similar as strcat_s defined in C11.\r
 \r
-  If an error would be returned, then the function will also ASSERT().\r
-\r
   If an error is returned, then the Destination is unmodified.\r
 \r
   @param  Destination              A pointer to a Null-terminated Ascii string.\r
@@ -2040,8 +1983,6 @@ AsciiStrCatS (
 \r
   This function is similar as strncat_s defined in C11.\r
 \r
-  If an error would be returned, then the function will also ASSERT().\r
-\r
   If an error is returned, then the Destination is unmodified.\r
 \r
   @param  Destination              A pointer to a Null-terminated Ascii string.\r
@@ -2154,12 +2095,6 @@ AsciiStrnCatS (
   be ignored. Then, the function stops at the first character that is a not a\r
   valid decimal character or a Null-terminator, whichever one comes first.\r
 \r
-  If String is NULL, then ASSERT().\r
-  If Data is NULL, then ASSERT().\r
-  If PcdMaximumAsciiStringLength is not zero, and String contains more than\r
-  PcdMaximumAsciiStringLength Ascii characters, not including the\r
-  Null-terminator, then ASSERT().\r
-\r
   If String has no valid decimal digits in the above format, then 0 is stored\r
   at the location pointed to by Data.\r
   If the number represented by String exceeds the range defined by UINTN, then\r
@@ -2266,12 +2201,6 @@ AsciiStrDecimalToUintnS (
   be ignored. Then, the function stops at the first character that is a not a\r
   valid decimal character or a Null-terminator, whichever one comes first.\r
 \r
-  If String is NULL, then ASSERT().\r
-  If Data is NULL, then ASSERT().\r
-  If PcdMaximumAsciiStringLength is not zero, and String contains more than\r
-  PcdMaximumAsciiStringLength Ascii characters, not including the\r
-  Null-terminator, then ASSERT().\r
-\r
   If String has no valid decimal digits in the above format, then 0 is stored\r
   at the location pointed to by Data.\r
   If the number represented by String exceeds the range defined by UINT64, then\r
@@ -2382,12 +2311,6 @@ AsciiStrDecimalToUint64S (
   character that is a not a valid hexadecimal character or Null-terminator,\r
   whichever on comes first.\r
 \r
-  If String is NULL, then ASSERT().\r
-  If Data is NULL, then ASSERT().\r
-  If PcdMaximumAsciiStringLength is not zero, and String contains more than\r
-  PcdMaximumAsciiStringLength Ascii characters, not including the\r
-  Null-terminator, then ASSERT().\r
-\r
   If String has no valid hexadecimal digits in the above format, then 0 is\r
   stored at the location pointed to by Data.\r
   If the number represented by String exceeds the range defined by UINTN, then\r
@@ -2509,12 +2432,6 @@ AsciiStrHexToUintnS (
   character that is a not a valid hexadecimal character or Null-terminator,\r
   whichever on comes first.\r
 \r
-  If String is NULL, then ASSERT().\r
-  If Data is NULL, then ASSERT().\r
-  If PcdMaximumAsciiStringLength is not zero, and String contains more than\r
-  PcdMaximumAsciiStringLength Ascii characters, not including the\r
-  Null-terminator, then ASSERT().\r
-\r
   If String has no valid hexadecimal digits in the above format, then 0 is\r
   stored at the location pointed to by Data.\r
   If the number represented by String exceeds the range defined by UINT64, then\r
@@ -2635,7 +2552,6 @@ AsciiStrHexToUint64S (
   the upper 8 bits, then ASSERT().\r
 \r
   If Source is not aligned on a 16-bit boundary, then ASSERT().\r
-  If an error would be returned, then the function will also ASSERT().\r
 \r
   If an error is returned, then the Destination is unmodified.\r
 \r
@@ -2735,7 +2651,6 @@ UnicodeStrToAsciiStrS (
   If any Unicode characters in Source contain non-zero value in the upper 8\r
   bits, then ASSERT().\r
   If Source is not aligned on a 16-bit boundary, then ASSERT().\r
-  If an error would be returned, then the function will also ASSERT().\r
 \r
   If an error is returned, then Destination and DestinationLength are\r
   unmodified.\r
@@ -2855,7 +2770,6 @@ UnicodeStrnToAsciiStrS (
   equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.\r
 \r
   If Destination is not aligned on a 16-bit boundary, then ASSERT().\r
-  If an error would be returned, then the function will also ASSERT().\r
 \r
   If an error is returned, then the Destination is unmodified.\r
 \r
@@ -2948,7 +2862,6 @@ AsciiStrToUnicodeStrS (
   ((MIN(AsciiStrLen(Source), Length) + 1) * sizeof (CHAR8)) in bytes.\r
 \r
   If Destination is not aligned on a 16-bit boundary, then ASSERT().\r
-  If an error would be returned, then the function will also ASSERT().\r
 \r
   If an error is returned, then Destination and DestinationLength are\r
   unmodified.\r
@@ -3072,10 +2985,6 @@ AsciiStrnToUnicodeStrS (
   "::" can be used to compress one or more groups of X when X contains only 0.\r
   The "::" can only appear once in the String.\r
 \r
-  If String is NULL, then ASSERT().\r
-\r
-  If Address is NULL, then ASSERT().\r
-\r
   If EndPointer is not NULL and Address is translated from String, a pointer\r
   to the character that stopped the scan is stored at the location pointed to\r
   by EndPointer.\r
@@ -3291,10 +3200,6 @@ AsciiStrToIpv6Address (
   When /P is in the String, the function stops at the first character that is not\r
   a valid decimal digit character after P is converted.\r
 \r
-  If String is NULL, then ASSERT().\r
-\r
-  If Address is NULL, then ASSERT().\r
-\r
   If EndPointer is not NULL and Address is translated from String, a pointer\r
   to the character that stopped the scan is stored at the location pointed to\r
   by EndPointer.\r
@@ -3448,9 +3353,6 @@ AsciiStrToIpv4Address (
                   oo          Data4[48:55]\r
                   pp          Data4[56:63]\r
 \r
-  If String is NULL, then ASSERT().\r
-  If Guid is NULL, then ASSERT().\r
-\r
   @param  String                   Pointer to a Null-terminated ASCII string.\r
   @param  Guid                     Pointer to the converted GUID.\r
 \r
@@ -3550,17 +3452,6 @@ AsciiStrToGuid (
   decoding stops after Length of characters and outputs Buffer containing\r
   (Length / 2) bytes.\r
 \r
-  If String is NULL, then ASSERT().\r
-\r
-  If Buffer is NULL, then ASSERT().\r
-\r
-  If Length is not multiple of 2, then ASSERT().\r
-\r
-  If PcdMaximumAsciiStringLength is not zero and Length is greater than\r
-  PcdMaximumAsciiStringLength, then ASSERT().\r
-\r
-  If MaxBufferSize is less than (Length / 2), then ASSERT().\r
-\r
   @param  String                   Pointer to a Null-terminated ASCII string.\r
   @param  Length                   The number of ASCII characters to decode.\r
   @param  Buffer                   Pointer to the converted bytes array.\r