This is if the user does not plan to delete the timer.
Signed-off-by: Angus Salkeld <asalkeld(a)redhat.com>
---
lib/loop_poll.c | 9 +++------
lib/loop_timerlist.c | 7 +++----
tests/check_loop.c | 2 --
3 files changed, 6 insertions(+), 12 deletions(-)
diff --git a/lib/loop_poll.c b/lib/loop_poll.c
index 2c1bd65..cc1f580 100644
--- a/lib/loop_poll.c
+++ b/lib/loop_poll.c
@@ -733,11 +733,6 @@ qb_loop_timer_add(struct qb_loop *l,
"can't add a timer with either (l == NULL || timer_fn == NULL)");
return -EINVAL;
}
- if (timer_handle_out == NULL) {
- qb_util_log(LOG_ERR,
- "can't add a timer with (timer_handle_out == NULL)");
- return -ENOENT;
- }
fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
if (fd == -1) {
res = -errno;
@@ -771,7 +766,9 @@ qb_loop_timer_add(struct qb_loop *l,
pe->type = QB_TIMER;
pe->add_to_jobs = _qb_timer_add_to_jobs_;
- *timer_handle_out = (((uint64_t) (pe->check)) << 32) | pe->install_pos;
+ if (timer_handle_out) {
+ *timer_handle_out = (((uint64_t) (pe->check)) << 32) | pe->install_pos;
+ }
return res;
diff --git a/lib/loop_timerlist.c b/lib/loop_timerlist.c
index afdebf4..7e7cb19 100644
--- a/lib/loop_timerlist.c
+++ b/lib/loop_timerlist.c
@@ -186,9 +186,6 @@ qb_loop_timer_add(struct qb_loop * l,
return -EINVAL;
}
my_src = (struct qb_timer_source *)l->timer_source;
- if (timer_handle_out == 0) {
- return -ENOENT;
- }
i = _get_empty_array_position_(my_src);
assert(qb_array_index(my_src->timers, i, (void **)&t) >= 0);
@@ -208,7 +205,9 @@ qb_loop_timer_add(struct qb_loop * l,
}
}
- *timer_handle_out = (((uint64_t) (t->check)) << 32) | t->install_pos;
+ if (timer_handle_out) {
+ *timer_handle_out = (((uint64_t) (t->check)) << 32) | t->install_pos;
+ }
return timerlist_add_duration(&my_src->timerlist,
make_job_from_tmo, t,
nsec_duration, &t->timerlist_handle);
diff --git a/tests/check_loop.c b/tests/check_loop.c
index 9a19b82..b358efd 100644
--- a/tests/check_loop.c
+++ b/tests/check_loop.c
@@ -193,8 +193,6 @@ START_TEST(test_loop_timer_input)
ck_assert_int_eq(res, -EINVAL);
res = qb_loop_timer_add(l, QB_LOOP_LOW, 5*QB_TIME_NS_IN_MSEC, l, NULL, &test_th);
ck_assert_int_eq(res, -EINVAL);
- res = qb_loop_timer_add(l, QB_LOOP_LOW, 5*QB_TIME_NS_IN_MSEC, l, job_1, NULL);
- ck_assert_int_eq(res, -ENOENT);
qb_loop_destroy(l);
}
END_TEST
--
1.7.7.5
Show replies by date