]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkCompatibilityPkg/Foundation/Library/Dxe/GraphicsLite/Print.c
Add Missing invocations to VA_END() for VA_START().
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / Dxe / GraphicsLite / Print.c
index 2f29293b4269da48d363045e9737998f87a276bc..1492e53d681b818e8d58ad3dd39ef72731b0ee50 100644 (file)
@@ -1,7 +1,7 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2007, Intel Corporation                                                         \r
-All rights reserved. This program and the accompanying materials                          \r
+Copyright (c) 2004 - 2012, 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
 http://opensource.org/licenses/bsd-license.php                                            \r
@@ -66,22 +66,22 @@ Abstract:
 #endif\r
 \r
 static EFI_GRAPHICS_OUTPUT_BLT_PIXEL  mEfiColors[16] = {\r
-  0x00, 0x00, 0x00, 0x00,\r
-  0x98, 0x00, 0x00, 0x00,\r
-  0x00, 0x98, 0x00, 0x00,\r
-  0x98, 0x98, 0x00, 0x00,\r
-  0x00, 0x00, 0x98, 0x00,\r
-  0x98, 0x00, 0x98, 0x00,\r
-  0x00, 0x98, 0x98, 0x00,\r
-  0x98, 0x98, 0x98, 0x00,\r
-  0x10, 0x10, 0x10, 0x00,\r
-  0xff, 0x10, 0x10, 0x00,\r
-  0x10, 0xff, 0x10, 0x00,\r
-  0xff, 0xff, 0x10, 0x00,\r
-  0x10, 0x10, 0xff, 0x00,\r
-  0xf0, 0x10, 0xff, 0x00,\r
-  0x10, 0xff, 0xff, 0x00,\r
-  0xff, 0xff, 0xff, 0x00,\r
+  {0x00, 0x00, 0x00, 0x00},\r
+  {0x98, 0x00, 0x00, 0x00},\r
+  {0x00, 0x98, 0x00, 0x00},\r
+  {0x98, 0x98, 0x00, 0x00},\r
+  {0x00, 0x00, 0x98, 0x00},\r
+  {0x98, 0x00, 0x98, 0x00},\r
+  {0x00, 0x98, 0x98, 0x00},\r
+  {0x98, 0x98, 0x98, 0x00},\r
+  {0x10, 0x10, 0x10, 0x00},\r
+  {0xff, 0x10, 0x10, 0x00},\r
+  {0x10, 0xff, 0x10, 0x00},\r
+  {0xff, 0xff, 0x10, 0x00},\r
+  {0x10, 0x10, 0xff, 0x00},\r
+  {0xf0, 0x10, 0xff, 0x00},\r
+  {0x10, 0xff, 0xff, 0x00},\r
+  {0xff, 0xff, 0xff, 0x00},\r
 };\r
 \r
 \r
@@ -125,8 +125,7 @@ Arguments:
 \r
 Returns: \r
 \r
-  EFI_SUCCESS             -  success\r
-  EFI_OUT_OF_RESOURCES    -  out of resources\r
+  Length of string printed to the console\r
 \r
 --*/\r
 {\r
@@ -156,9 +155,10 @@ Returns:
   //\r
   // For now, allocate an arbitrarily long buffer\r
   //\r
+  BufferLen = 0;\r
   Buffer = EfiLibAllocateZeroPool (0x10000);\r
   if (Buffer == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
+    return 0;\r
   }\r
 \r
   if (GraphicsOutput != NULL) {\r
@@ -337,10 +337,15 @@ Error:
   EfiLibSafeFreePool (Blt);\r
   EfiLibSafeFreePool (FontInfo);\r
 #else\r
-  gBS->FreePool (LineBuffer);\r
+  EfiLibSafeFreePool (LineBuffer);\r
 #endif  \r
   gBS->FreePool (Buffer);\r
-  return Status;\r
+  \r
+  if (EFI_ERROR (Status)) {\r
+    return 0;\r
+  }\r
+\r
+  return BufferLen;\r
 }\r
 \r
 \r
@@ -385,43 +390,47 @@ Returns:
   EFI_SIMPLE_TEXT_OUT_PROTOCOL  *Sto;\r
   EFI_STATUS                    Status;\r
   VA_LIST                       Args;\r
-\r
-  VA_START (Args, Fmt);\r
+  UINTN                         LengthOfPrinted;\r
 \r
   Handle = gST->ConsoleOutHandle;\r
 \r
+  GraphicsOutput = NULL;\r
+  UgaDraw = NULL;\r
   Status = gBS->HandleProtocol (\r
                   Handle,\r
                   &gEfiGraphicsOutputProtocolGuid,\r
-                  &GraphicsOutput\r
+                  (VOID **) &GraphicsOutput\r
                   );\r
 \r
-  UgaDraw = NULL;\r
-  if (EFI_ERROR (Status)) {\r
+  if (EFI_ERROR (Status) || (GraphicsOutput == NULL)) {\r
     GraphicsOutput = NULL;\r
 \r
     Status = gBS->HandleProtocol (\r
                     Handle,\r
                     &gEfiUgaDrawProtocolGuid,\r
-                    &UgaDraw\r
+                    (VOID **) &UgaDraw\r
                     );\r
 \r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
+    if (EFI_ERROR (Status) || (UgaDraw == NULL)) {\r
+      return 0;\r
     }\r
   }\r
 \r
+  Sto = NULL;\r
   Status = gBS->HandleProtocol (\r
                   Handle,\r
                   &gEfiSimpleTextOutProtocolGuid,\r
-                  &Sto\r
+                  (VOID **) &Sto\r
                   );\r
 \r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
+  if (EFI_ERROR (Status) || (Sto == NULL)) {\r
+    return 0;\r
   }\r
 \r
-  return _IPrint (GraphicsOutput, UgaDraw, Sto, X, Y, ForeGround, BackGround, Fmt, Args);\r
+  VA_START (Args, Fmt);\r
+  LengthOfPrinted = _IPrint (GraphicsOutput, UgaDraw, Sto, X, Y, ForeGround, BackGround, Fmt, Args);\r
+  VA_END (Args);\r
+  return LengthOfPrinted;\r
 }\r
 \r
 \r
@@ -504,7 +513,7 @@ Returns:
   Status = gBS->LocateProtocol (\r
                   &gEfiPrintProtocolGuid,\r
                   NULL,\r
-                  &PrintProtocol\r
+                  (VOID **) &PrintProtocol\r
                   );\r
   if (EFI_ERROR (Status)) {\r
     return 0;\r