Reviewed-by: Alexei Fedorov <alexei.fedo...@arm.com>

Alexei

________________________________
From: Sami Mujawar <sami.muja...@arm.com>
Sent: 23 August 2019 11:55
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Sami Mujawar <sami.muja...@arm.com>; Alexei Fedorov 
<alexei.fedo...@arm.com>; ard.biesheu...@linaro.org 
<ard.biesheu...@linaro.org>; leif.lindh...@linaro.org 
<leif.lindh...@linaro.org>; Matteo Carlini <matteo.carl...@arm.com>; nd 
<n...@arm.com>
Subject: [PATCH v1 18/19] ArmPlatformPkg: Fix comparison of constants warning

The VS2017 compiler reports 'warning C6326: potential
comparison of a constant with another constant' when
a fixed PCD value is compared with a constant value.

The faulting code is as marked by '-->' below:

--> if (FixedPcdGet32 (PL011UartInteger) != 0) {
      Integer = FixedPcdGet32 (PL011UartInteger);
      Fractional = FixedPcdGet32 (PL011UartFractional);
    } else {
    ...

The macro FixedPcdGet32 (PL011UartInteger) evaluates
to a macro _PCD_VALUE_PL011UartInteger that is defined
by the build system to represent the UART Integer
value. Therefore, the VS2017 compiler reports the above
warning.

Fix this warning by enclosing the code in appropriate
 #if .. #else .. #endif directives.

Signed-off-by: Sami Mujawar <sami.muja...@arm.com>
---
 ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.c 
b/ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.c
index 
2d3c279cce49304959953ec4a34b50e09a7d0045..dabf099b9bc82e1fb1bd5a2eae3fa4b5878a9e07
 100644
--- a/ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.c
+++ b/ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.c
@@ -174,10 +174,10 @@ PL011UartInitializePort (
   //

   // If PL011 Integer value has been defined then always ignore the BAUD rate
-  if (FixedPcdGet32 (PL011UartInteger) != 0) {
+#if (FixedPcdGet32 (PL011UartInteger) != 0)
     Integer = FixedPcdGet32 (PL011UartInteger);
     Fractional = FixedPcdGet32 (PL011UartFractional);
-  } else {
+#else
     // If BAUD rate is zero then replace it with the system default value
     if (*BaudRate == 0) {
       *BaudRate = FixedPcdGet32 (PcdSerialBaudRate);
@@ -197,7 +197,7 @@ PL011UartInitializePort (
     Divisor = (UINT32)DivisorValue;
     Integer = Divisor >> FRACTION_PART_SIZE_IN_BITS;
     Fractional = Divisor & FRACTION_PART_MASK;
-  }
+#endif

   //
   // If PL011 is already initialized, check the current settings
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'


IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#46285): https://edk2.groups.io/g/devel/message/46285
Mute This Topic: https://groups.io/mt/32999801/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to