[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 04/22] i386/kvm: Replace abs64() with uabs64() from host-utils
From: |
Luis Pires |
Subject: |
[PATCH v3 04/22] i386/kvm: Replace abs64() with uabs64() from host-utils |
Date: |
Fri, 10 Sep 2021 08:26:06 -0300 |
Drop abs64() and use uabs64() from host-utils, which avoids
an undefined behavior when taking abs of the most negative value.
Signed-off-by: Luis Pires <luis.pires@eldorado.org.br>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/i386/kvm/i8254.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/hw/i386/kvm/i8254.c b/hw/i386/kvm/i8254.c
index fa68669e8a..191a26fa57 100644
--- a/hw/i386/kvm/i8254.c
+++ b/hw/i386/kvm/i8254.c
@@ -59,11 +59,6 @@ struct KVMPITClass {
DeviceRealize parent_realize;
};
-static int64_t abs64(int64_t v)
-{
- return v < 0 ? -v : v;
-}
-
static void kvm_pit_update_clock_offset(KVMPITState *s)
{
int64_t offset, clock_offset;
@@ -81,7 +76,7 @@ static void kvm_pit_update_clock_offset(KVMPITState *s)
clock_gettime(CLOCK_MONOTONIC, &ts);
offset -= ts.tv_nsec;
offset -= (int64_t)ts.tv_sec * 1000000000;
- if (abs64(offset) < abs64(clock_offset)) {
+ if (uabs64(offset) < uabs64(clock_offset)) {
clock_offset = offset;
}
}
--
2.25.1
- [PATCH v3 00/22] target/ppc: DFP instructions using decodetree, Luis Pires, 2021/09/10
- [PATCH v3 02/22] host-utils: fix missing zero-extension in divs128, Luis Pires, 2021/09/10
- [PATCH v3 01/22] host-utils: Fix overflow detection in divu128(), Luis Pires, 2021/09/10
- [PATCH v3 03/22] host-utils: introduce uabs64(), Luis Pires, 2021/09/10
- [PATCH v3 04/22] i386/kvm: Replace abs64() with uabs64() from host-utils,
Luis Pires <=
- [PATCH v3 05/22] host-utils: move checks out of divu128/divs128, Luis Pires, 2021/09/10
- [PATCH v3 06/22] host-utils: move udiv_qrnnd() to host-utils, Luis Pires, 2021/09/10
- [PATCH v3 07/22] host-utils: add 128-bit quotient support to divu128/divs128, Luis Pires, 2021/09/10
- [PATCH v3 08/22] host-utils: add unit tests for divu128/divs128, Luis Pires, 2021/09/10
- [PATCH v3 09/22] libdecnumber: introduce decNumberFrom[U]Int128, Luis Pires, 2021/09/10
- [PATCH v3 10/22] target/ppc: Move REQUIRE_ALTIVEC/VECTOR to translate.c, Luis Pires, 2021/09/10
- [PATCH v3 11/22] target/ppc: Introduce REQUIRE_FPU, Luis Pires, 2021/09/10
- [PATCH v3 12/22] target/ppc: Implement DCFFIXQQ, Luis Pires, 2021/09/10
- [PATCH v3 13/22] host-utils: Introduce mulu128, Luis Pires, 2021/09/10
- [PATCH v3 14/22] libdecnumber: Introduce decNumberIntegralToInt128, Luis Pires, 2021/09/10