public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Fan, Jeff" <jeff.fan@intel.com>
To: "Marvin Häuser" <Marvin.Haeuser@outlook.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: [PATCH] UefiCpuPkg: Add BOOLEAN casts to return statements.
Date: Wed, 26 Jul 2017 02:44:41 +0000	[thread overview]
Message-ID: <542CF652F8836A4AB8DBFAAD40ED192A4C62E55C@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <AM4PR06MB14916E86F309FE9AF1955B9280A40@AM4PR06MB1491.eurprd06.prod.outlook.com>

Marvin,

Could you tell what VS version you are using?

Jeff

-----Original Message-----
From: Marvin Häuser [mailto:Marvin.Haeuser@outlook.com] 
Sent: Friday, July 21, 2017 6:20 PM
To: edk2-devel@lists.01.org
Cc: Fan, Jeff
Subject: [PATCH] UefiCpuPkg: Add BOOLEAN casts to return statements.

Old versions of the Visual Studio C compiler return a value of type 'int' for comparisons, which is what the C99 standard defines in the sections 6.5.8 and 6.5.9. When the result of a comparison is returned, int is implicitely casted to BOOLEAN, which is smaller, and hence a warning about a possible loss of data is generated. This patch adds casts to BOOLEAN where necessary to silence these.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Marvin Haeuser <Marvin.Haeuser@outlook.com>
---
 UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c                     | 8 ++++----
 UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c         | 8 ++++----
 UefiCpuPkg/Library/CpuCommonFeaturesLib/Aesni.c                    | 2 +-
 UefiCpuPkg/Library/CpuCommonFeaturesLib/C1e.c                      | 2 +-
 UefiCpuPkg/Library/CpuCommonFeaturesLib/ClockModulation.c          | 2 +-
 UefiCpuPkg/Library/CpuCommonFeaturesLib/Eist.c                     | 2 +-
 UefiCpuPkg/Library/CpuCommonFeaturesLib/ExecuteDisable.c           | 2 +-
 UefiCpuPkg/Library/CpuCommonFeaturesLib/FeatureControl.c           | 4 ++--
 UefiCpuPkg/Library/CpuCommonFeaturesLib/LimitCpuIdMaxval.c         | 2 +-
 UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c             | 6 +++---
 UefiCpuPkg/Library/CpuCommonFeaturesLib/MonitorMwait.c             | 2 +-
 UefiCpuPkg/Library/CpuCommonFeaturesLib/PendingBreak.c             | 2 +-
 UefiCpuPkg/Library/CpuCommonFeaturesLib/Ppin.c                     | 2 +-
 UefiCpuPkg/Library/CpuCommonFeaturesLib/X2Apic.c                   | 2 +-
 UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c | 2 +-
 15 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c
index 2091e5e2d0dd..55aee6c607f7 100644
--- a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c
+++ b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c
@@ -3,7 +3,7 @@
 
   This local APIC library instance supports xAPIC mode only.
 
