diff options
author | j_mayer <j_mayer@c046a42c-6fe2-441c-8c8c-71466251a162> | 2007-09-30 01:29:07 +0000 |
---|---|---|
committer | j_mayer <j_mayer@c046a42c-6fe2-441c-8c8c-71466251a162> | 2007-09-30 01:29:07 +0000 |
commit | 868d585aced5457218b3443398d08594d9c3ba6d (patch) | |
tree | 54f8f8233ff28a08e1d63ae6c1ea26ec6ef0b6d6 /hw/m48t59.c | |
parent | c80f84e3c037ebaebcec48f59c65be02a6d76a89 (diff) | |
download | qemu-868d585aced5457218b3443398d08594d9c3ba6d.zip qemu-868d585aced5457218b3443398d08594d9c3ba6d.tar.gz qemu-868d585aced5457218b3443398d08594d9c3ba6d.tar.bz2 |
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
Diffstat (limited to 'hw/m48t59.c')
-rw-r--r-- | hw/m48t59.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/hw/m48t59.c b/hw/m48t59.c index c2c0dec..da61313 100644 --- a/hw/m48t59.c +++ b/hw/m48t59.c @@ -161,10 +161,9 @@ 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); } - if (NVRAM->alarm - time(NULL) > 0) - qemu_mod_timer(NVRAM->alrm_timer, NVRAM->alarm * 1000); } /* Watchdog management */ @@ -188,15 +187,14 @@ 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)); + 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)); + } } } |