mirror of
https://github.com/troglobit/libuev.git
synced 2026-10-31 12:20:29 +00:00
Merge pull request #8 from westermo/master
Check timer period and timeout arguments
This commit is contained in:
commit
addd60db22
1 file changed
+10
@@ -67,6 +67,11 @@ int uev_timer_init(uev_ctx_t *ctx, uev_t *w, uev_cb_t *cb, void *arg, int timeou
|
|||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
|
if (timeout < 0 || period < 0) {
|
||||||
|
errno = ERANGE;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK | TFD_CLOEXEC);
|
fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK | TFD_CLOEXEC);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -100,6 +105,11 @@ int uev_timer_set(uev_t *w, int timeout, int period)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (timeout < 0 || period < 0) {
|
||||||
|
errno = ERANGE;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Handle stopped timers */
|
/* Handle stopped timers */
|
||||||
if (w->fd < 0) {
|
if (w->fd < 0) {
|
||||||
/* Timer already stopped */
|
/* Timer already stopped */
|
||||||
|
|||||||
Reference in new issue
Block a user