Skip to content

Commit

Permalink
hw/rtc/m48t59: Use 64-bit arithmetic in set_alarm()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
pm215 committed Aug 31, 2023
1 parent 35aa671 commit 7038b6e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion hw/rtc/m48t59.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7038b6e

Please sign in to comment.