]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/StatusCodeHandler/Pei/SerialStatusCodeWorker.c
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Universal / StatusCodeHandler / Pei / SerialStatusCodeWorker.c
index a34fa48e4528b288ae72536f12d3ad1ef01ddb41..96d589652054169a30060ccbc36c5797e7f9c65f 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Serial I/O status code reporting worker.\r
 \r
-  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -50,7 +50,7 @@ SerialStatusCodeReportWorker (
   CHAR8           *Filename;\r
   CHAR8           *Description;\r
   CHAR8           *Format;\r
-  CHAR8           Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];\r
+  CHAR8           Buffer[MAX_DEBUG_MESSAGE_LENGTH];\r
   UINT32          ErrorLevel;\r
   UINT32          LineNumber;\r
   UINTN           CharCount;\r
@@ -89,15 +89,17 @@ SerialStatusCodeReportWorker (
     CharCount = AsciiSPrint (\r
                   Buffer,\r
                   sizeof (Buffer),\r
-                  "ERROR: C%x:V%x I%x",\r
+                  "ERROR: C%08x:V%08x I%x",\r
                   CodeType,\r
                   Value,\r
                   Instance\r
                   );\r
 \r
+    ASSERT(CharCount > 0);\r
+\r
     if (CallerId != NULL) {\r
       CharCount += AsciiSPrint (\r
-                     &Buffer[CharCount - 1],\r
+                     &Buffer[CharCount],\r
                      (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
                      " %g",\r
                      CallerId\r
@@ -106,7 +108,7 @@ SerialStatusCodeReportWorker (
 \r
     if (Data != NULL) {\r
       CharCount += AsciiSPrint (\r
-                     &Buffer[CharCount - 1],\r
+                     &Buffer[CharCount],\r
                      (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
                      " %x",\r
                      Data\r
@@ -114,7 +116,7 @@ SerialStatusCodeReportWorker (
     }\r
 \r
     CharCount += AsciiSPrint (\r
-                   &Buffer[CharCount - 1],\r
+                   &Buffer[CharCount],\r
                    (sizeof (Buffer) - (sizeof (Buffer[0]) * CharCount)),\r
                    "\n\r"\r
                    );\r
@@ -125,11 +127,12 @@ SerialStatusCodeReportWorker (
     CharCount = AsciiSPrint (\r
                   Buffer,\r
                   sizeof (Buffer),\r
-                  "PROGRESS CODE: V%x I%x\n\r",\r
+                  "PROGRESS CODE: V%08x I%x\n\r",\r
                   Value,\r
                   Instance\r
                   );\r
-  } else if (CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeStringGuid) &&\r
+  } else if (Data != NULL &&\r
+             CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeStringGuid) &&\r
              ((EFI_STATUS_CODE_STRING_DATA *) Data)->StringType == EfiStringAscii) {\r
     //\r
     // EFI_STATUS_CODE_STRING_DATA\r
@@ -147,7 +150,7 @@ SerialStatusCodeReportWorker (
     CharCount = AsciiSPrint (\r
                   Buffer,\r
                   sizeof (Buffer),\r
-                  "Undefined: C%x:V%x I%x\n\r",\r
+                  "Undefined: C%08x:V%08x I%x\n\r",\r
                   CodeType,\r
                   Value,\r
                   Instance\r