diff options
| author | Benjamin Peterson <benjamin@python.org> | 2019-11-07 07:06:28 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-11-07 07:06:28 -0800 |
| commit | f32bcf8c27f3681407707bbb029323eb340d3c4b (patch) | |
| tree | 1c6d804a1562ac4f5b5734c18c8635fd7822fb8f /Modules/parsermodule.c | |
| parent | 089e5f52a34377193a9e6c03088114b14c8507af (diff) | |
| download | cpython-git-f32bcf8c27f3681407707bbb029323eb340d3c4b.tar.gz | |
[2.7] bpo-38730: Fix -Wstringop-truncation warnings. (GH-17075)
Diffstat (limited to 'Modules/parsermodule.c')
| -rw-r--r-- | Modules/parsermodule.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c index fcc618d5d9..759f0ff4f6 100644 --- a/Modules/parsermodule.c +++ b/Modules/parsermodule.c @@ -1055,14 +1055,15 @@ validate_numnodes(node *n, int num, const char *const name) static int validate_terminal(node *terminal, int type, char *string) { - int res = (validate_ntype(terminal, type) - && ((string == 0) || (strcmp(string, STR(terminal)) == 0))); - - if (!res && !PyErr_Occurred()) { + if (!validate_ntype(terminal, type)) { + return 0; + } + if (string != NULL && strcmp(string, STR(terminal)) != 0) { PyErr_Format(parser_error, "Illegal terminal: expected \"%s\"", string); + return 0; } - return (res); + return 1; } |
