[lttng-dev] [PATCH lttng-tools] Fix: unchecked return value

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Tue May 17 16:17:05 UTC 2016


Found by Coverity:

CID 1019971 (#1 of 1): Unchecked return value from library
(CHECKED_RETURN)2. check_return: Calling posix_fadvise(outfd,
orig_offset - stream->max_sb_size, stream->max_sb_size, 4) without
checking return value. This library function may fail and return an
error code.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
---
 src/common/consumer/consumer.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/common/consumer/consumer.c b/src/common/consumer/consumer.c
index cb05a1e..e22de4d 100644
--- a/src/common/consumer/consumer.c
+++ b/src/common/consumer/consumer.c
@@ -1262,8 +1262,10 @@ void lttng_consumer_sync_trace_file(struct lttng_consumer_stream *stream,
 	 * defined. So it can be expected to lead to lower throughput in
 	 * streaming.
 	 */
-	posix_fadvise(outfd, orig_offset - stream->max_sb_size,
-			stream->max_sb_size, POSIX_FADV_DONTNEED);
+	if (posix_fadvise(outfd, orig_offset - stream->max_sb_size,
+			stream->max_sb_size, POSIX_FADV_DONTNEED)) {
+		DBG("Ignoring posix_fadvise() error: %s.", strerror(errno));
+	}
 }
 
 /*
-- 
2.1.4



More information about the lttng-dev mailing list