From 33f400b44e2323853c868f1feebe424ae176a711 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 19 Dec 2013 18:23:39 +0300 Subject: [PATCH] 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 --- smatch_flow.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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: -- 2.11.4.GIT