summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/clockset.c
diff options
context:
space:
mode:
authorFrank Kühndel <frank.kuehndel@embedded-brains.de>2021-05-11 16:26:55 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-05-12 06:41:10 +0200
commit3af2dc7802164d6c22dbef1f144c9bd945a35c30 (patch)
tree6c34fd16da24213f89fde232dd6a0f7ccf87cf35 /cpukit/rtems/src/clockset.c
parentrtems: Use _Objects_Free_nothing() for msg queues (diff)
downloadrtems-3af2dc7802164d6c22dbef1f144c9bd945a35c30.tar.bz2
_TOD_Validate(): Fix incorrect return code
This patch fixes bug #4403. Directives * rtems_timer_fire_when() * rtems_timer_server_fire_when() * rtems_task_wake_when() are documented to return RTEMS_INVALID_ADDRESS when their time-of-day argument is NULL. But actually they return RTEMS_INVALID_CLOCK. To fix the issue this patch changes _TOD_Validate() to return a status code instead of just true/false. Close #4403
Diffstat (limited to 'cpukit/rtems/src/clockset.c')
-rw-r--r--cpukit/rtems/src/clockset.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/cpukit/rtems/src/clockset.c b/cpukit/rtems/src/clockset.c
index 7a085ada69..df163531a7 100644
--- a/cpukit/rtems/src/clockset.c
+++ b/cpukit/rtems/src/clockset.c
@@ -29,26 +29,25 @@ rtems_status_code rtems_clock_set(
const rtems_time_of_day *tod
)
{
- Status_Control status;
+ rtems_status_code status;
+ Status_Control score_status;
+ struct timespec tod_as_timespec;
+ ISR_lock_Context lock_context;
- if ( !tod )
- return RTEMS_INVALID_ADDRESS;
+ status = _TOD_Validate( tod );
- if ( _TOD_Validate( tod ) ) {
- struct timespec tod_as_timespec;
- ISR_lock_Context lock_context;
-
- tod_as_timespec.tv_sec = _TOD_To_seconds( tod );
- tod_as_timespec.tv_nsec = tod->ticks
- * rtems_configuration_get_nanoseconds_per_tick();
+ if ( status != RTEMS_SUCCESSFUL ) {
+ return status;
+ }
- _TOD_Lock();
- _TOD_Acquire( &lock_context );
- status = _TOD_Set( &tod_as_timespec, &lock_context );
- _TOD_Unlock();
+ tod_as_timespec.tv_sec = _TOD_To_seconds( tod );
+ tod_as_timespec.tv_nsec = tod->ticks
+ * rtems_configuration_get_nanoseconds_per_tick();
- return _Status_Get( status );
- }
+ _TOD_Lock();
+ _TOD_Acquire( &lock_context );
+ score_status = _TOD_Set( &tod_as_timespec, &lock_context );
+ _TOD_Unlock();
- return RTEMS_INVALID_CLOCK;
+ return _Status_Get( score_status );
}