public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Laszlo Ersek" <lersek@redhat.com>
To: Tom Lendacky <thomas.lendacky@amd.com>, devel@edk2.groups.io
Cc: Liming Gao <liming.gao@intel.com>,
	Eric Dong <eric.dong@intel.com>, Ray Ni <ray.ni@intel.com>,
	Rahul Kumar <rahul1.kumar@intel.com>
Subject: Re: [PATCH 1/1] UefiCpuPkg/MpInitLib: Always initialize the DoDecrement variable
Date: Wed, 19 Aug 2020 11:24:29 +0200	[thread overview]
Message-ID: <fa1f41c3-1efe-b7c2-eada-9c73185953b0@redhat.com> (raw)
In-Reply-To: <477f5449c898cd96240729105dde26b1fd75baa9.1597756206.git.thomas.lendacky@amd.com>

On 08/18/20 15:10, Tom Lendacky wrote:
> From: Tom Lendacky <thomas.lendacky@amd.com>
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2901
> 
> The DoDecrement variable in ApWakeupFunction () wasn't always being
> initialized. Update the code to always fully initialize it.
> 
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Rahul Kumar <rahul1.kumar@intel.com>
> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
> ---
>  UefiCpuPkg/Library/MpInitLib/MpLib.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> index 90416c81b616..e24bdc64f930 100644
> --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
> +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
> @@ -885,9 +885,7 @@ ApWakeupFunction (
>            UINT64                    Status;
>            BOOLEAN                   DoDecrement;
>  
> -          if (CpuMpData->InitFlag == ApInitConfig) {
> -            DoDecrement = TRUE;
> -          }
> +          DoDecrement = (CpuMpData->InitFlag == ApInitConfig) ? TRUE : FALSE;
>  
>            while (TRUE) {
>              Msr.GhcbPhysicalAddress = AsmReadMsr64 (MSR_SEV_ES_GHCB);
> 

Not that I want to obsess about style, but

  (condition) ? TRUE : FALSE

is an anti-patter that's similar to

  (condition) == TRUE

Instead, I suggest:

  DoDecrement = (BOOLEAN)(CpuMpData->InitFlag == ApInitConfig);

(The (BOOLEAN) cast is necessary, or at least used to be necessary,
becasue the == operator returns "int" (INT32), but BOOLEAN (i.e., the
type of "DoDecrement") is UINT8 -- and some VS toolchains perceive (or
used to perceive) this implicit conversion as a "potential loss of
precision". That warning is of course bogus, as the == operator only
produces 0 or 1, each of which values fits comfortably into a UINT8. But
still the explicit (BOOLEAN) cast is how we suppress the warning.)

Different question: who's supposed to merge (v2 of) this? Per
"Maintainers.txt", it should be Eric or Ray; OTOH, maybe the fix is
urgent (build failure with CLANGPDB) and anyone with push access could
qualify.

Thanks,
Laszlo


  parent reply	other threads:[~2020-08-19  9:24 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-18 13:10 [PATCH 1/1] UefiCpuPkg/MpInitLib: Always initialize the DoDecrement variable Lendacky, Thomas
2020-08-19  7:08 ` Liming Gao
2020-08-20 14:52   ` Lendacky, Thomas
2020-08-19  9:24 ` Laszlo Ersek [this message]
2020-08-19 14:45   ` [edk2-devel] " Liming Gao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fa1f41c3-1efe-b7c2-eada-9c73185953b0@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox