ensure that timer period is non-negative (#295)
This commit is contained in:
parent
16adb1e4f6
commit
a0f83b071a
2 changed files with 6 additions and 1 deletions
|
@ -81,7 +81,8 @@ rcl_get_zero_initialized_timer(void);
|
|||
* The clock handle must be a pointer to an initialized rcl_clock_t struct.
|
||||
* The life time of the clock must exceed the life time of the timer.
|
||||
*
|
||||
* The period is a duration (rather an absolute time in the future).
|
||||
* The period is a non-negative duration (rather an absolute time in the
|
||||
* future).
|
||||
* If the period is `0` then it will always be ready.
|
||||
*
|
||||
* The callback is an optional argument.
|
||||
|
|
|
@ -62,6 +62,10 @@ rcl_timer_init(
|
|||
RCL_CHECK_ALLOCATOR_WITH_MSG(&allocator, "invalid allocator", return RCL_RET_INVALID_ARGUMENT);
|
||||
RCL_CHECK_ARGUMENT_FOR_NULL(timer, RCL_RET_INVALID_ARGUMENT, allocator);
|
||||
RCL_CHECK_ARGUMENT_FOR_NULL(clock, RCL_RET_INVALID_ARGUMENT, allocator);
|
||||
if (period < 0) {
|
||||
RCL_SET_ERROR_MSG("timer period must be non-negative", allocator);
|
||||
return RCL_RET_INVALID_ARGUMENT;
|
||||
}
|
||||
RCUTILS_LOG_DEBUG_NAMED(ROS_PACKAGE_NAME, "Initializing timer with period: %" PRIu64 "ns", period)
|
||||
if (timer->impl) {
|
||||
RCL_SET_ERROR_MSG("timer already initailized, or memory was uninitialized", allocator);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue