qemu-timer: reuse MIN macro in qemu_timeout_ns_to_ms
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20191023122652.2999-3-fziglio@redhat.com>
[lv: removed the two useless casts]
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
diff --git a/util/qemu-timer.c b/util/qemu-timer.c
index d428fec..ef52d28 100644
--- a/util/qemu-timer.c
+++ b/util/qemu-timer.c
@@ -322,11 +322,7 @@
ms = DIV_ROUND_UP(ns, SCALE_MS);
/* To avoid overflow problems, limit this to 2^31, i.e. approx 25 days */
- if (ms > (int64_t) INT32_MAX) {
- ms = INT32_MAX;
- }
-
- return (int) ms;
+ return MIN(ms, INT32_MAX);
}