Cache size of ASCII string in local variable.
Cc: Nickle Wang <[email protected]>
Cc: Igor Kulchytskyy <[email protected]>
Signed-off-by: Mike Maslenkin <[email protected]>
Reviewed-by: Abner Chang <[email protected]>
---
.../RedfishDiscoverDxe/RedfishDiscoverDxe.c | 34 ++++++++++++-------
1 file changed, 21 insertions(+), 13 deletions(-)
diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
index 0ac41f09559b..76f87e4fe5e7 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
@@ -738,39 +738,47 @@ InitInformationData (
IN CONST CHAR8 *ProductVer OPTIONAL
)
{
+ UINTN AllocationSize;
+
if (RedfishVersion != NULL) {
Information->RedfishVersion = *RedfishVersion;
DEBUG ((DEBUG_MANAGEABILITY, "Redfish service version: %d.\n",
Information->RedfishVersion));
}
if (RedfishLocation != NULL) {
- Information->Location = AllocatePool (AsciiStrSize (RedfishLocation) *
sizeof (CHAR16));
- AsciiStrToUnicodeStrS (RedfishLocation, Information->Location,
AsciiStrSize (RedfishLocation) * sizeof (CHAR16));
+ AllocationSize = AsciiStrSize (RedfishLocation) * sizeof (CHAR16);
+ Information->Location = AllocatePool (AllocationSize);
+ AsciiStrToUnicodeStrS (RedfishLocation, Information->Location,
AllocationSize);
DEBUG ((DEBUG_MANAGEABILITY, "Redfish service location: %s.\n",
Information->Location));
}
if (Uuid != NULL) {
- Information->Uuid = AllocatePool (AsciiStrSize (Uuid) * sizeof (CHAR16));
- AsciiStrToUnicodeStrS (Uuid, Information->Uuid, AsciiStrSize (Uuid) *
sizeof (CHAR16));
+ AllocationSize = AsciiStrSize (Uuid) * sizeof (CHAR16);
+ Information->Uuid = AllocatePool (AllocationSize);
+ AsciiStrToUnicodeStrS (Uuid, Information->Uuid, AllocationSize);
DEBUG ((DEBUG_MANAGEABILITY, "Service UUID: %s.\n", Information->Uuid));
}
if (Os != NULL) {
- Information->Os = AllocatePool (AsciiStrSize (Os) * sizeof (CHAR16));
- AsciiStrToUnicodeStrS (Os, Information->Os, AsciiStrSize (Os) * sizeof
(CHAR16));
- DEBUG ((DEBUG_MANAGEABILITY, "Redfish service OS: %s, Version:%s.\n",
Information->Os, Information->OsVersion));
+ AllocationSize = AsciiStrSize (Os) * sizeof (CHAR16);
+ Information->Os = AllocatePool (AllocationSize);
+ AsciiStrToUnicodeStrS (Os, Information->Os, AllocationSize);
}
if (OsVer != NULL) {
- Information->OsVersion = AllocatePool (AsciiStrSize (OsVer) * sizeof
(CHAR16));
- AsciiStrToUnicodeStrS (OsVer, Information->OsVersion, AsciiStrSize (OsVer)
* sizeof (CHAR16));
+ AllocationSize = AsciiStrSize (OsVer) * sizeof (CHAR16);
+ Information->OsVersion = AllocatePool (AllocationSize);
+ AsciiStrToUnicodeStrS (OsVer, Information->OsVersion, AllocationSize);
+ DEBUG ((DEBUG_MANAGEABILITY, "Redfish service OS: %s, Version:%s.\n",
Information->Os, Information->OsVersion));
}
if ((Product != NULL) && (ProductVer != NULL)) {
- Information->Product = AllocatePool (AsciiStrSize (Product) * sizeof
(CHAR16));
- AsciiStrToUnicodeStrS (Product, Information->Product, AsciiStrSize
(Product) * sizeof (CHAR16));
- Information->ProductVer = AllocatePool (AsciiStrSize (ProductVer) * sizeof
(CHAR16));
- AsciiStrToUnicodeStrS (ProductVer, Information->ProductVer, AsciiStrSize
(ProductVer) * sizeof (CHAR16));
+ AllocationSize = AsciiStrSize (Product) * sizeof (CHAR16);
+ Information->Product = AllocatePool (AllocationSize);
+ AsciiStrToUnicodeStrS (Product, Information->Product, AllocationSize);
+ AllocationSize = AsciiStrSize (ProductVer) * sizeof (CHAR16);
+ Information->ProductVer = AllocatePool (AllocationSize);
+ AsciiStrToUnicodeStrS (ProductVer, Information->ProductVer,
AllocationSize);
DEBUG ((DEBUG_MANAGEABILITY, "Redfish service product: %s, Version:%s.\n",
Information->Product, Information->ProductVer));
}
}
--
2.32.0 (Apple Git-132)
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112871): https://edk2.groups.io/g/devel/message/112871
Mute This Topic: https://groups.io/mt/103354131/21656
Group Owner: [email protected]
Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-