]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BasePrintLib/PrintLib.c
BaseMemoryLib (BaseMemoryLibRepStr):
[mirror_edk2.git] / MdePkg / Library / BasePrintLib / PrintLib.c
index 24e01755451352ad7af165cd77b0047abe63f8f6..e940bedb3497aec3b32b83c5fa29b49f7008609e 100644 (file)
@@ -66,7 +66,6 @@ static CONST STATUS_LOOKUP_TABLE_ENTRY  StatusString[] = {
   @param  Buffer      Character buffer to print the results of the parsing\r
                       of Format into.\r
   @param  BufferSize  Maximum number of characters to put into buffer.\r
   @param  Buffer      Character buffer to print the results of the parsing\r
                       of Format into.\r
   @param  BufferSize  Maximum number of characters to put into buffer.\r
-                      Zero means no limit.\r
   @param  Flags       Intial flags value.\r
                       Can only have FORMAT_UNICODE and OUTPUT_UNICODE set\r
   @param  Format      Null-terminated format string.\r
   @param  Flags       Intial flags value.\r
                       Can only have FORMAT_UNICODE and OUTPUT_UNICODE set\r
   @param  Format      Null-terminated format string.\r
@@ -110,6 +109,9 @@ BasePrintLibVSPrint (
   UINTN           Radix;\r
   RETURN_STATUS   Status;\r
 \r
   UINTN           Radix;\r
   RETURN_STATUS   Status;\r
 \r
+  if (BufferSize == 0) {\r
+    return 0;\r
+  }\r
   ASSERT (Buffer != NULL);\r
   ASSERT (Format != NULL);\r
 \r
   ASSERT (Buffer != NULL);\r
   ASSERT (Format != NULL);\r
 \r
@@ -130,7 +132,6 @@ BasePrintLibVSPrint (
 \r
   //\r
   // Reserve space for the Null terminator.\r
 \r
   //\r
   // Reserve space for the Null terminator.\r
-  // If BufferSize is 0, this will set BufferSize to the max unsigned value\r
   //\r
   BufferSize--;\r
 \r
   //\r
   BufferSize--;\r
 \r
@@ -338,7 +339,7 @@ BasePrintLibVSPrint (
         } else {\r
           BasePrintLibSPrint (\r
             ValueBuffer,\r
         } else {\r
           BasePrintLibSPrint (\r
             ValueBuffer,\r
-            0\r
+            MAXIMUM_VALUE_CHARACTERS\r
             0,\r
             "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",\r
             TmpGuid->Data1,\r
             0,\r
             "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",\r
             TmpGuid->Data1,\r
@@ -364,7 +365,7 @@ BasePrintLibVSPrint (
         } else {\r
           BasePrintLibSPrint (\r
             ValueBuffer,\r
         } else {\r
           BasePrintLibSPrint (\r
             ValueBuffer,\r
-            0,\r
+            MAXIMUM_VALUE_CHARACTERS,\r
             0,\r
             "%02d/%02d/%04d  %02d:%02d",\r
             TmpTime->Month,\r
             0,\r
             "%02d/%02d/%04d  %02d:%02d",\r
             TmpTime->Month,\r
@@ -386,10 +387,14 @@ BasePrintLibVSPrint (
           }\r
         }\r
         if (ArgumentString == ValueBuffer) {\r
           }\r
         }\r
         if (ArgumentString == ValueBuffer) {\r
-          BasePrintLibSPrint ((CHAR8 *) ValueBuffer, 0, 0, "%08X", Status);\r
+          BasePrintLibSPrint ((CHAR8 *) ValueBuffer, MAXIMUM_VALUE_CHARACTERS, 0, "%08X", Status);\r
         }\r
         break;\r
 \r
         }\r
         break;\r
 \r
+      case '\n':\r
+        ArgumentString = "\r\n";\r
+        break;\r
+\r
       case '%':\r
       default:\r
         //\r
       case '%':\r
       default:\r
         //\r
@@ -400,9 +405,6 @@ BasePrintLibVSPrint (
         break;\r
       }\r
       break;\r
         break;\r
       }\r
       break;\r
-    case '\n':\r
-      ArgumentString = "\r\n";\r
-      break;\r
     default:\r
       ArgumentString = (CHAR8 *)&FormatCharacter;\r
       Flags |= ARGUMENT_UNICODE;\r
     default:\r
       ArgumentString = (CHAR8 *)&FormatCharacter;\r
       Flags |= ARGUMENT_UNICODE;\r
@@ -717,7 +719,7 @@ UnicodeSPrintAsciiFormat (
   VA_LIST Marker;\r
 \r
   VA_START (Marker, FormatString);\r
   VA_LIST Marker;\r
 \r
   VA_START (Marker, FormatString);\r
-  return UnicodeVSPrintAsciiFormat (StartOfBuffer, BufferSize >> 1, FormatString, Marker);\r
+  return UnicodeVSPrintAsciiFormat (StartOfBuffer, BufferSize, FormatString, Marker);\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r