From 1cf9656cf8f53a69a8be83cb76c0ee3de64b0db8 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Tue, 17 May 2016 12:06:45 -0400 Subject: [PATCH] Fix: unchecked return value in trace_clock_read64_monotonic MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/bin/lttng-sessiond/ust-clock.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bin/lttng-sessiond/ust-clock.h b/src/bin/lttng-sessiond/ust-clock.h index 849373763..c2e0cbcc3 100644 --- a/src/bin/lttng-sessiond/ust-clock.h +++ b/src/bin/lttng-sessiond/ust-clock.h @@ -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; } -- 2.34.1