From: Mathieu Desnoyers Date: Tue, 17 May 2016 16:06:45 +0000 (-0400) Subject: Fix: unchecked return value in trace_clock_read64_monotonic X-Git-Tag: v2.6.3~29 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=513ab0a11303bbd03c64ee09a4a8ae1f00405574;p=lttng-tools.git Fix: unchecked return value in trace_clock_read64_monotonic 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 Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/ust-clock.h b/src/bin/lttng-sessiond/ust-clock.h index 7d9c99a66..9819220d5 100644 --- a/src/bin/lttng-sessiond/ust-clock.h +++ b/src/bin/lttng-sessiond/ust-clock.h @@ -43,7 +43,12 @@ uint64_t trace_clock_read64(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; }