From: Michael Kinney Date: Wed, 3 May 2017 00:23:22 +0000 (-0700) Subject: PcAtChipsetPkg/SerialIoLib: Remove negative value shift X-Git-Tag: edk2-stable201903~4015 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=bbd61de5dbc6ad146dc7250e9646cb662604b5f3;hp=da0df6ca8f8f118866e53c7fb770598c199993a6 PcAtChipsetPkg/SerialIoLib: Remove negative value shift 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 Cc: Andrew Fish Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Michael D Kinney Reviewed-by: Laszlo Ersek --- diff --git a/PcAtChipsetPkg/Library/SerialIoLib/SerialPortLib.c b/PcAtChipsetPkg/Library/SerialIoLib/SerialPortLib.c index 95e0db70ad..0a2e20c1d9 100644 --- a/PcAtChipsetPkg/Library/SerialIoLib/SerialPortLib.c +++ b/PcAtChipsetPkg/Library/SerialIoLib/SerialPortLib.c @@ -102,7 +102,7 @@ SerialPortInitialize ( // // Switch back to bank 0 // - OutputData = (UINT8) ((~DLAB << 7) | (gBreakSet << 6) | (gParity << 3) | (gStop << 2) | Data); + OutputData = (UINT8) ( (gBreakSet << 6) | (gParity << 3) | (gStop << 2) | Data); IoWrite8 (gUartBase + LCR_OFFSET, OutputData); return RETURN_SUCCESS; @@ -481,7 +481,7 @@ SerialPortSetAttributes ( // // Switch back to bank 0 // - OutputData = (UINT8) ((~DLAB << 7) | (gBreakSet << 6) | (LcrParity << 3) | (LcrStop << 2) | LcrData); + OutputData = (UINT8) ((gBreakSet << 6) | (LcrParity << 3) | (LcrStop << 2) | LcrData); IoWrite8 (gUartBase + LCR_OFFSET, OutputData); return RETURN_SUCCESS;