py-common: clean-up: unreachable error handling code
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 28 Feb 2020 23:54:55 +0000 (18:54 -0500)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Sat, 29 Feb 2020 23:31:28 +0000 (18:31 -0500)
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 <jeremie.galarneau@efficios.com>
Change-Id: I81b5a2db2cefe1fe08e25819bfa2d8e0fd78ee82
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3154
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
src/py-common/py-common.c

index b1ca34ae455014f87e85116c33fd8b2ab97e4a15..75539819529261d49747d63595ce13acdacf3d49 100644 (file)
@@ -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);
This page took 0.024982 seconds and 4 git commands to generate.