From 87694a583f967f4b8e9e7b232805e93bdc0e6089 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 28 Feb 2020 18:54:55 -0500 Subject: [PATCH] py-common: clean-up: unreachable error handling code MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Both `bt_py_common_format_exception()` and `bt_py_common_format_tb()` use the same error handling pattern of defining an `error` label and free-ing `msg_buf` if it has been created before jumping there. In both cases, the creation of `msg_buf` is the last operation that can fail, which makes the check, and clean-up, unrechable. From Coverity's report: 1408326 Logically dead code The indicated dead code may have performed some action; that action will never occur. In bt_py_common_format_tb: Code can never be reached because of a logical contradiction (CWE-561) Reported-by: Coverity Scan Signed-off-by: Jérémie Galarneau Change-Id: I81b5a2db2cefe1fe08e25819bfa2d8e0fd78ee82 Reviewed-on: https://review.lttng.org/c/babeltrace/+/3154 Reviewed-by: Simon Marchi Tested-by: jenkins --- src/py-common/py-common.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/py-common/py-common.c b/src/py-common/py-common.c index b1ca34ae..75539819 100644 --- a/src/py-common/py-common.c +++ b/src/py-common/py-common.c @@ -141,15 +141,7 @@ GString *bt_py_common_format_tb(PyObject *py_exc_tb, int log_level) goto error; } - goto end; - error: - if (msg_buf) { - g_string_free(msg_buf, TRUE); - msg_buf = NULL; - } - -end: Py_XDECREF(traceback_module); Py_XDECREF(format_tb_func); Py_XDECREF(exc_str_list); @@ -222,15 +214,7 @@ GString *bt_py_common_format_exception(PyObject *py_exc_type, goto error; } - goto end; - error: - if (msg_buf) { - g_string_free(msg_buf, TRUE); - msg_buf = NULL; - } - -end: Py_XDECREF(exc_str_list); Py_XDECREF(format_exception_func); Py_XDECREF(traceback_module); -- 2.34.1