Skip to content

Commit 37e3b40

Browse files
committed
Solve uninitalized variable warning using = NULL
1 parent c5529c6 commit 37e3b40

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

Python/generated_cases.c.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tools/cases_generator/generate_cases.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,13 @@ def declare(self, dst: StackEffect, src: StackEffect | None):
160160
if dst.name == UNUSED:
161161
return
162162
typ = f"{dst.type}" if dst.type else "PyObject *"
163-
init = ""
164163
if src:
165164
cast = self.cast(dst, src)
166165
init = f" = {cast}{src.name}"
166+
elif dst.cond:
167+
init = " = NULL"
168+
else:
169+
init = ""
167170
sepa = "" if typ.endswith("*") else " "
168171
self.emit(f"{typ}{sepa}{dst.name}{init};")
169172

Tools/cases_generator/test_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ def test_cond_effect():
494494
PyObject *input = (oparg & 1) ? PEEK(1 + ((oparg & 1) != 0)) : NULL;
495495
PyObject *aa = PEEK(2 + ((oparg & 1) != 0));
496496
PyObject *xx;
497-
PyObject *output;
497+
PyObject *output = NULL;
498498
PyObject *zz;
499499
output = spam(oparg, input);
500500
STACK_SHRINK(((oparg & 1) != 0));

0 commit comments

Comments
 (0)