summaryrefslogtreecommitdiff
path: root/MdePkg
diff options
context:
space:
mode:
authormdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2010-06-11 19:11:20 +0000
committermdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2010-06-11 19:11:20 +0000
commitcda8ba5ed7db9b6a4c963734915eae3f1d31b613 (patch)
tree0861be89ec476b62cc66e15507820edb46fe7bff /MdePkg
parentde243ee44476ccdb4979e5719cb7ac8a8c290565 (diff)
Add ASSERT() conditions to UEFI Library Print() and AsciiPrint() functions if gST->ConOut is NULL.
Add ASSERT() conditions to UEFI Library ErrorPrint() and AsciiErrorPrint() functions if gST->StdErr is NULL. Add ASSERT() conditions to UEFI Library PrintXY() and AsciiPrintXY() gST->ConsoleOutputHandle is NULL. Update Print(), AsciiPrint(), ErrorPrint(), AsciiErrorPrint() to return 0 if the Simple Text Output Protocol OutputString() call returns an error. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10576 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg')
-rw-r--r--MdePkg/Include/Library/UefiLib.h6
-rw-r--r--MdePkg/Library/UefiLib/UefiLibPrint.c34
2 files changed, 32 insertions, 8 deletions
diff --git a/MdePkg/Include/Library/UefiLib.h b/MdePkg/Include/Library/UefiLib.h
index 6d557e11c..5c2877627 100644
--- a/MdePkg/Include/Library/UefiLib.h
+++ b/MdePkg/Include/Library/UefiLib.h
@@ -986,6 +986,7 @@ EfiGetNameGuidFromFwVolDevicePathNode (
PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.
If Format is NULL, then ASSERT().
If Format is not aligned on a 16-bit boundary, then ASSERT().
+ If gST->ConOut is NULL, then ASSERT().
@param Format A null-terminated Unicode format string.
@param ... The variable argument list whose contents are accessed based
@@ -1012,6 +1013,7 @@ Print (
PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.
If Format is NULL, then ASSERT().
If Format is not aligned on a 16-bit boundary, then ASSERT().
+ If gST->StdErr is NULL, then ASSERT().
@param Format A null-terminated Unicode format string.
@param ... The variable argument list whose contents are accessed based
@@ -1037,6 +1039,7 @@ ErrorPrint (
string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.
If Format is NULL, then ASSERT().
+ If gST->ConOut is NULL, then ASSERT().
@param Format A null-terminated ASCII format string.
@param ... The variable argument list whose contents are accessed based
@@ -1062,6 +1065,7 @@ AsciiPrint (
string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.
If Format is NULL, then ASSERT().
+ If gST->StdErr is NULL, then ASSERT().
@param Format A null-terminated ASCII format string.
@param ... The variable argument list whose contents are accessed based
@@ -1098,6 +1102,7 @@ AsciiErrorPrint (
string is printed, and 0 is returned.
If Format is NULL, then ASSERT().
If Format is not aligned on a 16-bit boundary, then ASSERT().
+ If gST->ConsoleOutputHandle is NULL, then ASSERT().
@param PointX X coordinate to print the string.
@param PointY Y coordinate to print the string.
@@ -1147,6 +1152,7 @@ PrintXY (
If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no
string is printed, and 0 is returned.
If Format is NULL, then ASSERT().
+ If gST->ConsoleOutputHandle is NULL, then ASSERT().
@param PointX X coordinate to print the string.
@param PointY Y coordinate to print the string.
diff --git a/MdePkg/Library/UefiLib/UefiLibPrint.c b/MdePkg/Library/UefiLib/UefiLibPrint.c
index 81d9b7b51..1c31ef1d5 100644
--- a/MdePkg/Library/UefiLib/UefiLibPrint.c
+++ b/MdePkg/Library/UefiLib/UefiLibPrint.c
@@ -59,12 +59,14 @@ InternalPrint (
IN VA_LIST Marker
)
{
- UINTN Return;
- CHAR16 *Buffer;
- UINTN BufferSize;
+ EFI_STATUS Status;
+ UINTN Return;
+ CHAR16 *Buffer;
+ UINTN BufferSize;
ASSERT (Format != NULL);
ASSERT (((UINTN) Format & BIT0) == 0);
+ ASSERT (Console != NULL);
BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);
@@ -77,7 +79,10 @@ InternalPrint (
//
// To be extra safe make sure Console has been initialized
//
- Console->OutputString (Console, Buffer);
+ Status = Console->OutputString (Console, Buffer);
+ if (EFI_ERROR (Status)) {
+ Return = 0;
+ }
}
FreePool (Buffer);
@@ -96,6 +101,7 @@ InternalPrint (
PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.
If Format is NULL, then ASSERT().
If Format is not aligned on a 16-bit boundary, then ASSERT().
+ If gST->ConOut is NULL, then ASSERT().
@param Format Null-terminated Unicode format string.
@param ... Variable argument list whose contents are accessed based
@@ -134,6 +140,7 @@ Print (
PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.
If Format is NULL, then ASSERT().
If Format is not aligned on a 16-bit boundary, then ASSERT().
+ If gST->StdErr is NULL, then ASSERT().
@param Format Null-terminated Unicode format string.
@param ... Variable argument list whose contents are accessed based
@@ -188,11 +195,13 @@ AsciiInternalPrint (
IN VA_LIST Marker
)
{
- UINTN Return;
- CHAR16 *Buffer;
- UINTN BufferSize;
+ EFI_STATUS Status;
+ UINTN Return;
+ CHAR16 *Buffer;
+ UINTN BufferSize;
ASSERT (Format != NULL);
+ ASSERT (Console != NULL);
BufferSize = (PcdGet32 (PcdUefiLibMaxPrintBufferSize) + 1) * sizeof (CHAR16);
@@ -205,7 +214,10 @@ AsciiInternalPrint (
//
// To be extra safe make sure Console has been initialized
//
- Console->OutputString (Console, Buffer);
+ Status = Console->OutputString (Console, Buffer);
+ if (EFI_ERROR (Status)) {
+ Return = 0;
+ }
}
FreePool (Buffer);
@@ -223,6 +235,7 @@ AsciiInternalPrint (
string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
PcdUefiLibMaxPrintBufferSize characters are sent to ConOut.
If Format is NULL, then ASSERT().
+ If gST->ConOut is NULL, then ASSERT().
@param Format Null-terminated ASCII format string.
@param ... Variable argument list whose contents are accessed based
@@ -261,6 +274,7 @@ AsciiPrint (
string is greater than PcdUefiLibMaxPrintBufferSize, then only the first
PcdUefiLibMaxPrintBufferSize characters are sent to StdErr.
If Format is NULL, then ASSERT().
+ If gST->StdErr is NULL, then ASSERT().
@param Format Null-terminated ASCII format string.
@param ... Variable argument list whose contents are accessed based
@@ -357,6 +371,8 @@ InternalPrintGraphic (
RowInfoArray = NULL;
ConsoleHandle = gST->ConsoleOutHandle;
+
+ ASSERT( ConsoleHandle != NULL);
Status = gBS->HandleProtocol (
ConsoleHandle,
@@ -558,6 +574,7 @@ Error:
string is printed, and 0 is returned.
If Format is NULL, then ASSERT().
If Format is not aligned on a 16-bit boundary, then ASSERT().
+ If gST->ConsoleOutputHandle is NULL, then ASSERT().
@param PointX X coordinate to print the string.
@param PointY Y coordinate to print the string.
@@ -634,6 +651,7 @@ PrintXY (
If the EFI_HII_FONT_PROTOCOL is not present in the handle database, then no
string is printed, and 0 is returned.
If Format is NULL, then ASSERT().
+ If gST->ConsoleOutputHandle is NULL, then ASSERT().
@param PointX X coordinate to print the string.
@param PointY Y coordinate to print the string.