From 7eb664102dfe38f6c2c30bfffd8b255fe84f2b6c Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Thu, 10 Oct 2019 14:02:39 +0900 Subject: [PATCH 1/3] =?UTF-8?q?bpo-38425:=20Remove=20=E2=80=98res=E2=80=99?= =?UTF-8?q?=20may=20be=20used=20uninitialized=20warning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Parser/asdl_c.py | 2 +- Python/Python-ast.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py index 3a9d4e6b4b923f..c336f415600274 100755 --- a/Parser/asdl_c.py +++ b/Parser/asdl_c.py @@ -1197,7 +1197,7 @@ class PartingShots(StaticVisitor): /* 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; + mod_ty res = NULL; PyObject *req_type[3]; const char * const req_name[] = {"Module", "Expression", "Interactive"}; int isinstance; diff --git a/Python/Python-ast.c b/Python/Python-ast.c index 558d9ebea5c723..71cba36e45e054 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -10250,7 +10250,7 @@ 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; + mod_ty res = NULL; PyObject *req_type[3]; const char * const req_name[] = {"Module", "Expression", "Interactive"}; int isinstance; From a2f20ef87288cce2b662aa124bb447876c0b075a Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Thu, 10 Oct 2019 14:06:12 +0900 Subject: [PATCH 2/3] add news --- .../Core and Builtins/2019-10-10-14-04-26.bpo-38425.xB59iJ.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2019-10-10-14-04-26.bpo-38425.xB59iJ.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-10-10-14-04-26.bpo-38425.xB59iJ.rst b/Misc/NEWS.d/next/Core and Builtins/2019-10-10-14-04-26.bpo-38425.xB59iJ.rst new file mode 100644 index 00000000000000..db7070734c14a1 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2019-10-10-14-04-26.bpo-38425.xB59iJ.rst @@ -0,0 +1,2 @@ +Remove ‘res’ may be used uninitialized warning. (Contributed by Dong-hee Na +in :issue:`38425`.) From 70b0d5bbaff0d502cedd510fe5a316cd22f0e59f Mon Sep 17 00:00:00 2001 From: Dong-hee Na Date: Thu, 10 Oct 2019 16:11:32 +0900 Subject: [PATCH 3/3] bpo-38425: Reflect codereview --- .../Core and Builtins/2019-10-10-14-04-26.bpo-38425.xB59iJ.rst | 2 -- Parser/asdl_c.py | 3 ++- Python/Python-ast.c | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) delete mode 100644 Misc/NEWS.d/next/Core and Builtins/2019-10-10-14-04-26.bpo-38425.xB59iJ.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2019-10-10-14-04-26.bpo-38425.xB59iJ.rst b/Misc/NEWS.d/next/Core and Builtins/2019-10-10-14-04-26.bpo-38425.xB59iJ.rst deleted file mode 100644 index db7070734c14a1..00000000000000 --- a/Misc/NEWS.d/next/Core and Builtins/2019-10-10-14-04-26.bpo-38425.xB59iJ.rst +++ /dev/null @@ -1,2 +0,0 @@ -Remove ‘res’ may be used uninitialized warning. (Contributed by Dong-hee Na -in :issue:`38425`.) diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py index c336f415600274..3a821cc9265c9d 100755 --- a/Parser/asdl_c.py +++ b/Parser/asdl_c.py @@ -1197,7 +1197,6 @@ class PartingShots(StaticVisitor): /* 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 = NULL; PyObject *req_type[3]; const char * const req_name[] = {"Module", "Expression", "Interactive"}; int isinstance; @@ -1223,6 +1222,8 @@ class PartingShots(StaticVisitor): req_name[mode], _PyType_Name(Py_TYPE(ast))); 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 71cba36e45e054..e2c703d815552e 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -10250,7 +10250,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 = NULL; PyObject *req_type[3]; const char * const req_name[] = {"Module", "Expression", "Interactive"}; int isinstance; @@ -10276,6 +10275,8 @@ mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode) req_name[mode], _PyType_Name(Py_TYPE(ast))); return NULL; } + + mod_ty res = NULL; if (obj2ast_mod(ast, &res, arena) != 0) return NULL; else