From: David Herrmann Date: Thu, 27 Sep 2012 10:54:37 +0000 (+0200) Subject: eloop: allow NULL for timer updates X-Git-Tag: kmscon-7~466 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b3aba6f61caad9100f1f938c47619a421fcbd114;p=platform%2Fupstream%2Fkmscon.git eloop: allow NULL for timer updates If NULL is passed for timer udpates, we simply assume that the timer should be disarmed and use a zeroed itimerspec. Signed-off-by: David Herrmann --- diff --git a/src/eloop.c b/src/eloop.c index c097292..1bf9ff7 100644 --- a/src/eloop.c +++ b/src/eloop.c @@ -1502,6 +1502,8 @@ err_cb: timer->cb(timer, 0, timer->data); } +static const struct itimerspec ev_timer_zero; + /** * ev_timer_new: * @out: Timer pointer where to store the new timer @@ -1525,6 +1527,9 @@ int ev_timer_new(struct ev_timer **out, const struct itimerspec *spec, if (!out) return llog_dEINVAL(log); + if (!spec) + spec = &ev_timer_zero; + timer = malloc(sizeof(*timer)); if (!timer) return llog_dENOMEM(log); @@ -1694,8 +1699,9 @@ int ev_timer_update(struct ev_timer *timer, const struct itimerspec *spec) if (!timer) return -EINVAL; + if (!spec) - return llog_EINVAL(timer); + spec = &ev_timer_zero; ret = timerfd_settime(timer->fd, 0, spec, NULL); if (ret) {