summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/rtems')
-rw-r--r--cpukit/rtems/src/clockset.c33
-rw-r--r--cpukit/rtems/src/clocktodvalidate.c21
-rw-r--r--cpukit/rtems/src/taskwakewhen.c13
-rw-r--r--cpukit/rtems/src/timercreate.c10
4 files changed, 44 insertions, 33 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 );
}
diff --git a/cpukit/rtems/src/clocktodvalidate.c b/cpukit/rtems/src/clocktodvalidate.c
index 2685bfd6e7..d8e9d01382 100644
--- a/cpukit/rtems/src/clocktodvalidate.c
+++ b/cpukit/rtems/src/clocktodvalidate.c
@@ -35,17 +35,20 @@ const uint32_t _TOD_Days_per_month[ 2 ][ 13 ] = {
{ 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
};
-bool _TOD_Validate(
+rtems_status_code _TOD_Validate(
const rtems_time_of_day *the_tod
)
{
uint32_t days_in_month;
uint32_t ticks_per_second;
+ if ( the_tod == NULL ) {
+ return RTEMS_INVALID_ADDRESS;
+ }
+
ticks_per_second = TOD_MICROSECONDS_PER_SECOND /
rtems_configuration_get_microseconds_per_tick();
- if ((!the_tod) ||
- (the_tod->ticks >= ticks_per_second) ||
+ if ((the_tod->ticks >= ticks_per_second) ||
(the_tod->second >= TOD_SECONDS_PER_MINUTE) ||
(the_tod->minute >= TOD_MINUTES_PER_HOUR) ||
(the_tod->hour >= TOD_HOURS_PER_DAY) ||
@@ -53,8 +56,9 @@ bool _TOD_Validate(
(the_tod->month > TOD_MONTHS_PER_YEAR) ||
(the_tod->year < TOD_BASE_YEAR) ||
(the_tod->year > TOD_LATEST_YEAR) ||
- (the_tod->day == 0) )
- return false;
+ (the_tod->day == 0) ) {
+ return RTEMS_INVALID_CLOCK;
+ }
if (((the_tod->year % 4) == 0 && (the_tod->year % 100 != 0)) ||
(the_tod->year % 400 == 0))
@@ -62,8 +66,9 @@ bool _TOD_Validate(
else
days_in_month = _TOD_Days_per_month[ 0 ][ the_tod->month ];
- if ( the_tod->day > days_in_month )
- return false;
+ if ( the_tod->day > days_in_month ) {
+ return RTEMS_INVALID_CLOCK;
+ }
- return true;
+ return RTEMS_SUCCESSFUL;
}
diff --git a/cpukit/rtems/src/taskwakewhen.c b/cpukit/rtems/src/taskwakewhen.c
index 5f6a5795fc..a25204ad01 100644
--- a/cpukit/rtems/src/taskwakewhen.c
+++ b/cpukit/rtems/src/taskwakewhen.c
@@ -30,9 +30,10 @@ rtems_status_code rtems_task_wake_when(
rtems_time_of_day *time_buffer
)
{
- uint32_t seconds;
- Thread_Control *executing;
- Per_CPU_Control *cpu_self;
+ uint32_t seconds;
+ Thread_Control *executing;
+ Per_CPU_Control *cpu_self;
+ rtems_status_code status;
if ( !_TOD_Is_set() )
return RTEMS_NOT_DEFINED;
@@ -41,9 +42,11 @@ rtems_status_code rtems_task_wake_when(
return RTEMS_INVALID_ADDRESS;
time_buffer->ticks = 0;
+ status = _TOD_Validate( time_buffer );
- if ( !_TOD_Validate( time_buffer ) )
- return RTEMS_INVALID_CLOCK;
+ if ( status != RTEMS_SUCCESSFUL ) {
+ return status;
+ }
seconds = _TOD_To_seconds( time_buffer );
diff --git a/cpukit/rtems/src/timercreate.c b/cpukit/rtems/src/timercreate.c
index a3ece5cc4d..bd9421c440 100644
--- a/cpukit/rtems/src/timercreate.c
+++ b/cpukit/rtems/src/timercreate.c
@@ -132,7 +132,8 @@ rtems_status_code _Timer_Fire_when(
Watchdog_Service_routine_entry adaptor
)
{
- rtems_interval seconds;
+ rtems_status_code status;
+ rtems_interval seconds;
if ( !_TOD_Is_set() )
return RTEMS_NOT_DEFINED;
@@ -140,8 +141,11 @@ rtems_status_code _Timer_Fire_when(
if ( !routine )
return RTEMS_INVALID_ADDRESS;
- if ( !_TOD_Validate( wall_time ) )
- return RTEMS_INVALID_CLOCK;
+ status = _TOD_Validate( wall_time );
+
+ if ( status != RTEMS_SUCCESSFUL ) {
+ return status;
+ }
seconds = _TOD_To_seconds( wall_time );
if ( seconds <= _TOD_Seconds_since_epoch() )