Menu

Commit [r13003]  Maximize  Restore  History

Silence the two noisiest warning categories: sign-compare loops and unused-but-set

A full build goes from 2066 warnings to 882. The two categories dealt with here
were 1409 of those, and neither was telling us anything.

-Wunused-but-set-variable (303, across 66 files) is switched off in
configure.ac, alongside the -Wno-unused-parameter and -Wno-unused-function that
were already there - same reasoning, they are almost all leftovers from removed
debug and trace code. This needs configure regenerating, hence the change to
the checked-in configure as well.

-Wsign-compare (1106) is NOT switched off, because the category is not uniformly
noise. It splits three ways:

880 for (a=0; a<x.x_len; a++) counter is int, length is u_int
178 if/while comparisons
13 A4GL_assertion() bounds checks
35 other

Only the first group is meaningless: the counter starts at zero, so the signed
comparison is what was meant all along. Those are now cast - 829 rewritten
mechanically from the compiler's own diagnostics and verified by rebuilding,
plus 3 by hand in ace.yacc, screen.yacc and helper_funcs.ec, which the script
skipped because a #line directive makes the reported column unreliable.

The other 226 are left visible on purpose. The assertions are the reason:

A4GL_assertion(u->variable_id >= ...->variables.variables_len, "Invalid VARIABLE ID");

a negative variable_id converts to a huge unsigned here, so the assertion fires
and catches it. Casting the length to int would let a negative index through
into the array access. Anything that hides this category hides that too.

Two of the casts change behaviour, both for the better:

lib/libform/form_generic/formwrite2.c:439
lib/liblex/lex_esqlc/compile_c.c:2927
for (a = 0; a < (int)(len - 1); a++)

With len==0 the old code computed 0-1 as unsigned, so an empty list ran the
loop UINT_MAX times instead of not at all. Both loops mean "all but the last
element", and now they do that.

What is left: format-overflow 159 (sprintf in the yacc grammars, worth a proper
look), unused-variable 64, missing-prototypes 61, unused-const-variable 48,
redundant-decls 48, plus the bison grammar warnings and the ~19 real bug
candidates noted previously.

mikeaubury 1 day ago

1 2 3 4 > >> (Page 1 of 4)
changed /aubit4glsrc/trunk/compilers/4glc/clobber.c
changed /aubit4glsrc/trunk/compilers/4glc/commands.c
changed /aubit4glsrc/trunk/compilers/4glc/common.c
changed /aubit4glsrc/trunk/compilers/4glc/expr_as_string_when_possible.c
changed /aubit4glsrc/trunk/compilers/4glc/extendedmap.c
changed /aubit4glsrc/trunk/compilers/4glc/globals.c
changed /aubit4glsrc/trunk/compilers/4glc/import.c
changed /aubit4glsrc/trunk/compilers/4glc/lexer.c
changed /aubit4glsrc/trunk/compilers/4glc/linearise.c
changed /aubit4glsrc/trunk/compilers/4glc/lint.c
changed /aubit4glsrc/trunk/compilers/4glc/map.c
changed /aubit4glsrc/trunk/compilers/4glc/mod.c
changed /aubit4glsrc/trunk/compilers/4glc/parsehelp.c
changed /aubit4glsrc/trunk/compilers/4glc/prototypes.c
changed /aubit4glsrc/trunk/compilers/4glc/variables.c
changed /aubit4glsrc/trunk/compilers/4glc/variables_new.c
changed /aubit4glsrc/trunk/compilers/ace/ace.yacc
changed /aubit4glsrc/trunk/compilers/ace/data.c
changed /aubit4glsrc/trunk/compilers/ace/dump.c
changed /aubit4glsrc/trunk/compilers/ace/dump_4gl.c
changed /aubit4glsrc/trunk/compilers/fcompile/create_default.c
changed /aubit4glsrc/trunk/compilers/fcompile/dump.c
changed /aubit4glsrc/trunk/compilers/fcompile/dump_form.c
changed /aubit4glsrc/trunk/compilers/fcompile/dump_scr.c
changed /aubit4glsrc/trunk/compilers/fcompile/fcompile.c
/aubit4glsrc/trunk/compilers/4glc/clobber.c Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/4glc/commands.c Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/4glc/common.c Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/4glc/expr_as_string_when_possible.c Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/4glc/extendedmap.c Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/4glc/globals.c Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/4glc/import.c Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/4glc/lexer.c Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/4glc/linearise.c Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/4glc/lint.c Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/4glc/map.c Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/4glc/mod.c Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/4glc/parsehelp.c Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/4glc/prototypes.c Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/4glc/variables.c Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/4glc/variables_new.c Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/ace/ace.yacc Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/ace/data.c Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/ace/dump.c Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/ace/dump_4gl.c Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/fcompile/create_default.c Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/fcompile/dump.c Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/fcompile/dump_form.c Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/fcompile/dump_scr.c Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/fcompile/fcompile.c Diff Switch to side-by-side view
Loading...
1 2 3 4 > >> (Page 1 of 4)