On Fri, Aug 23, 2019 at 11:55:38 +0100, Sami Mujawar wrote:
> 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 <[email protected]>
Reviewed-by: Leif Lindholm <[email protected]>
> ---
> 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)'
>
>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#51056): https://edk2.groups.io/g/devel/message/51056
Mute This Topic: https://groups.io/mt/32999801/21656
Group Owner: [email protected]
Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-