]> git.proxmox.com Git - mirror_edk2.git/commitdiff
FmpDevicePkg/FmpDxe: Remove use of CatSprint()
authorEric Jin <eric.jin@intel.com>
Fri, 26 Jul 2019 07:48:44 +0000 (15:48 +0800)
committerLiming Gao <liming.gao@intel.com>
Thu, 15 Aug 2019 09:22:24 +0000 (17:22 +0800)
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>
FmpDevicePkg/FmpDxe/FmpDxe.h
FmpDevicePkg/FmpDxe/FmpDxe.inf
FmpDevicePkg/FmpDxe/FmpDxeLib.inf
FmpDevicePkg/FmpDxe/VariableSupport.c

index 28bfa41580b8febf6dfe33e5cb7e9d70d87cb6ce..150f18b656e111271d4db7f9a327ce68141a6662 100644 (file)
@@ -23,6 +23,7 @@
 #include <Library/UefiRuntimeServicesTableLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/UefiLib.h>\r
+#include <Library/PrintLib.h>\r
 #include <Library/FmpAuthenticationLib.h>\r
 #include <Library/FmpDeviceLib.h>\r
 #include <Library/FmpPayloadHeaderLib.h>\r
index 5487123935e2de95592b28bb9592df90976423f0..bec73aa8fbc9c8bf64b0a950436e3bcb7783cdb5 100644 (file)
@@ -45,6 +45,7 @@
   BaseMemoryLib\r
   UefiBootServicesTableLib\r
   MemoryAllocationLib\r
+  PrintLib\r
   UefiLib\r
   BaseCryptLib\r
   FmpAuthenticationLib\r
index ba762b0b7782bf4c6b3ec175483de4d91d2c5a3d..edc0cd66c10427ceeeb7eeefaff503faf23b351a 100644 (file)
@@ -45,6 +45,7 @@
   BaseMemoryLib\r
   UefiBootServicesTableLib\r
   MemoryAllocationLib\r
+  PrintLib\r
   UefiLib\r
   BaseCryptLib\r
   FmpAuthenticationLib\r
index 6c1ecf7df99086b133d3d61c44dfd00abfeccdc4..86dd5b203b73159718128fbc11089fe10d4d09a1 100644 (file)
@@ -147,9 +147,15 @@ GenerateFmpVariableName (
   IN  CHAR16  *BaseVariableName\r
   )\r
 {\r
+  UINTN   Size;\r
   CHAR16  *VariableName;\r
 \r
-  VariableName = CatSPrint (NULL, BaseVariableName);\r
+  //\r
+  // Allocate Unicode string with room for BaseVariableName and a 16 digit\r
+  // hexadecimal value for the HardwareInstance value.\r
+  //\r
+  Size = StrSize (BaseVariableName) + 16 * sizeof (CHAR16);\r
+  VariableName = AllocateCopyPool (Size, BaseVariableName);\r
   if (VariableName == NULL) {\r
     DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to generate variable name %s.\n", mImageIdName, BaseVariableName));\r
     return VariableName;\r
@@ -157,10 +163,13 @@ GenerateFmpVariableName (
   if (HardwareInstance == 0) {\r
     return VariableName;\r
   }\r
-  VariableName = CatSPrint (VariableName, L"%016lx", HardwareInstance);\r
-  if (VariableName == NULL) {\r
-    DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to generate variable name %s.\n", mImageIdName, BaseVariableName));\r
-  }\r
+  UnicodeValueToStringS (\r
+    &VariableName[StrLen(BaseVariableName)],\r
+    Size,\r
+    PREFIX_ZERO | RADIX_HEX,\r
+    HardwareInstance,\r
+    16\r
+    );\r
   return VariableName;\r
 }\r
 \r