From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: eric.jin@intel.com) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by groups.io with SMTP; Thu, 01 Aug 2019 01:46:49 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Aug 2019 01:46:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,333,1559545200"; d="scan'208";a="372535054" Received: from jjin9-mobl.ccr.corp.intel.com ([10.239.192.65]) by fmsmga006.fm.intel.com with ESMTP; 01 Aug 2019 01:46:47 -0700 From: "Eric Jin" To: devel@edk2.groups.io Cc: Sean Brogan , Bret Barkelew , Liming Gao , Michael D Kinney Subject: [PATCH 10/14] FmpDevicePkg/FmpDxe: Remove use of CatSprint() Date: Thu, 1 Aug 2019 16:46:42 +0800 Message-Id: <20190801084642.18932-1-eric.jin@intel.com> X-Mailer: git-send-email 2.20.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Cc: Bret Barkelew Cc: Liming Gao Signed-off-by: Michael D Kinney Reviewed-by: Eric Jin --- FmpDevicePkg/FmpDxe/FmpDxe.h | 1 + FmpDevicePkg/FmpDxe/FmpDxe.inf | 1 + FmpDevicePkg/FmpDxe/FmpDxeLib.inf | 1 + FmpDevicePkg/FmpDxe/VariableSupport.c | 19 ++++++++++++++----- 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 #include #include +#include #include #include #include diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.inf b/FmpDevicePkg/FmpDxe/FmpDxe.inf index 361ae9a5fc..ca9709976b 100644 --- a/FmpDevicePkg/FmpDxe/FmpDxe.inf +++ b/FmpDevicePkg/FmpDxe/FmpDxe.inf @@ -44,6 +44,7 @@ BaseMemoryLib UefiBootServicesTableLib MemoryAllocationLib + PrintLib UefiLib BaseCryptLib FmpAuthenticationLib diff --git a/FmpDevicePkg/FmpDxe/FmpDxeLib.inf b/FmpDevicePkg/FmpDxe/FmpDxeLib.inf index cc4dca5e9c..a614bc638a 100644 --- a/FmpDevicePkg/FmpDxe/FmpDxeLib.inf +++ b/FmpDevicePkg/FmpDxe/FmpDxeLib.inf @@ -44,6 +44,7 @@ BaseMemoryLib UefiBootServicesTableLib MemoryAllocationLib + PrintLib UefiLib BaseCryptLib FmpAuthenticationLib diff --git a/FmpDevicePkg/FmpDxe/VariableSupport.c b/FmpDevicePkg/FmpDxe/VariableSupport.c index 5b4242d932..2508d3bbe6 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; } -- 2.20.1.windows.1