diff options
author | Phlosioneer <mattmdrr2@gmail.com> | 2017-11-20 18:04:49 -0500 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2017-11-21 00:04:49 +0100 |
commit | 8674b0c3d161bd367ff63c6a8fb290fec0122d05 (patch) | |
tree | 18e4224a4c9f19c1dd5b3fd303bd247967667e51 /test/unit/viml/expressions/parser_tests.lua | |
parent | c39140164877ce51d5785405205a570b45cc5f82 (diff) | |
download | rneovim-8674b0c3d161bd367ff63c6a8fb290fec0122d05.tar.gz rneovim-8674b0c3d161bd367ff63c6a8fb290fec0122d05.tar.bz2 rneovim-8674b0c3d161bd367ff63c6a8fb290fec0122d05.zip |
syntax.c: Fix maybe-uninitialized warning (#7596)
When building in release mode, gcc generated a maybe-initialized
warning in get_syn_options. The warning is both right and wrong;
there is an execution path where the len variable is not
initialized in the code:
...
int len;
...
for (fidx = ARRAY_SIZE(flagtab); --fidx >= 0; ) {
p = flagtab[fidx].name;
int i;
for (i = 0, len = 0; p[i] != NUL; i += 2, ++len)
if (arg[len] != p[i] && arg[len] != p[i + 1])
break;
// <snip>
}
...
arg = skipwhite(arg + len);
...
The initial for loop will not execute if ARRAY_SIZE(flagtab) == 0,
and thus len will never be initialized. flagtab is a local-static
variable, initialized to a long array of structured data, so
ARRAY_SIZE(flagtab) can't be 0.
However, gcc doesn't recognize ARRAY_SIZE(flagtab) as a constant.
There are any number of reasons this could happen. In any case,
the message can be fixed with a len=0 before the first for loop.
In addition to the above warning, I've labeled flagtab and
first_letters as const. They should never change.
Diffstat (limited to 'test/unit/viml/expressions/parser_tests.lua')
0 files changed, 0 insertions, 0 deletions