Skip to content

Commit 3065c15

Browse files
vstinnerestyxx
authored andcommitted
pythongh-120155: Initialize variables in _tkinter.c (python#120156)
Initialize variables in _tkinter.c to make static analyzers happy.
1 parent f2c9198 commit 3065c15

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Modules/_tkinter.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,7 @@ Tkapp_Call(PyObject *selfptr, PyObject *args)
14381438
marshal the parameters to the interpreter thread. */
14391439
Tkapp_CallEvent *ev;
14401440
Tcl_Condition cond = NULL;
1441-
PyObject *exc;
1441+
PyObject *exc = NULL; // init to make static analyzers happy
14421442
if (!WaitForMainloop(self))
14431443
return NULL;
14441444
ev = (Tkapp_CallEvent*)attemptckalloc(sizeof(Tkapp_CallEvent));
@@ -1712,7 +1712,8 @@ var_invoke(EventFunc func, PyObject *selfptr, PyObject *args, int flags)
17121712
TkappObject *self = (TkappObject*)selfptr;
17131713
if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) {
17141714
VarEvent *ev;
1715-
PyObject *res, *exc;
1715+
// init 'res' and 'exc' to make static analyzers happy
1716+
PyObject *res = NULL, *exc = NULL;
17161717
Tcl_Condition cond = NULL;
17171718

17181719
/* The current thread is not the interpreter thread. Marshal
@@ -2413,6 +2414,8 @@ _tkinter_tkapp_createcommand_impl(TkappObject *self, const char *name,
24132414
data->self = self;
24142415
data->func = Py_NewRef(func);
24152416
if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) {
2417+
err = 0; // init to make static analyzers happy
2418+
24162419
Tcl_Condition cond = NULL;
24172420
CommandEvent *ev = (CommandEvent*)attemptckalloc(sizeof(CommandEvent));
24182421
if (ev == NULL) {
@@ -2468,6 +2471,8 @@ _tkinter_tkapp_deletecommand_impl(TkappObject *self, const char *name)
24682471
TRACE(self, ("((sss))", "rename", name, ""));
24692472

24702473
if (self->threaded && self->thread_id != Tcl_GetCurrentThread()) {
2474+
err = 0; // init to make static analyzers happy
2475+
24712476
Tcl_Condition cond = NULL;
24722477
CommandEvent *ev;
24732478
ev = (CommandEvent*)attemptckalloc(sizeof(CommandEvent));

0 commit comments

Comments
 (0)