-  Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2010 - 2017, Intel Corporation. All rights 
+ reserved.<BR>
   Copyright (c) 2017, AMD Inc. All rights reserved.<BR>
 
   This program and the accompanying materials @@ -49,9 +49,9 @@ StandardSignatureIsAuthenticAMD (
   UINT32  RegEdx;
 
   AsmCpuid(CPUID_SIGNATURE, NULL, &RegEbx, &RegEcx, &RegEdx);
-  return (RegEbx == CPUID_SIGNATURE_AUTHENTIC_AMD_EBX &&
-          RegEcx == CPUID_SIGNATURE_AUTHENTIC_AMD_ECX &&
-          RegEdx == CPUID_SIGNATURE_AUTHENTIC_AMD_EDX);
+  return (BOOLEAN)(RegEbx == CPUID_SIGNATURE_AUTHENTIC_AMD_EBX &&
+                   RegEcx == CPUID_SIGNATURE_AUTHENTIC_AMD_ECX &&
+                   RegEdx == CPUID_SIGNATURE_AUTHENTIC_AMD_EDX);
 }
 
 /**
diff --git a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
index d5d4efaeb408..bfd5acceebfa 100644
--- a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
+++ b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
@@ -4,7 +4,7 @@
   This local APIC library instance supports x2APIC capable processors
   which have xAPIC and x2APIC modes.
 
-  Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2010 - 2017, Intel Corporation. All rights 
+ reserved.<BR>
   Copyright (c) 2017, AMD Inc. All rights reserved.<BR>
 
   This program and the accompanying materials @@ -50,9 +50,9 @@ StandardSignatureIsAuthenticAMD (
   UINT32  RegEdx;
 
   AsmCpuid(CPUID_SIGNATURE, NULL, &RegEbx, &RegEcx, &RegEdx);
-  return (RegEbx == CPUID_SIGNATURE_AUTHENTIC_AMD_EBX &&
-          RegEcx == CPUID_SIGNATURE_AUTHENTIC_AMD_ECX &&
-          RegEdx == CPUID_SIGNATURE_AUTHENTIC_AMD_EDX);
+  return (BOOLEAN)(RegEbx == CPUID_SIGNATURE_AUTHENTIC_AMD_EBX &&
+                   RegEcx == CPUID_SIGNATURE_AUTHENTIC_AMD_ECX &&
+                   RegEdx == CPUID_SIGNATURE_AUTHENTIC_AMD_EDX);
 }
 
 /**
diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/Aesni.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/Aesni.c
index 178bfb50abcf..df0f56ab9d82 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/Aesni.c
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/Aesni.c
@@ -69,7 +69,7 @@ AesniSupport (
       IS_XEON_PHI_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) {
     MsrFeatureConfig = (MSR_SANDY_BRIDGE_FEATURE_CONFIG_REGISTER *) ConfigData;
     MsrFeatureConfig[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_SANDY_BRIDGE_FEATURE_CONFIG);
-    return (CpuInfo->CpuIdVersionInfoEcx.Bits.AESNI == 1);
+    return (BOOLEAN)(CpuInfo->CpuIdVersionInfoEcx.Bits.AESNI == 1);
   }
   return FALSE;
 }
diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/C1e.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/C1e.c
index 47116355a8ff..00ebc5c9a19e 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/C1e.c
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/C1e.c
@@ -38,7 +38,7 @@ C1eSupport (
   IN VOID                              *ConfigData  OPTIONAL
   )
 {
-  return IS_NEHALEM_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel);
+  return (BOOLEAN)IS_NEHALEM_PROCESSOR (CpuInfo->DisplayFamily, 
+ CpuInfo->DisplayModel);
 }
 
 /**
diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/ClockModulation.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/ClockModulation.c
index 56e53561e9de..e625b061829f 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/ClockModulation.c
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/ClockModulation.c
@@ -38,7 +38,7 @@ ClockModulationSupport (
   IN VOID                              *ConfigData  OPTIONAL
   )
 {
-  return (CpuInfo->CpuIdVersionInfoEdx.Bits.ACPI == 1);
+  return (BOOLEAN)(CpuInfo->CpuIdVersionInfoEdx.Bits.ACPI == 1);
 }
 
 /**
diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/Eist.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/Eist.c
index 2038171a14c3..593a1e1b35b5 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/Eist.c
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/Eist.c
@@ -38,7 +38,7 @@ EistSupport (
   IN VOID                              *ConfigData  OPTIONAL
   )
 {
-  return (CpuInfo->CpuIdVersionInfoEcx.Bits.EIST == 1);
+  return (BOOLEAN)(CpuInfo->CpuIdVersionInfoEcx.Bits.EIST == 1);
 }
 
 /**
diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/ExecuteDisable.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/ExecuteDisable.c
index 921656a1e869..1ba942990113 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/ExecuteDisable.c
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/ExecuteDisable.c
@@ -50,7 +50,7 @@ ExecuteDisableSupport (
   }
 
   AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, &Edx.Uint32);
-  return (Edx.Bits.NX != 0);
+  return (BOOLEAN)(Edx.Bits.NX != 0);
 }
 
 /**
diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/FeatureControl.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/FeatureControl.c
index d28c4ec51a04..fae09d8be711 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/FeatureControl.c
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/FeatureControl.c
@@ -65,7 +65,7 @@ VmxSupport (
   ASSERT (ConfigData != NULL);
   MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData;
   MsrRegister[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_IA32_FEATURE_CONTROL);
-  return (CpuInfo->CpuIdVersionInfoEcx.Bits.VMX == 1);
+  return (BOOLEAN)(CpuInfo->CpuIdVersionInfoEcx.Bits.VMX == 1);
 }
 
 /**
@@ -215,7 +215,7 @@ SmxSupport (
   ASSERT (ConfigData != NULL);
   MsrRegister = (MSR_IA32_FEATURE_CONTROL_REGISTER *) ConfigData;
   MsrRegister[ProcessorNumber].Uint64 = AsmReadMsr64 (MSR_IA32_FEATURE_CONTROL);
-  return (CpuInfo->CpuIdVersionInfoEcx.Bits.SMX == 1);
+  return (BOOLEAN)(CpuInfo->CpuIdVersionInfoEcx.Bits.SMX == 1);
 }
 
 /**
diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/LimitCpuIdMaxval.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/LimitCpuIdMaxval.c
index 40cc9d5fe0cf..ee037c35dc5a 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/LimitCpuIdMaxval.c
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/LimitCpuIdMaxval.c
@@ -41,7 +41,7 @@ LimitCpuidMaxvalSupport (
   UINT32  Eax;
 
   AsmCpuid (CPUID_SIGNATURE, &Eax, NULL, NULL, NULL);
-  return (Eax > 3);
+  return (BOOLEAN)(Eax > 3);
 }
 
 /**
diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c
index 72f665d32e36..0e3b3468d7bc 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c
@@ -38,7 +38,7 @@ MceSupport (
   IN VOID                              *ConfigData  OPTIONAL
   )
 {
-  return (CpuInfo->CpuIdVersionInfoEdx.Bits.MCE == 1);
+  return (BOOLEAN)(CpuInfo->CpuIdVersionInfoEdx.Bits.MCE == 1);
 }
 
 /**
@@ -105,7 +105,7 @@ McaSupport (
   IN VOID                              *ConfigData  OPTIONAL
   )
 {
-  return (CpuInfo->CpuIdVersionInfoEdx.Bits.MCA == 1);
+  return (BOOLEAN)(CpuInfo->CpuIdVersionInfoEdx.Bits.MCA == 1);
 }
 
 /**
@@ -191,7 +191,7 @@ McgCtlSupport (
     return FALSE;
   }
   McgCap.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_CAP);
-  return (McgCap.Bits.MCG_CTL_P == 1);
+  return (BOOLEAN)(McgCap.Bits.MCG_CTL_P == 1);
 }
 
 /**
diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/MonitorMwait.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/MonitorMwait.c
index 1d43bd128afe..67aaf37d4e3d 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/MonitorMwait.c
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/MonitorMwait.c
@@ -38,7 +38,7 @@ MonitorMwaitSupport (
   IN VOID                              *ConfigData  OPTIONAL
   )
 {
-  return (CpuInfo->CpuIdVersionInfoEcx.Bits.MONITOR == 1);
+  return (BOOLEAN)(CpuInfo->CpuIdVersionInfoEcx.Bits.MONITOR == 1);
 }
 
 /**
diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/PendingBreak.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/PendingBreak.c
index 8cafba4f4a87..5df2ef15ddcf 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/PendingBreak.c
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/PendingBreak.c
@@ -43,7 +43,7 @@ PendingBreakSupport (
       IS_CORE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
       IS_PENTIUM_4_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
       IS_PENTIUM_M_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) {
-    return (CpuInfo->CpuIdVersionInfoEdx.Bits.PBE == 1);
+    return (BOOLEAN)(CpuInfo->CpuIdVersionInfoEdx.Bits.PBE == 1);
   }
   return FALSE;
 }
diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/Ppin.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/Ppin.c
index 146c4cfda3f9..438578a83230 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/Ppin.c
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/Ppin.c
@@ -53,7 +53,7 @@ PpinSupport (
     // Check whether platform support this feature.
     //
     PlatformInfo.Uint64 = AsmReadMsr64 (MSR_IVY_BRIDGE_PLATFORM_INFO_1);
-    return (PlatformInfo.Bits.PPIN_CAP != 0);
+    return (BOOLEAN)(PlatformInfo.Bits.PPIN_CAP != 0);
   }
 
   return FALSE;
diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/X2Apic.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/X2Apic.c
index b4a453c3525c..ecaf47a4af00 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/X2Apic.c
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/X2Apic.c
@@ -71,7 +71,7 @@ X2ApicSupport (
   //
   X2ApicEnabled[ProcessorNumber] = (GetApicMode () == LOCAL_APIC_MODE_X2APIC) ? TRUE : FALSE;
 
-  return (CpuInfo->CpuIdVersionInfoEcx.Bits.x2APIC == 1);
+  return (BOOLEAN)(CpuInfo->CpuIdVersionInfoEcx.Bits.x2APIC == 1);
 }
 
 /**
diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c
index 338f1a495cf4..c093356ab150 100644
--- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c
+++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeaturesLib.c
@@ -650,7 +650,7 @@ IsCpuFeatureSetInCpuPcd (
   if ((Feature >> 3) >= CpuBitMaskSize) {
     return FALSE;
   }
-  return ((*(CpuBitMask + (Feature >> 3)) & (1 << (Feature & 0x07))) != 0);
+  return (BOOLEAN)((*(CpuBitMask + (Feature >> 3)) & (1 << (Feature & 
+ 0x07))) != 0);
 }
 
 /**
--
2.12.2.windows.2



  reply	other threads:[~2017-07-26  2:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-21 10:20 [PATCH] UefiCpuPkg: Add BOOLEAN casts to return statements Marvin Häuser
2017-07-26  2:44 ` Fan, Jeff [this message]
2017-07-26  8:36   ` Marvin Häuser
2017-07-27 13:17     ` Gao, Liming
2017-07-27 13:41       ` Marvin Häuser

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=542CF652F8836A4AB8DBFAAD40ED192A4C62E55C@shsmsx102.ccr.corp.intel.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