Avoid crash on NULL timers.
This is a rework of Stefan Weil proposed patch. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3283 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
c80f84e3c0
commit
868d585ace
@ -161,11 +161,10 @@ static void set_alarm (m48t59_t *NVRAM, struct tm *tm)
|
||||
NVRAM->alarm = mktime(tm);
|
||||
if (NVRAM->alrm_timer != NULL) {
|
||||
qemu_del_timer(NVRAM->alrm_timer);
|
||||
NVRAM->alrm_timer = NULL;
|
||||
}
|
||||
if (NVRAM->alarm - time(NULL) > 0)
|
||||
qemu_mod_timer(NVRAM->alrm_timer, NVRAM->alarm * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
/* Watchdog management */
|
||||
static void watchdog_cb (void *opaque)
|
||||
@ -188,17 +187,16 @@ static void set_up_watchdog (m48t59_t *NVRAM, uint8_t value)
|
||||
{
|
||||
uint64_t interval; /* in 1/16 seconds */
|
||||
|
||||
NVRAM->buffer[0x1FF0] &= ~0x80;
|
||||
if (NVRAM->wd_timer != NULL) {
|
||||
qemu_del_timer(NVRAM->wd_timer);
|
||||
NVRAM->wd_timer = NULL;
|
||||
}
|
||||
NVRAM->buffer[0x1FF0] &= ~0x80;
|
||||
if (value != 0) {
|
||||
interval = (1 << (2 * (value & 0x03))) * ((value >> 2) & 0x1F);
|
||||
qemu_mod_timer(NVRAM->wd_timer, ((uint64_t)time(NULL) * 1000) +
|
||||
((interval * 1000) >> 4));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Direct access to NVRAM */
|
||||
void m48t59_write (m48t59_t *NVRAM, uint32_t addr, uint32_t val)
|
||||
|
Loading…
Reference in New Issue
Block a user