qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] ibex_uart: fix XOR-as-pow


From: Eric Blake
Subject: Re: [PATCH] ibex_uart: fix XOR-as-pow
Date: Tue, 23 Jun 2020 15:07:01 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]