Closed rtolkacheva closed 1 year ago
Missing breaks in swtich-case statements can and should be detected by the compiler. gcc
has the -Wimplicit-fallthrough
flag that enables this check. This flag is enabled in the Tarantool main repository so there's no need to have this check implemented in checkpatch.
I saw a commit that contained switch/case and switch/default statements without
break
,return
, or explicitFALLTHROUGH
macro. The breaks should have been included but were accidentally omitted in the commit and were fixed later. Now there are two similar errors that thecheckpatch
can already find:PREFER_FALLTHROUGH
andDEFAULT_NO_BREAK
. Here are their descriptions from the documentation:Neither of them detects the possible error of forgotten breaks in switch/case and in non-empty switch/default. I see a possible solution: to check all switch/case and switch/default statements to ensure they end with
break
,return
, or theFALLTHROUGH
macro.