[PATCH 1/7] score: Return status in _TOD_Adjust()

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Sep 3 13:33:18 UTC 2021


---
 cpukit/include/rtems/score/todimpl.h | 5 ++++-
 cpukit/posix/src/adjtime.c           | 6 +++++-
 cpukit/score/src/coretodadjust.c     | 7 +++++--
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/cpukit/include/rtems/score/todimpl.h b/cpukit/include/rtems/score/todimpl.h
index 316a56ec74..02a7fb1092 100644
--- a/cpukit/include/rtems/score/todimpl.h
+++ b/cpukit/include/rtems/score/todimpl.h
@@ -337,8 +337,11 @@ RTEMS_INLINE_ROUTINE void _TOD_Get_timeval(
  * specified amount.
  *
  * @param delta is the amount to adjust.
+ *
+ * @retval STATUS_SUCCESSFUL Successful operation.
+ * @retval other Some error occurred.
  */
-void _TOD_Adjust(
+Status_Control _TOD_Adjust(
   const struct timespec *delta
 );
 
diff --git a/cpukit/posix/src/adjtime.c b/cpukit/posix/src/adjtime.c
index ab61693f19..ec8cb19a2e 100644
--- a/cpukit/posix/src/adjtime.c
+++ b/cpukit/posix/src/adjtime.c
@@ -44,6 +44,7 @@ int adjtime(
 )
 {
   struct timespec delta_as_timespec;
+  Status_Control  status;
 
   /*
    * Simple validations
@@ -83,7 +84,10 @@ int adjtime(
   /*
    * Now apply the adjustment
    */
-  _TOD_Adjust( &delta_as_timespec );
+  status = _TOD_Adjust( &delta_as_timespec );
+  if ( status != STATUS_SUCCESSFUL ) {
+    rtems_set_errno_and_return_minus_one( STATUS_GET_POSIX( status ) );
+  }
 
   return 0;
 }
diff --git a/cpukit/score/src/coretodadjust.c b/cpukit/score/src/coretodadjust.c
index a746b0e004..90c99803e1 100644
--- a/cpukit/score/src/coretodadjust.c
+++ b/cpukit/score/src/coretodadjust.c
@@ -22,12 +22,13 @@
 
 #include <rtems/score/todimpl.h>
 
-void _TOD_Adjust(
+Status_Control _TOD_Adjust(
   const struct timespec *delta
 )
 {
   ISR_lock_Context lock_context;
   struct timespec  tod;
+  Status_Control   status;
 
   /*
    * Currently, RTEMS does the adjustment in one movement.
@@ -41,6 +42,8 @@ void _TOD_Adjust(
   _TOD_Acquire( &lock_context );
   _TOD_Get( &tod );
   _Timespec_Add_to( &tod, delta );
-  _TOD_Set( &tod, &lock_context );
+  status = _TOD_Set( &tod, &lock_context );
   _TOD_Unlock();
+
+  return status;
 }
-- 
2.26.2



More information about the devel mailing list