From: Xiaolu.jiang@intel.com
To: devel@edk2.groups.io
Cc: "Xiaolu.Jiang" <xiaolu.jiang@intel.com>,
Bob Feng <bob.c.feng@intel.com>,
Liming Gao <gaoliming@byosoft.com.cn>,
Yuwei Chen <yuwei.chen@intel.com>
Subject: [edk2-devel][PATCH] BaseTools: Increase the DevicePath length for support more PCD value.
Date: Tue, 16 Nov 2021 09:42:14 +0800 [thread overview]
Message-ID: <20211116014214.745-1-xiaolu.jiang@intel.com> (raw)
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.
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3718
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Signed-off-by: Xiaolu Jiang <xiaolu.jiang@intel.com>
---
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 = '\0';
}
+
+/**
+ Returns the length of a Null-terminated ASCII string.
+
+ This function returns the number of ASCII characters in the Null-terminated
+ ASCII string specified by String.
+
+ If Length > 0 and Destination is NULL, then ASSERT().
+ If Length > 0 and Source is NULL, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero and String contains more than
+ PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
+ then ASSERT().
+
+ @param String A pointer to a Null-terminated ASCII string.
+
+ @return The length of String.
+
+**/
+UINTN
+EFIAPI
+AsciiStrLen (
+ IN CONST CHAR8 *String
+ )
+{
+ UINTN Length;
+
+ ASSERT (String != NULL);
+
+ for (Length = 0; *String != '\0'; String++, Length++) {
+
+ }
+ return Length;
+}
+
int main(int argc, CHAR8 *argv[])
{
CHAR8 * Str;
@@ -170,7 +204,7 @@ int main(int argc, CHAR8 *argv[])
fprintf(stderr, "Invalid option value, Device Path can't be NULL");
return STATUS_ERROR;
}
- Str16 = (CHAR16 *)malloc(1024);
+ Str16 = (CHAR16 *)malloc((AsciiStrLen (Str) + 1) * sizeof (CHAR16));
if (Str16 == NULL) {
fprintf(stderr, "Resource, memory cannot be allocated");
return STATUS_ERROR;
--
2.30.2.windows.1
next reply other threads:[~2021-11-16 1:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-16 1:42 Xiaolu.jiang [this message]
2021-11-16 12:46 ` [edk2-devel][PATCH] BaseTools: Increase the DevicePath length for support more PCD value Bob Feng
2021-11-24 15:01 ` 回复: " gaoliming
-- strict thread matches above, loose matches on Subject: below --
2021-11-29 2:13 Xiaolu.Jiang
2021-11-29 5:04 ` 回复: " gaoliming
2021-12-09 0:10 ` Bob Feng
[not found] <20211108082136.2707-1-xiaolu.jiang@intel.com>
2021-11-10 2:59 ` FW: " Jiang, Xiaolu
2021-11-12 6:59 ` Jiang, Xiaolu
[not found] <20211106035056.183-1-xiaolu.jiang@intel.com>
2021-11-08 1:14 ` 回复: " gaoliming
2021-11-08 1:24 ` Jiang, Xiaolu
2021-11-08 2:26 ` Jiang, Xiaolu
2021-11-08 2:30 ` Bob Feng
2021-11-08 3:17 ` 回复: " gaoliming
2021-11-08 3:20 ` Jiang, Xiaolu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211116014214.745-1-xiaolu.jiang@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox