From 16e53ce0d96ed9972a12fb0a6c40b8fa4762d6df Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Sat, 20 Apr 2013 14:07:15 +0300 Subject: [PATCH] flow: don't print duplicate "unreachable code" warnings We don't print these warnings inside inline functions but the flag to say if the warning had been printed or not was getting reset. It meant that the unreachable warning message was printed on multiple lines instead of just the first. Signed-off-by: Dan Carpenter --- smatch_flow.c | 3 +++ smatch_states.c | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/smatch_flow.c b/smatch_flow.c index 791b4da7..579f6957 100644 --- a/smatch_flow.c +++ b/smatch_flow.c @@ -481,6 +481,9 @@ static void print_unreached(struct statement *stmt) { static int print = 1; + if (__inline_fn) + return; + if (!__path_is_null()) { print = 1; return; diff --git a/smatch_states.c b/smatch_states.c index f141f056..def9a311 100644 --- a/smatch_states.c +++ b/smatch_states.c @@ -81,7 +81,8 @@ int unreachable(void) static int reset_warnings = 1; if (cur_slist) { - reset_warnings = 1; + if (!__inline_fn) + reset_warnings = 1; return 0; } @@ -91,7 +92,8 @@ int unreachable(void) /* option spammy turns on a noisier version of this */ if (reset_warnings && !option_spammy) sm_msg("info: ignoring unreachable code."); - reset_warnings = 0; + if (!__inline_fn) + reset_warnings = 0; return 1; } -- 2.11.4.GIT