summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2020-05-12 19:03:29 +0200
committerAkim Demaille <akim.demaille@gmail.com>2020-05-16 14:39:57 +0200
commit4619b32dc079b7833a784d788114cb1129647723 (patch)
tree7f29c087d194f446ac6eee6c3c3c8b3e5c170e35 /etc
parentad921890c1af6926ccbe80f2c8ba532ac7f5a302 (diff)
downloadbison-4619b32dc079b7833a784d788114cb1129647723.tar.gz
examples: don't promote unchecked function calls
* etc/bench.pl.in, examples/c/bistromathic/parse.y, * examples/c/calc/calc.y, examples/c/pushcalc/calc.y: Check scanf's return value. * doc/bison.texi: Likewise, but only for the second example, to avoid cluttering the very simple case.
Diffstat (limited to 'etc')
-rwxr-xr-xetc/bench.pl.in3
1 files changed, 2 insertions, 1 deletions
diff --git a/etc/bench.pl.in b/etc/bench.pl.in
index b7d44f41..036bf52e 100755
--- a/etc/bench.pl.in
+++ b/etc/bench.pl.in
@@ -498,7 +498,8 @@ yylex (void)
case '5': case '6': case '7': case '8': case '9':
{
int nchars = 0;
- sscanf (input - 1, "%d%n", &yylval.NUM, &nchars);
+ int n = sscanf (input - 1, "%d%n", &yylval.NUM, &nchars);
+ assert (n == 1);
input += nchars - 1;
return NUM;
}