summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Jin <eric.jin@intel.com>2019-07-26 15:48:44 +0800
committerLiming Gao <liming.gao@intel.com>2019-08-15 17:22:24 +0800
commita5944b6a13e227da23daa0ab59b5d6f4b06bb49b (patch)
treeec6facce36397326be6b5ecf56b14725eacc7f62
parent11d354945c204588c98f74cfd8b6d18433d621c4 (diff)
downloadedk2-a5944b6a13e227da23daa0ab59b5d6f4b06bb49b.tar.gz
edk2-a5944b6a13e227da23daa0ab59b5d6f4b06bb49b.tar.bz2
edk2-a5944b6a13e227da23daa0ab59b5d6f4b06bb49b.zip
FmpDevicePkg/FmpDxe: Remove use of CatSprint()
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1525 The size overhead for CatSPrint() is large. This function is only used to generate variable names with HardwareInstance value appended. Use UnicodeValueToStringS() instead that is much smaller. Cc: Sean Brogan <sean.brogan@microsoft.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Cc: Liming Gao <liming.gao@intel.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Eric Jin <eric.jin@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
-rw-r--r--FmpDevicePkg/FmpDxe/FmpDxe.h1
-rw-r--r--FmpDevicePkg/FmpDxe/FmpDxe.inf1
-rw-r--r--FmpDevicePkg/FmpDxe/FmpDxeLib.inf1
-rw-r--r--FmpDevicePkg/FmpDxe/VariableSupport.c19
4 files changed, 17 insertions, 5 deletions
diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.h b/FmpDevicePkg/FmpDxe/FmpDxe.h
index 28bfa41580..150f18b656 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.h
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.h
@@ -23,6 +23,7 @@
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiLib.h>
+#include <Library/PrintLib.h>
#include <Library/FmpAuthenticationLib.h>
#include <Library/FmpDeviceLib.h>
#include <Library/FmpPayloadHeaderLib.h>
diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.inf b/FmpDevicePkg/FmpDxe/FmpDxe.inf
index 5487123935..bec73aa8fb 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxe.inf
+++ b/FmpDevicePkg/FmpDxe/FmpDxe.inf
@@ -45,6 +45,7 @@
BaseMemoryLib
UefiBootServicesTableLib
MemoryAllocationLib
+ PrintLib
UefiLib
BaseCryptLib
FmpAuthenticationLib
diff --git a/FmpDevicePkg/FmpDxe/FmpDxeLib.inf b/FmpDevicePkg/FmpDxe/FmpDxeLib.inf
index ba762b0b77..edc0cd66c1 100644
--- a/FmpDevicePkg/FmpDxe/FmpDxeLib.inf
+++ b/FmpDevicePkg/FmpDxe/FmpDxeLib.inf
@@ -45,6 +45,7 @@
BaseMemoryLib
UefiBootServicesTableLib
MemoryAllocationLib
+ PrintLib
UefiLib
BaseCryptLib
FmpAuthenticationLib
diff --git a/FmpDevicePkg/FmpDxe/VariableSupport.c b/FmpDevicePkg/FmpDxe/VariableSupport.c
index 6c1ecf7df9..86dd5b203b 100644
--- a/FmpDevicePkg/FmpDxe/VariableSupport.c
+++ b/FmpDevicePkg/FmpDxe/VariableSupport.c
@@ -147,9 +147,15 @@ GenerateFmpVariableName (
IN CHAR16 *BaseVariableName
)
{
+ UINTN Size;
CHAR16 *VariableName;
- VariableName = CatSPrint (NULL, BaseVariableName);
+ //
+ // Allocate Unicode string with room for BaseVariableName and a 16 digit
+ // hexadecimal value for the HardwareInstance value.
+ //
+ Size = StrSize (BaseVariableName) + 16 * sizeof (CHAR16);
+ VariableName = AllocateCopyPool (Size, BaseVariableName);
if (VariableName == NULL) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to generate variable name %s.\n", mImageIdName, BaseVariableName));
return VariableName;
@@ -157,10 +163,13 @@ GenerateFmpVariableName (
if (HardwareInstance == 0) {
return VariableName;
}
- VariableName = CatSPrint (VariableName, L"%016lx", HardwareInstance);
- if (VariableName == NULL) {
- DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to generate variable name %s.\n", mImageIdName, BaseVariableName));
- }
+ UnicodeValueToStringS (
+ &VariableName[StrLen(BaseVariableName)],
+ Size,
+ PREFIX_ZERO | RADIX_HEX,
+ HardwareInstance,
+ 16
+ );
return VariableName;
}