From: Leif Lindholm <leif.lindholm@linaro.org>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: edk2-devel@lists.01.org
Subject: Re: [PATCH] EmbeddedPkg/GdbSerialLib: avoid left shift of negative quantity
Date: Mon, 18 Jun 2018 22:57:59 +0100 [thread overview]
Message-ID: <20180618215758.vsoetpww4ax64v6g@bivouac.eciton.net> (raw)
In-Reply-To: <20180618204918.31835-1-ard.biesheuvel@linaro.org>
On Mon, Jun 18, 2018 at 10:49:18PM +0200, Ard Biesheuvel wrote:
> Clang complains about left shifting a negative value being undefined.
As well it should.
> EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.c:151:30:
> error: shifting a negative signed value is undefined [-Werror,-Wshift-negative-value]
> OutputData = (UINT8)((~DLAB<<7)|((BreakSet<<6)|((Parity<<3)|((StopBits<<2)| Data))));
>
> Redefine all bit pattern constants as unsigned to work around this.
So, I'm totally OK with this and
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
but ...
would it be worth fixing up BIT0-31 in Base.h and use those?
/
Leif
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.c b/EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.c
> index 069d87ca780d..7931d1ac4e2b 100644
> --- a/EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.c
> +++ b/EmbeddedPkg/Library/GdbSerialLib/GdbSerialLib.c
> @@ -40,11 +40,11 @@
> //---------------------------------------------
> // UART Register Bit Defines
> //---------------------------------------------
> -#define LSR_TXRDY 0x20
> -#define LSR_RXDA 0x01
> -#define DLAB 0x01
> -#define ENABLE_FIFO 0x01
> -#define CLEAR_FIFOS 0x06
> +#define LSR_TXRDY 0x20U
> +#define LSR_RXDA 0x01U
> +#define DLAB 0x01U
> +#define ENABLE_FIFO 0x01U
> +#define CLEAR_FIFOS 0x06U
>
>
>
> --
> 2.17.1
>
next prev parent reply other threads:[~2018-06-18 21:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-18 20:49 [PATCH] EmbeddedPkg/GdbSerialLib: avoid left shift of negative quantity Ard Biesheuvel
2018-06-18 21:57 ` Leif Lindholm [this message]
2018-06-18 22:07 ` Ard Biesheuvel
2018-06-18 22:51 ` Laszlo Ersek
2018-06-19 6:37 ` Ard Biesheuvel
2018-06-19 9:54 ` Leif Lindholm
2018-06-19 12:51 ` Laszlo Ersek
2018-06-19 13:06 ` Leif Lindholm
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=20180618215758.vsoetpww4ax64v6g@bivouac.eciton.net \
--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