diff options
author | Benjamin Peterson <benjamin@python.org> | 2017-10-24 23:09:55 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-24 23:09:55 -0700 |
commit | 88d5e2c938b014885044f1cfd016e62798f07fd2 (patch) | |
tree | a613aacd228dff102ec83ec85f8c3b932cbbfc85 /Python | |
parent | 04c0a4038e8764f742de8505600b8ee97ee50776 (diff) | |
download | cpython-git-88d5e2c938b014885044f1cfd016e62798f07fd2.tar.gz |
fix marshal uninitialized variable warnings (#4114)
GCC says:
../cpython/Python/marshal.c: In function ‘PyMarshal_WriteLongToFile’:
../cpython/Python/marshal.c:70:35: warning: ‘wf.ptr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
else if ((p)->ptr != (p)->end) *(p)->ptr++ = (c); \
^~
../cpython/Python/marshal.c:70:47: warning: ‘wf.end’ may be used uninitialized in this function [-Wmaybe-uninitialized]
else if ((p)->ptr != (p)->end) *(p)->ptr++ = (c); \
^~
../cpython/Python/marshal.c:77:10: warning: ‘wf.str’ may be used uninitialized in this function [-Wmaybe-uninitialized]
if (p->str == NULL)
~^~~~~
This isn't a real problem because if the file pointer is not NULL, the
string-related fields are never touched. But, it doesn't hurt to set the unused
fields to NULL.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/marshal.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Python/marshal.c b/Python/marshal.c index e1a84d0bf7..f55599bdb0 100644 --- a/Python/marshal.c +++ b/Python/marshal.c @@ -465,6 +465,9 @@ PyMarshal_WriteLongToFile(long x, FILE *fp, int version) { WFILE wf; wf.fp = fp; + wf.str = NULL; + wf.ptr = NULL; + wf.end = NULL; wf.error = WFERR_OK; wf.depth = 0; wf.strings = NULL; @@ -477,6 +480,9 @@ PyMarshal_WriteObjectToFile(PyObject *x, FILE *fp, int version) { WFILE wf; wf.fp = fp; + wf.str = NULL; + wf.ptr = NULL; + wf.end = NULL; wf.error = WFERR_OK; wf.depth = 0; wf.strings = (version > 0) ? PyDict_New() : NULL; |