Add a new helper macro which is a wrapper over StringTableAddString(). It adds a string to the string table, and if the string is NULL or empty, add "" string instead.
Signed-off-by: Dat Mach <dm...@nvidia.com> Signed-off-by: Nick Ramirez <nrami...@nvidia.com> Signed-off-by: Girish Mahadevan <gmahade...@nvidia.com> --- .../Include/Library/SmbiosStringTableLib.h | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/DynamicTablesPkg/Include/Library/SmbiosStringTableLib.h b/DynamicTablesPkg/Include/Library/SmbiosStringTableLib.h index fb183d427f..b95d83f457 100644 --- a/DynamicTablesPkg/Include/Library/SmbiosStringTableLib.h +++ b/DynamicTablesPkg/Include/Library/SmbiosStringTableLib.h @@ -2,6 +2,7 @@ SMBIOS String Table Helper library. Copyright (c) 2022, Arm Limited. All rights reserved.<BR> + SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -116,4 +117,23 @@ StringTableFree ( IN STRING_TABLE *CONST StrTable ); +/** STRING_TABLE_ADD_STRING macro is the wrapper over StringTableAddString(). + It adds a string to the string table, and if the string is NULL or empty, + add "" string instead. + + @param [IN] StrTable Pointer to the string table + @param [IN] Str Pointer to the string + @param [OUT] StrRef The string field reference of the added string +**/ +#define STRING_TABLE_ADD_STRING(StrTable, String, StringRef) \ + StringRef = 0; \ + if ((String != NULL) && (String[0] != '\0')) { \ + Status = StringTableAddString (&StrTable, String, &StringRef); \ + } else { \ + Status = StringTableAddString (&StrTable, "", &StringRef); \ + } \ + if (EFI_ERROR (Status)) { \ + DEBUG ((DEBUG_ERROR, "Failed to add "#String" string %r\n", Status)); \ + } \ + #endif // SMBIOS_STRING_TABLE_H_ -- 2.25.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#121084): https://edk2.groups.io/g/devel/message/121084 Mute This Topic: https://groups.io/mt/111022000/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-