[dm-devel] [PATCH 09/12] multipathd(coverity): check retval clock_gettime()

Martin Wilck mwilck at suse.com
Tue Jan 8 22:54:06 UTC 2019


Checking this is pointless, as we'd bail out early in
pthread_cond_init_mono if CLOCK_MONOTONIC was unsupported, and this
is the only error condition of clock_gettime worth checking.
Do it anyway to make coverity feel better.

Signed-off-by: Martin Wilck <mwilck at suse.com>
---
 multipathd/main.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/multipathd/main.c b/multipathd/main.c
index 01cf70f..0270e18 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -242,10 +242,11 @@ int set_config_state(enum daemon_status state)
 		else if (running_state != DAEMON_IDLE) {
 			struct timespec ts;
 
-			clock_gettime(CLOCK_MONOTONIC, &ts);
-			ts.tv_sec += 1;
-			rc = pthread_cond_timedwait(&config_cond,
-						    &config_lock, &ts);
+			if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
+				ts.tv_sec += 1;
+				rc = pthread_cond_timedwait(&config_cond,
+							    &config_lock, &ts);
+			}
 		}
 		if (!rc && (running_state != DAEMON_SHUTDOWN)) {
 			running_state = state;
-- 
2.19.2




More information about the dm-devel mailing list