Re: [PATCH] BaseTools/VolInfo: Correct EFI_SECTION_VERSION display


Bob Feng
 

Reviewed-by: Bob Feng <bob.c.feng@...>

-----Original Message-----
From: Konstantin Aladyshev <aladyshev22@...>
Sent: Monday, July 18, 2022 5:44 PM
To: devel@edk2.groups.io
Cc: Feng, Bob C <bob.c.feng@...>; Gao, Liming <gaoliming@...>; Chen, Christine <yuwei.chen@...>; Konstantin Aladyshev <aladyshev22@...>
Subject: [PATCH] BaseTools/VolInfo: Correct EFI_SECTION_VERSION display

- Correct typo in print statement,
- "BuildNumber" field is UINT16, therefore it needs "0x%04X" format modifier,
- "VersionString" field is CHAR16, therefore the input data should be processed to be displayed with "%s" printf modifier.

Signed-off-by: Konstantin Aladyshev <aladyshev22@...>
---
BaseTools/Source/C/VolInfo/VolInfo.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/C/VolInfo/VolInfo.c b/BaseTools/Source/C/VolInfo/VolInfo.c
index 8b6fcffa48..ed56587058 100644
--- a/BaseTools/Source/C/VolInfo/VolInfo.c
+++ b/BaseTools/Source/C/VolInfo/VolInfo.c
@@ -1676,6 +1676,7 @@ Returns:
CHAR8 *ToolInputFileName; CHAR8 *ToolOutputFileName; CHAR8 *UIFileName;+ CHAR8 *VersionString; ParsedLength = 0; ToolInputFileName = NULL;@@ -1816,8 +1817,14 @@ Returns:
break; case EFI_SECTION_VERSION:- printf (" Build Number: 0x%02X\n", *(UINT16 *)(Ptr + SectionHeaderLen));- printf (" Version Strg: %s\n", (char*) (Ptr + SectionHeaderLen + sizeof (UINT16)));+ printf (" Build Number: 0x%04X\n", *(UINT16 *)(Ptr + SectionHeaderLen));+ VersionString = (CHAR8 *) malloc (UnicodeStrLen (((EFI_VERSION_SECTION *) Ptr)->VersionString) + 1);+ if (VersionString == NULL) {+ Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");+ return EFI_OUT_OF_RESOURCES;+ }+ Unicode2AsciiString (((EFI_VERSION_SECTION *) Ptr)->VersionString, VersionString);+ printf (" Version String: %s\n", VersionString); break; case EFI_SECTION_COMPRESSION:--
2.25.1

Join devel@edk2.groups.io to automatically receive all group messages.