[edk2-devel] [PATCH v6 14/22] ArmPkg: Add Universal/Smbios/ProcessorSubClassDxe
Rebecca Cran
rebecca at nuviainc.com
Thu Jan 28 04:53:57 UTC 2021
On 1/25/21 12:04 PM, Leif Lindholm wrote:
> On Thu, Jan 14, 2021 at 09:36:20 -0700, Rebecca Cran wrote:
>> +// Sets the HII variable `x` if `pcd` isn't empty
>> +#define SET_HII_STRING_IF_PCD_NOT_EMPTY(pcd, x) \
>> + x##Str = (CHAR16 *)PcdGetPtr (pcd); \
>> + if (StrLen (x##Str) > 0) { \
>> + HiiSetString (mHiiHandle, x, x##Str, NULL); \
>> + } \
>
> I am not a fan of preprocessor macros that require local variables
> with magic names to exist.
> Can this be rewritten as a helper function?
Unfortunately PcdGetPtr uses token pasting, so a helper function won't work.
Would the following be better?
#define SetHiiStringIfPcdNotEmpty(Pcd, StringId) { \
CHAR16 *Str = (CHAR16*)PcdGetPtr (Pcd); \
if (StrLen (Str) > 0) { \
HiiSetString (mHiiHandle, StringId, Str, NULL); \
} \
}
--
Rebecca Cran
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#70840): https://edk2.groups.io/g/devel/message/70840
Mute This Topic: https://groups.io/mt/79679256/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list