aboutsummaryrefslogtreecommitdiff
path: root/hw/i386/kvm
diff options
context:
space:
mode:
authorLuis Pires <luis.pires@eldorado.org.br>2021-09-10 08:26:06 -0300
committerDavid Gibson <david@gibson.dropbear.id.au>2021-09-29 19:37:38 +1000
commitbb89646c75e46db0074e263d74770dac6f0a29fc (patch)
tree49e4a9cf9af93c1f6e9a3d4c53944125bf54ba7f /hw/i386/kvm
parentd03bba0bfbe6dcacc9d7be2b664d70fde081cc47 (diff)
downloadqemu-bb89646c75e46db0074e263d74770dac6f0a29fc.zip
qemu-bb89646c75e46db0074e263d74770dac6f0a29fc.tar.gz
qemu-bb89646c75e46db0074e263d74770dac6f0a29fc.tar.bz2
i386/kvm: Replace abs64() with uabs64() from host-utils
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> Message-Id: <20210910112624.72748-5-luis.pires@eldorado.org.br> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'hw/i386/kvm')
-rw-r--r--hw/i386/kvm/i8254.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/hw/i386/kvm/i8254.c b/hw/i386/kvm/i8254.c
index fa68669..191a26f 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;
}
}