]> granicus.if.org Git - postgresql/commit
Clean up warnings from -Wimplicit-fallthrough.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 1 May 2018 23:35:08 +0000 (19:35 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 1 May 2018 23:35:08 +0000 (19:35 -0400)
commit41c912cad15955b5f9270ef3688a44e91d410d3d
tree829397c0ab0c3fdd1863b3ddc9cd9caffc5a3729
parent1667148a4dd98cea28b8b53d57dbc1eece1b0b5c
Clean up warnings from -Wimplicit-fallthrough.

Recent gcc can warn about switch-case fall throughs that are not
explicitly labeled as intentional.  This seems like a good thing,
so clean up the warnings exposed thereby by labeling all such
cases with comments that gcc will recognize.

In files that already had one or more suitable comments, I generally
matched the existing style of those.  Otherwise I went with
/* FALLTHROUGH */, which is one of the spellings approved at the
more-restrictive-than-default level -Wimplicit-fallthrough=4.
(At the default level you can also spell it /* FALL ?THRU */,
and it's not picky about case.  What you can't do is include
additional text in the same comment, so some existing comments
containing versions of this aren't good enough.)

Testing with gcc 8.0.1 (Fedora 28's current version), I found that
I also had to put explicit "break"s after elog(ERROR) or ereport(ERROR);
apparently, for this purpose gcc doesn't recognize that those don't
return.  That seems like possibly a gcc bug, but it's fine because
in most places we did that anyway; so this amounts to a visit from the
style police.

Discussion: https://postgr.es/m/15083.1525207729@sss.pgh.pa.us
28 files changed:
contrib/btree_gin/btree_gin.c
contrib/pageinspect/hashfuncs.c
src/backend/access/hash/hashfunc.c
src/backend/catalog/objectaddress.c
src/backend/commands/explain.c
src/backend/commands/indexcmds.c
src/backend/commands/trigger.c
src/backend/executor/execMain.c
src/backend/executor/execReplication.c
src/backend/executor/nodeLockRows.c
src/backend/executor/nodeModifyTable.c
src/backend/parser/gram.y
src/backend/parser/parse_utilcmd.c
src/backend/regex/regc_lex.c
src/backend/regex/regcomp.c
src/backend/tcop/postgres.c
src/backend/utils/adt/acl.c
src/backend/utils/adt/datetime.c
src/backend/utils/adt/numeric.c
src/backend/utils/adt/ruleutils.c
src/backend/utils/adt/timestamp.c
src/backend/utils/misc/guc.c
src/backend/utils/sort/tuplestore.c
src/bin/pgbench/pgbench.c
src/interfaces/ecpg/pgtypeslib/interval.c
src/interfaces/ecpg/preproc/ecpg.c
src/pl/plpgsql/src/pl_exec.c
src/pl/tcl/pltcl.c