Fix: unchecked return value in trace_clock_read64_monotonic
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 17 May 2016 16:06:45 +0000 (12:06 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 18 May 2016 18:56:55 +0000 (14:56 -0400)
Found by Coverity:

CID 1311498 (#1 of 1): Unchecked return value (CHECKED_RETURN)1.
check_return: Calling clock_gettime without checking return value (as is
done elsewhere 8 out of 9 times).

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/ust-clock.h

index 8493737634a72d8656e6ddb155aa68d6452c33ea..c2e0cbcc394a9708f16801802761169e8cd0ea6d 100644 (file)
@@ -57,7 +57,12 @@ uint64_t trace_clock_read64_monotonic(void)
 {
        struct timespec ts;
 
-       clock_gettime(CLOCK_MONOTONIC, &ts);
+       if (clock_gettime(CLOCK_MONOTONIC, &ts)) {
+               /* TODO Report error cleanly up the chain. */
+               PERROR("clock_gettime CLOCK_MONOTONIC");
+               ts.tv_sec = 0;
+               ts.tv_nsec = 0;
+       }
        return ((uint64_t) ts.tv_sec * 1000000000ULL) + ts.tv_nsec;
 }
 
This page took 0.033328 seconds and 4 git commands to generate.