From: Jérémie Galarneau Date: Fri, 28 Feb 2020 23:54:55 +0000 (-0500) Subject: py-common: clean-up: unreachable error handling code X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=87694a583f967f4b8e9e7b232805e93bdc0e6089 py-common: clean-up: unreachable error handling code 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 --- 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);