From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) by mx.groups.io with SMTP id smtpd.web09.23311.1611833565922452336 for ; Thu, 28 Jan 2021 03:32:46 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=ilALUssA; spf=pass (domain: nuviainc.com, ip: 209.85.221.43, mailfrom: leif@nuviainc.com) Received: by mail-wr1-f43.google.com with SMTP id p15so5015130wrq.8 for ; Thu, 28 Jan 2021 03:32:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ake8f+fwDZ7ouFD3Jjn5NRjs8nDJXXgMk2twjp8ciA8=; b=ilALUssAeq8ol6gi6Y/iubIzTjUvgre+2GX0LDx+VwRZbBjTl3e5dTNnds9jgqwkYc cosFLxNZU/oYak5ceUC4k1mmcyZjjjrfhZpDawvETDWeodnC5QyeftRtqlSRjfJ/lUNn QO0S/+j+F4i3QmxXqDyvTe/dJLdjVasygvwpCzxHjfugpKU8QFMqd1pGLKEnaoPaNhZc eGAkICequ51j/pb9p0zfkxCkHcFWf0kk8OB7mbYi/hUBoadwQVlWJpYbW9Rfm51col47 3b4M339BXwkuzwFEbUDXJSPkTZrW6xSFumJgSWDZLPCgEIyZk0cRPLP+hiMVsrm+b65t gHRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ake8f+fwDZ7ouFD3Jjn5NRjs8nDJXXgMk2twjp8ciA8=; b=YTieJJhhwM2hgC2w8Uof0UfNgxd73hWUSt6P2KhDDJjSP5QOz1uHvbB0psl53nEZYo lGiID17Gne90SPsZhGdOtgQjtHVOw2OLvqzrPpXYv53xF3TUUiNNJ/g1G1Y8xERWzvBf iMl/fdog5YoTMxHMu9wtjZ0sWB+OYs437h9LZd3ulgs/BQ6VeU6lVS/xvtihQ94Xq0LQ TZP28S6Oknd9FCd2+CbbnLd3bzQ1vYL3RcwtmerGqTRe4GIPqoNiuxtGYOjO4gybO4p+ 57Y0xO9GZSYji+s8riRLQRt9jEiNlUdUfq1Bku4tEFYGcnF/tm3aFJIdnuNxXwV8dZ+d J+rg== X-Gm-Message-State: AOAM5311dIjHBr/Wr7153AlqUfhMv4o7cyAUNBHsAoMPHNem8avLdkvM 9jUZfAGaAHf+RK5IltCWSSjVBg== X-Google-Smtp-Source: ABdhPJyMkekSoPAj3/mvMh3lsPoZYP2M1fFXuB55VtaxrlWR+pYukHa4V4BculFS5JSY0BlOt70L6Q== X-Received: by 2002:adf:d0d2:: with SMTP id z18mr16347510wrh.70.1611833564565; Thu, 28 Jan 2021 03:32:44 -0800 (PST) Return-Path: Received: from vanye (cpc1-cmbg19-2-0-cust915.5-4.cable.virginm.net. [82.27.183.148]) by smtp.gmail.com with ESMTPSA id q6sm5505958wmj.32.2021.01.28.03.32.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jan 2021 03:32:44 -0800 (PST) Date: Thu, 28 Jan 2021 11:32:41 +0000 From: "Leif Lindholm" To: Rebecca Cran Cc: devel@edk2.groups.io, Ard Biesheuvel , nd@arm.com, Sami Mujawar , Liming Gao , Michael D Kinney , Zhiguang Liu , Samer El-Haj-Mahmoud Subject: Re: [PATCH v6 14/22] ArmPkg: Add Universal/Smbios/ProcessorSubClassDxe Message-ID: <20210128113241.GU1664@vanye> References: <20210114163628.31952-1-rebecca@nuviainc.com> <20210114163628.31952-15-rebecca@nuviainc.com> <20210125190417.GE1664@vanye> <6fa39599-5ec0-38f3-6eb0-f857c601fb8a@nuviainc.com> MIME-Version: 1.0 In-Reply-To: <6fa39599-5ec0-38f3-6eb0-f857c601fb8a@nuviainc.com> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. However, it still needs to have the name indicate that it's a macro, so SET_HII_STRING_IF_PCD_NOT_EMPTY. Best Regards, Leif