From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.byosoft.com.cn (mail.byosoft.com.cn [58.240.74.242]) by mx.groups.io with SMTP id smtpd.web11.7185.1637766068100040782 for ; Wed, 24 Nov 2021 07:01:13 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=none, err=permanent DNS error (domain: byosoft.com.cn, ip: 58.240.74.242, mailfrom: gaoliming@byosoft.com.cn) Received: from DESKTOPS6D0PVI ([101.224.117.122]) (envelope-sender ) by 192.168.6.13 with ESMTP for ; Wed, 24 Nov 2021 23:01:02 +0800 X-WM-Sender: gaoliming@byosoft.com.cn X-Originating-IP: 101.224.117.122 X-WM-AuthFlag: YES X-WM-AuthUser: gaoliming@byosoft.com.cn From: "gaoliming" To: , Cc: "'Bob Feng'" , "'Yuwei Chen'" References: <20211116014214.745-1-xiaolu.jiang@intel.com> In-Reply-To: <20211116014214.745-1-xiaolu.jiang@intel.com> Subject: =?UTF-8?B?5Zue5aSNOiBbZWRrMi1kZXZlbF1bUEFUQ0hdIEJhc2VUb29sczogSW5jcmVhc2UgdGhlIERldmljZVBhdGggbGVuZ3RoIGZvciBzdXBwb3J0IG1vcmUgUENEIHZhbHVlLg==?= Date: Wed, 24 Nov 2021 23:01:03 +0800 Message-ID: <00a301d7e144$199c7a30$4cd56e90$@byosoft.com.cn> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQKBCKCyujioS3VNkaNPK23iy1e/UqrAdlDw Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Content-Language: zh-cn Xiaolu: BaseTools C source can directly use std libc API. You can use strlen() = to get the length of the input ascii string.=20 With this change, Reviewed-by: Liming Gao Thanks Liming > -----=D3=CA=BC=FE=D4=AD=BC=FE----- > =B7=A2=BC=FE=C8=CB: devel@edk2.groups.io = =B4=FA=B1=ED Xiaolu.Jiang > =B7=A2=CB=CD=CA=B1=BC=E4: 2021=C4=EA11=D4=C216=C8=D5 9:42 > =CA=D5=BC=FE=C8=CB: devel@edk2.groups.io > =B3=AD=CB=CD: Xiaolu.Jiang ; Bob Feng > ; Liming Gao ; Yuwei > Chen > =D6=F7=CC=E2: [edk2-devel][PATCH] BaseTools: Increase the DevicePath = length for > support more PCD value. >=20 > Currently the PCD Value only support 13 Guid,When use more 13 pcd will > cause the build tool fail, > Need calculate the required memory,then allocate it. >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3718 >=20 > Cc: Bob Feng > Cc: Liming Gao > Cc: Yuwei Chen >=20 > Signed-off-by: Xiaolu Jiang > --- > BaseTools/Source/C/DevicePath/DevicePath.c | 36 > +++++++++++++++++++++- > 1 file changed, 35 insertions(+), 1 deletion(-) >=20 > 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'; >=20 > } >=20 >=20 >=20 > + >=20 > +/** >=20 > + Returns the length of a Null-terminated ASCII string. >=20 > + >=20 > + This function returns the number of ASCII characters in the > Null-terminated >=20 > + ASCII string specified by String. >=20 > + >=20 > + If Length > 0 and Destination is NULL, then ASSERT(). >=20 > + If Length > 0 and Source is NULL, then ASSERT(). >=20 > + If PcdMaximumAsciiStringLength is not zero and String contains more than >=20 > + PcdMaximumAsciiStringLength ASCII characters, not including the > Null-terminator, >=20 > + then ASSERT(). >=20 > + >=20 > + @param String A pointer to a Null-terminated ASCII string. >=20 > + >=20 > + @return The length of String. >=20 > + >=20 > +**/ >=20 > +UINTN >=20 > +EFIAPI >=20 > +AsciiStrLen ( >=20 > + IN CONST CHAR8 *String >=20 > + ) >=20 > +{ >=20 > + UINTN Length; >=20 > + >=20 > + ASSERT (String !=3D NULL); >=20 > + >=20 > + for (Length =3D 0; *String !=3D '\0'; String++, Length++) { >=20 > + >=20 > + } >=20 > + return Length; >=20 > +} >=20 > + >=20 > int main(int argc, CHAR8 *argv[]) >=20 > { >=20 > CHAR8 * Str; >=20 > @@ -170,7 +204,7 @@ int main(int argc, CHAR8 *argv[]) > fprintf(stderr, "Invalid option value, Device Path can't be = NULL"); >=20 > return STATUS_ERROR; >=20 > } >=20 > - Str16 =3D (CHAR16 *)malloc(1024); >=20 > + Str16 =3D (CHAR16 *)malloc((AsciiStrLen (Str) + 1) * sizeof = (CHAR16)); >=20 > if (Str16 =3D=3D NULL) { >=20 > fprintf(stderr, "Resource, memory cannot be allocated"); >=20 > return STATUS_ERROR; >=20 > -- > 2.30.2.windows.1 >=20 >=20 >=20 > -=3D-=3D-=3D-=3D-=3D-=3D > Groups.io Links: You receive all messages sent to this group. > View/Reply Online (#83769): = https://edk2.groups.io/g/devel/message/83769 > Mute This Topic: https://groups.io/mt/87089392/4905953 > Group Owner: devel+owner@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub > [gaoliming@byosoft.com.cn] > -=3D-=3D-=3D-=3D-=3D-=3D >=20