From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.groups.io with SMTP id smtpd.web11.23096.1611834368971860164 for ; Thu, 28 Jan 2021 03:46:09 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EWabPRgD; spf=pass (domain: redhat.com, ip: 63.128.21.124, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611834367; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SK3YWJ5JNM/j8oOmzGeVB7KemP85cu2HD4ybaI6/+JM=; b=EWabPRgDcSgRAYwiSBOfobnFVfY0+mxrg9m7/gEjgQscrKissSZC+xh2lHuwDL60WeW641 FzDgLa0b/bA+b62uhX7Bi16z46wUwUc+Il4Dl/BVTlPDgMs5gWm+CXWKlsA7PJXymcXc7s AtVqxc/b9NIRbMdFFopSvFa0uqSoojw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-404-iymww9qSP22jT4CO1DiPyw-1; Thu, 28 Jan 2021 06:46:03 -0500 X-MC-Unique: iymww9qSP22jT4CO1DiPyw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AA2E6806715; Thu, 28 Jan 2021 11:45:55 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-115-247.ams2.redhat.com [10.36.115.247]) by smtp.corp.redhat.com (Postfix) with ESMTP id 604AF5D9EF; Thu, 28 Jan 2021 11:45:53 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH v6 14/22] ArmPkg: Add Universal/Smbios/ProcessorSubClassDxe To: devel@edk2.groups.io, leif@nuviainc.com, Rebecca Cran Cc: Ard Biesheuvel , nd@arm.com, Sami Mujawar , Liming Gao , Michael D Kinney , Zhiguang Liu , Samer El-Haj-Mahmoud References: <20210114163628.31952-1-rebecca@nuviainc.com> <20210114163628.31952-15-rebecca@nuviainc.com> <20210125190417.GE1664@vanye> <6fa39599-5ec0-38f3-6eb0-f857c601fb8a@nuviainc.com> <20210128113241.GU1664@vanye> From: "Laszlo Ersek" Message-ID: <03d6bf14-1baf-2f3c-0d94-797049257714@redhat.com> Date: Thu, 28 Jan 2021 12:45:52 +0100 MIME-Version: 1.0 In-Reply-To: <20210128113241.GU1664@vanye> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lersek@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 01/28/21 12:32, Leif Lindholm wrote: > On Wed, Jan 27, 2021 at 21:53:57 -0700, Rebecca Cran wrote: >> 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); \ >> } \ >> } > > I'm mostly OK with that. I'd say it technically violates the coding > style because of assigning a value to Str on definition, but I can't > convince myself to care about that for a macro. It wouldn't be hard to fix. > > However, it still needs to have the name indicate that it's a macro, > so SET_HII_STRING_IF_PCD_NOT_EMPTY. A "do { ... } while (0)" around the whole thing is missing as well. Laszlo