From f3ce6f5d9f5cfbe70898ca94efb3c8b31968534d Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 31 Jan 2020 17:51:04 -0500 Subject: [PATCH 1/1] Clean-up: trace-chunk: remove unreachable code MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit `path` can never be NULL in this code path; it is unnecessary to check it. There may be a null pointer dereference, or else the comparison against null is unnecessary. In lttng_trace_chunk_rename_path_no_lock: All paths that lead to this null pointer comparison already dereference the pointer earlier (CWE-476). Reported-by: Coverity Scan Signed-off-by: Jérémie Galarneau Change-Id: I4d850b0b8686300268d85f577ae5f14a96d66348 --- src/common/trace-chunk.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/common/trace-chunk.c b/src/common/trace-chunk.c index 63bfb6c52..6039f6376 100644 --- a/src/common/trace-chunk.c +++ b/src/common/trace-chunk.c @@ -911,15 +911,11 @@ enum lttng_trace_chunk_status lttng_trace_chunk_rename_path_no_lock( } skip_move: - if (path) { - new_path = strdup(path); - if (!new_path) { - ERR("Failed to allocate new trace chunk path"); - status = LTTNG_TRACE_CHUNK_STATUS_ERROR; - goto end; - } - } else { - new_path = NULL; + new_path = strdup(path); + if (!new_path) { + ERR("Failed to allocate new trace chunk path"); + status = LTTNG_TRACE_CHUNK_STATUS_ERROR; + goto end; } free(chunk->path); chunk->path = new_path; -- 2.34.1