From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web10.4102.1637026945553992587 for ; Mon, 15 Nov 2021 17:42:25 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: xiaolu.jiang@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10169"; a="233540391" X-IronPort-AV: E=Sophos;i="5.87,237,1631602800"; d="scan'208";a="233540391" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2021 17:42:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,237,1631602800"; d="scan'208";a="494260019" Received: from xiaolu-dev.ccr.corp.intel.com ([10.239.158.148]) by orsmga007.jf.intel.com with ESMTP; 15 Nov 2021 17:42:23 -0800 From: Xiaolu.jiang@intel.com To: devel@edk2.groups.io Cc: "Xiaolu.Jiang" , Bob Feng , Liming Gao , Yuwei Chen Subject: [edk2-devel][PATCH] BaseTools: Increase the DevicePath length for support more PCD value. Date: Tue, 16 Nov 2021 09:42:14 +0800 Message-Id: <20211116014214.745-1-xiaolu.jiang@intel.com> X-Mailer: git-send-email 2.30.2.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Currently the PCD Value only support 13 Guid,When use more 13 pcd will caus= e the build tool fail, Need calculate the required memory,then allocate it. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3718 Cc: Bob Feng Cc: Liming Gao Cc: Yuwei Chen Signed-off-by: Xiaolu Jiang --- BaseTools/Source/C/DevicePath/DevicePath.c | 36 +++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/BaseTools/Source/C/DevicePath/DevicePath.c b/BaseTools/Source/= C/DevicePath/DevicePath.c index c4d224ed61..8a0f5f4e2a 100644 --- a/BaseTools/Source/C/DevicePath/DevicePath.c +++ b/BaseTools/Source/C/DevicePath/DevicePath.c @@ -144,6 +144,40 @@ Returns: *UniString =3D '\0';=0D }=0D =0D +=0D +/**=0D + Returns the length of a Null-terminated ASCII string.=0D +=0D + This function returns the number of ASCII characters in the Null-termina= ted=0D + ASCII string specified by String.=0D +=0D + If Length > 0 and Destination is NULL, then ASSERT().=0D + If Length > 0 and Source is NULL, then ASSERT().=0D + If PcdMaximumAsciiStringLength is not zero and String contains more than= =0D + PcdMaximumAsciiStringLength ASCII characters, not including the Null-ter= minator,=0D + then ASSERT().=0D +=0D + @param String A pointer to a Null-terminated ASCII string.=0D +=0D + @return The length of String.=0D +=0D +**/=0D +UINTN=0D +EFIAPI=0D +AsciiStrLen (=0D + IN CONST CHAR8 *String=0D + )=0D +{=0D + UINTN Length;=0D +=0D + ASSERT (String !=3D NULL);=0D +=0D + for (Length =3D 0; *String !=3D '\0'; String++, Length++) {=0D +=0D + }=0D + return Length;=0D +}=0D +=0D int main(int argc, CHAR8 *argv[])=0D {=0D CHAR8 * Str;=0D @@ -170,7 +204,7 @@ int main(int argc, CHAR8 *argv[]) fprintf(stderr, "Invalid option value, Device Path can't be NULL");=0D return STATUS_ERROR;=0D }=0D - Str16 =3D (CHAR16 *)malloc(1024);=0D + Str16 =3D (CHAR16 *)malloc((AsciiStrLen (Str) + 1) * sizeof (CHAR16));=0D if (Str16 =3D=3D NULL) {=0D fprintf(stderr, "Resource, memory cannot be allocated");=0D return STATUS_ERROR;=0D --=20 2.30.2.windows.1