]> git.proxmox.com Git - mirror_edk2.git/commitdiff
PcAtChipsetPkg/SerialIoLib: Remove negative value shift
authorMichael Kinney <michael.d.kinney@intel.com>
Wed, 3 May 2017 00:23:22 +0000 (17:23 -0700)
committerMichael Kinney <michael.d.kinney@intel.com>
Fri, 19 May 2017 19:12:06 +0000 (12:12 -0700)
https://bugzilla.tianocore.org/show_bug.cgi?id=553

Remove left shift of negative values that always evaluate
to 0 to address build errors from the llvm/clang compiler
used in the XCODE5 tool chain.

Clang rightfully complains about left-shifting ~DLAB. DLAB is #defined
as 0x01 (an "int"), hence ~DLAB has value (-2) on all edk2 platforms.
Left-shifting a negative int is undefined behavior.

Rather than replacing ~DLAB with ~(UINT32)DLAB, realize that the nonzero
bits of (~(UINT32)DLAB << 7) would all be truncated away in the final
conversion to UINT8 anyway. So just remove (~DLAB << 7).

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
PcAtChipsetPkg/Library/SerialIoLib/SerialPortLib.c

index 95e0db70ad6915872a1b2c8050ad5044b5dc06e6..0a2e20c1d932c0e816621526b5de4443e9668575 100644 (file)
@@ -102,7 +102,7 @@ SerialPortInitialize (
   //\r
   // Switch back to bank 0\r
   //\r
-  OutputData = (UINT8) ((~DLAB << 7) | (gBreakSet << 6) | (gParity << 3) | (gStop << 2) | Data);\r
+  OutputData = (UINT8) ( (gBreakSet << 6) | (gParity << 3) | (gStop << 2) | Data);\r
   IoWrite8 (gUartBase + LCR_OFFSET, OutputData);\r
 \r
   return RETURN_SUCCESS;\r
@@ -481,7 +481,7 @@ SerialPortSetAttributes (
   //\r
   // Switch back to bank 0\r
   //\r
-  OutputData = (UINT8) ((~DLAB << 7) | (gBreakSet << 6) | (LcrParity << 3) | (LcrStop << 2) | LcrData);\r
+  OutputData = (UINT8) ((gBreakSet << 6) | (LcrParity << 3) | (LcrStop << 2) | LcrData);\r
   IoWrite8 (gUartBase + LCR_OFFSET, OutputData);\r
 \r
   return RETURN_SUCCESS;\r