From: Eric Blake <eblake@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH] ibex_uart: fix XOR-as-pow
Date: Tue, 23 Jun 2020 15:07:01 -0500 [thread overview]
Message-ID: <e47cdd98-ee3f-a222-5bc9-6f8f7085584f@redhat.com> (raw)
In-Reply-To: <20200623195441.14646-1-pbonzini@redhat.com>
On 6/23/20 2:54 PM, Paolo Bonzini wrote:
> The xor-as-pow warning in clang actually detected a genuine bug.
> Fix it.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> hw/char/ibex_uart.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/char/ibex_uart.c b/hw/char/ibex_uart.c
> index 3e0dd9968e..45cd724998 100644
> --- a/hw/char/ibex_uart.c
> +++ b/hw/char/ibex_uart.c
> @@ -331,7 +331,7 @@ static void ibex_uart_write(void *opaque, hwaddr addr,
> if (value & UART_CTRL_NCO) {
> uint64_t baud = ((value & UART_CTRL_NCO) >> 16);
> baud *= 1000;
> - baud /= 2 ^ 20;
> + baud >>= 20;
Dividing by 1M instead of 22 seems much more logical, indeed :)
It's odd that we are scaling up by 1000, down by 1024*1024, then
>
> s->char_tx_time = (NANOSECONDS_PER_SECOND / baud) * 10;
inverting and scaling by 10. I don't know if there is a more succinct
way to write the intended transformation.
> }
But even without reading the hardware manual to see if the resulting
scaling is correct, the typo fix is obvious enough to give:
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
next prev parent reply other threads:[~2020-06-23 20:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-23 19:54 [PATCH] ibex_uart: fix XOR-as-pow Paolo Bonzini
2020-06-23 20:07 ` Eric Blake [this message]
2020-06-24 6:33 ` Paolo Bonzini
2020-06-24 9:25 ` Philippe Mathieu-Daudé
2020-06-23 20:33 ` Peter Maydell
2020-06-23 23:26 ` Alistair Francis
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-all 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=e47cdd98-ee3f-a222-5bc9-6f8f7085584f@redhat.com \
--to=eblake@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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;
as well as URLs for NNTP newsgroup(s).