[rtems commit] posix: Avoid dead code in clock_nanosleep()

Sebastian Huber sebh at rtems.org
Fri Aug 5 06:12:47 UTC 2022


Module:    rtems
Branch:    master
Commit:    c3c4525a322a29d596861b5fe5aceb0adbfa49c0
Changeset: http://git.rtems.org/rtems/commit/?id=c3c4525a322a29d596861b5fe5aceb0adbfa49c0

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Aug  5 08:18:36 2022 +0200

posix: Avoid dead code in clock_nanosleep()

This issue was reported by Coverity Scan for RTEMS:

CID 1507760: Control flow issues (DEADCODE)

Closes #4690.

---

 cpukit/posix/src/clocknanosleep.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/cpukit/posix/src/clocknanosleep.c b/cpukit/posix/src/clocknanosleep.c
index bfa8ef7975..43f15346de 100644
--- a/cpukit/posix/src/clocknanosleep.c
+++ b/cpukit/posix/src/clocknanosleep.c
@@ -127,11 +127,8 @@ int clock_nanosleep(
       struct timespec actual_end;
       struct timespec planned_end;
 
-      if ( clock_id == CLOCK_REALTIME ) {
-        _Timecounter_Nanotime( &actual_end );
-      } else {
-        _Timecounter_Nanouptime( &actual_end );
-      }
+      _Assert( clock_id == CLOCK_MONOTONIC );
+      _Timecounter_Nanouptime( &actual_end );
 
       _Watchdog_Ticks_to_timespec(
         executing->Timer.Watchdog.expire,



More information about the vc mailing list