From: Dan Carpenter Date: Thu, 19 Dec 2013 15:23:39 +0000 (+0300) Subject: unreachable code: don't warn about unreachable break statements X-Git-Tag: 1.60~456 X-Git-Url: https://repo.or.cz/w/smatch.git/commitdiff_plain/33f400b44e2323853c868f1feebe424ae176a711 unreachable code: don't warn about unreachable break statements A lot of people do stuff like: switch (foo) { case X: .... return ret; break; case Y: I think it sucks when people do this. Smatch used to warn about it when --spammy was enabled, but actually I never sent patches for these. Signed-off-by: Dan Carpenter --- diff --git a/smatch_flow.c b/smatch_flow.c index 3532bfc4..b1aff677 100644 --- a/smatch_flow.c +++ b/smatch_flow.c @@ -516,7 +516,9 @@ static void print_unreached(struct statement *stmt) return; break; case STMT_GOTO: - if (!option_spammy) + /* people put extra breaks inside switch statements */ + if (stmt->goto_label && stmt->goto_label->type == SYM_NODE && + strcmp(stmt->goto_label->ident->name, "break") == 0) return; break; default: