]> git.proxmox.com Git - mirror_qemu.git/commitdiff
hw/rtc/m48t59: Use 64-bit arithmetic in set_alarm()
authorPeter Maydell <peter.maydell@linaro.org>
Thu, 31 Aug 2023 08:45:17 +0000 (09:45 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Thu, 31 Aug 2023 08:45:17 +0000 (09:45 +0100)
In the m48t59 device we almost always use 64-bit arithmetic when
dealing with time_t deltas.  The one exception is in set_alarm(),
which currently uses a plain 'int' to hold the difference between two
time_t values.  Switch to int64_t instead to avoid any possible
overflow issues.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
hw/rtc/m48t59.c

index ec3e56e84fdff410679306d335f3cc0e1c7b5bd2..2e2c849985c6c6bc19e150bfb32115b623e3433d 100644 (file)
@@ -133,7 +133,7 @@ static void alarm_cb (void *opaque)
 
 static void set_alarm(M48t59State *NVRAM)
 {
-    int diff;
+    int64_t diff;
     if (NVRAM->alrm_timer != NULL) {
         timer_del(NVRAM->alrm_timer);
         diff = qemu_timedate_diff(&NVRAM->alarm) - NVRAM->time_offset;