From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Thu, 10 Oct 2019 08:00:19 +0000 (-0700) Subject: bpo-38425: Fix ‘res’ may be used uninitialized warning (GH-16688) X-Git-Tag: v3.8.0~29 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6b6935e563562c427d5bb1b2864d6a2fed0e74fa;p=python bpo-38425: Fix ‘res’ may be used uninitialized warning (GH-16688) (cherry picked from commit a05fcd3c7adf6e3a0944da8cf80a3346882e9b3b) Co-authored-by: Dong-hee Na --- diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py index f4fa271b65..574fcb0e2f 100644 --- a/Parser/asdl_c.py +++ b/Parser/asdl_c.py @@ -1191,7 +1191,6 @@ PyObject* PyAST_mod2obj(mod_ty t) /* mode is 0 for "exec", 1 for "eval" and 2 for "single" input */ mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode) { - mod_ty res; PyObject *req_type[3]; char *req_name[] = {"Module", "Expression", "Interactive"}; int isinstance; @@ -1217,6 +1216,8 @@ mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode) req_name[mode], Py_TYPE(ast)->tp_name); return NULL; } + + mod_ty res = NULL; if (obj2ast_mod(ast, &res, arena) != 0) return NULL; else diff --git a/Python/Python-ast.c b/Python/Python-ast.c index fd96964a1e..f73f035845 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -8991,7 +8991,6 @@ PyObject* PyAST_mod2obj(mod_ty t) /* mode is 0 for "exec", 1 for "eval" and 2 for "single" input */ mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode) { - mod_ty res; PyObject *req_type[3]; char *req_name[] = {"Module", "Expression", "Interactive"}; int isinstance; @@ -9017,6 +9016,8 @@ mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode) req_name[mode], Py_TYPE(ast)->tp_name); return NULL; } + + mod_ty res = NULL; if (obj2ast_mod(ast, &res, arena) != 0) return NULL; else