diff options
author | Mike Maslenkin <mike.maslenkin@gmail.com> | 2023-12-14 03:18:57 +0300 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2023-12-27 00:09:49 +0000 |
commit | d1c21f8d557f01cd82e06d6b9b6900dec8e6b373 (patch) | |
tree | e330a50d1cff551e87cedf6bcb2347b895753c73 | |
parent | 17870bf3f5f9440bd860e15f1f500d5a5b9e0b7d (diff) | |
download | edk2-d1c21f8d557f01cd82e06d6b9b6900dec8e6b373.tar.gz edk2-d1c21f8d557f01cd82e06d6b9b6900dec8e6b373.tar.bz2 edk2-d1c21f8d557f01cd82e06d6b9b6900dec8e6b373.zip |
RedfishDiscoverDxe: refine InitInformationData() function
Cache size of ASCII string in local variable.
Cc: Nickle Wang <nicklew@nvidia.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Signed-off-by: Mike Maslenkin <mike.maslenkin@gmail.com>
Reviewed-by: Abner Chang <abner.chang@amd.com>
-rw-r--r-- | RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c index 7260efe6ad..e673de8ef7 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));
}
}
|