[Python-checkins] Initialize a variable to make the compiler happy. (GH-9153)

Benjamin Peterson webhook-mailer at python.org
Tue Sep 11 18:11:09 EDT 2018


https://github.com/python/cpython/commit/acd282fd5b3ca4de302b33c9361dbc433593c4ca
commit: acd282fd5b3ca4de302b33c9361dbc433593c4ca
branch: master
author: Benjamin Peterson <benjamin at python.org>
committer: GitHub <noreply at github.com>
date: 2018-09-11T15:11:06-07:00
summary:

Initialize a variable to make the compiler happy. (GH-9153)

GCC complains:

Python/pylifecycle.c: In function ‘_Py_InitializeFromConfig’:
Python/pylifecycle.c:900:13: warning: ‘interp’ may be used uninitialized in this function [-Wmaybe-uninitialized]
         err = _Py_InitializeMainInterpreter(interp, &main_config);
         ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This seems spurious since &interp is passed to _Py_InitializeCore. Anyway, we
can easily initialize to quiet the warning.

files:
M Python/pylifecycle.c

diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 33ca802fd56d..379e860b5ba4 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -886,7 +886,7 @@ _Py_InitializeMainInterpreter(PyInterpreterState *interp,
 _PyInitError
 _Py_InitializeFromConfig(const _PyCoreConfig *config)
 {
-    PyInterpreterState *interp;
+    PyInterpreterState *interp = NULL;
     _PyInitError err;
     err = _Py_InitializeCore(&interp, config);
     if (_Py_INIT_FAILED(err)) {



More information about the Python-checkins mailing list