summaryrefslogtreecommitdiff
path: root/MdePkg/Library/BasePrintLib
diff options
context:
space:
mode:
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2006-06-13 06:31:11 +0000
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>2006-06-13 06:31:11 +0000
commit8960cdebac8c75f13f1cb6afa932f0ae323a138b (patch)
tree0bf5bf973e6a379677db5282165ced3a69bae19d /MdePkg/Library/BasePrintLib
parentad82307c753df478012953df517006c58cd7b8a4 (diff)
downloadedk2-platforms-8960cdebac8c75f13f1cb6afa932f0ae323a138b.tar.xz
BaseMemoryLib (BaseMemoryLibRepStr):
Fix a logic error in SetMem64 (); The correct stride should be 8 instead of 4. BasePrintLib: Fix Printf(ā€œ%\nā€) passer error. Fix BufferSize = 0, 1 issue Fix some missing ASSERT ()s Move MAXIMUM_VALUE_CHARACTERS from PrintLibInternal.h to PrintLib.h ReportStatusCodeLib: Add CONST modifier to some interfaces Modify DebugLib: Replace some Unicode in comments. PeiServicesTablePointerLib Add ASSERT()s PciLib: Remove unnecessary ASSERT()s in PciRead/WriteBuffer() git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@496 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg/Library/BasePrintLib')
-rw-r--r--MdePkg/Library/BasePrintLib/PrintLib.c20
-rw-r--r--MdePkg/Library/BasePrintLib/PrintLibInternal.c9
-rw-r--r--MdePkg/Library/BasePrintLib/PrintLibInternal.h10
3 files changed, 19 insertions, 20 deletions
diff --git a/MdePkg/Library/BasePrintLib/PrintLib.c b/MdePkg/Library/BasePrintLib/PrintLib.c
index 24e0175545..e940bedb34 100644
--- a/MdePkg/Library/BasePrintLib/PrintLib.c
+++ b/MdePkg/Library/BasePrintLib/PrintLib.c
@@ -66,7 +66,6 @@ static CONST STATUS_LOOKUP_TABLE_ENTRY StatusString[] = {
@param Buffer Character buffer to print the results of the parsing
of Format into.
@param BufferSize Maximum number of characters to put into buffer.
- Zero means no limit.
@param Flags Intial flags value.
Can only have FORMAT_UNICODE and OUTPUT_UNICODE set
@param Format Null-terminated format string.
@@ -110,6 +109,9 @@ BasePrintLibVSPrint (
UINTN Radix;
RETURN_STATUS Status;
+ if (BufferSize == 0) {
+ return 0;
+ }
ASSERT (Buffer != NULL);
ASSERT (Format != NULL);
@@ -130,7 +132,6 @@ BasePrintLibVSPrint (
//
// Reserve space for the Null terminator.
- // If BufferSize is 0, this will set BufferSize to the max unsigned value
//
BufferSize--;
@@ -338,7 +339,7 @@ BasePrintLibVSPrint (
} else {
BasePrintLibSPrint (
ValueBuffer,
- 0,
+ MAXIMUM_VALUE_CHARACTERS,
0,
"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
TmpGuid->Data1,
@@ -364,7 +365,7 @@ BasePrintLibVSPrint (
} else {
BasePrintLibSPrint (
ValueBuffer,
- 0,
+ MAXIMUM_VALUE_CHARACTERS,
0,
"%02d/%02d/%04d %02d:%02d",
TmpTime->Month,
@@ -386,10 +387,14 @@ BasePrintLibVSPrint (
}
}
if (ArgumentString == ValueBuffer) {
- BasePrintLibSPrint ((CHAR8 *) ValueBuffer, 0, 0, "%08X", Status);
+ BasePrintLibSPrint ((CHAR8 *) ValueBuffer, MAXIMUM_VALUE_CHARACTERS, 0, "%08X", Status);
}
break;
+ case '\n':
+ ArgumentString = "\r\n";
+ break;
+
case '%':
default:
//
@@ -400,9 +405,6 @@ BasePrintLibVSPrint (
break;
}
break;
- case '\n':
- ArgumentString = "\r\n";
- break;
default:
ArgumentString = (CHAR8 *)&FormatCharacter;
Flags |= ARGUMENT_UNICODE;
@@ -717,7 +719,7 @@ UnicodeSPrintAsciiFormat (
VA_LIST Marker;
VA_START (Marker, FormatString);
- return UnicodeVSPrintAsciiFormat (StartOfBuffer, BufferSize >> 1, FormatString, Marker);
+ return UnicodeVSPrintAsciiFormat (StartOfBuffer, BufferSize, FormatString, Marker);
}
/**
diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.c b/MdePkg/Library/BasePrintLib/PrintLibInternal.c
index 89d18b09a2..06c220692e 100644
--- a/MdePkg/Library/BasePrintLib/PrintLibInternal.c
+++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.c
@@ -138,13 +138,20 @@ BasePrintLibConvertValueToString (
UINTN Digits;
UINTN Index;
+ ASSERT (Buffer != NULL);
+ ASSERT (Width < MAXIMUM_VALUE_CHARACTERS);
+ //
+ // Make sure Flags can only contain supported bits.
+ //
+ ASSERT ((Flags & ~(LEFT_JUSTIFY | COMMA_TYPE | PREFIX_ZERO)) == 0);
+
OriginalBuffer = Buffer;
if (Width == 0 || (Flags & COMMA_TYPE) != 0) {
Flags &= (~PREFIX_ZERO);
}
- if (Width == 0 || Width > (MAXIMUM_VALUE_CHARACTERS - 1)) {
+ if (Width == 0) {
Width = MAXIMUM_VALUE_CHARACTERS - 1;
}
diff --git a/MdePkg/Library/BasePrintLib/PrintLibInternal.h b/MdePkg/Library/BasePrintLib/PrintLibInternal.h
index 0f7bebff45..f395bb7956 100644
--- a/MdePkg/Library/BasePrintLib/PrintLibInternal.h
+++ b/MdePkg/Library/BasePrintLib/PrintLibInternal.h
@@ -31,16 +31,6 @@
#define PRECISION 0x800
#define ARGUMENT_REVERSED 0x1000
-///
-/// Define the maximum number of characters that are required to encode
-/// a decimal, hexidecimal, GUID, or TIME value with a Nll terminator.
-/// Maximum Length Decimal String = 28 "-9,223,372,036,854,775,808"
-/// Maximum Length Hexidecimal String = 17 "FFFFFFFFFFFFFFFF"
-/// Maximum Length GUID = 37 "00000000-0000-0000-0000-000000000000"
-/// Maximum Length TIME = 18 "12/12/2006 12:12"
-///
-#define MAXIMUM_VALUE_CHARACTERS 38
-
//
// Record date and time information
//