From: Dan Carpenter Date: Thu, 22 May 2014 09:35:04 +0000 (+0300) Subject: unreachable: silence "not actually initialized" false positives X-Git-Tag: 1.60~245 X-Git-Url: https://repo.or.cz/w/smatch.git/commitdiff_plain/e3cceb77b347ff0f2ed54bd91c9c6fe387d4130c unreachable: silence "not actually initialized" false positives Sometimes temporary variables are declared inside macros like list_for_each() but we don't reach those variables. The fix for this is to push the is_ignored_macro() test earlier into this function. Signed-off-by: Dan Carpenter --- diff --git a/check_unreachable.c b/check_unreachable.c index 63b12538..d9065402 100644 --- a/check_unreachable.c +++ b/check_unreachable.c @@ -146,6 +146,10 @@ static void unreachable_stmt(struct statement *stmt) if (!print_unreached) return; + if (empty_statement(stmt)) + return; + if (is_ignored_macro(stmt)) + return; switch (stmt->type) { case STMT_COMPOUND: /* after a switch before a case stmt */ @@ -168,10 +172,6 @@ static void unreachable_stmt(struct statement *stmt) default: break; } - if (empty_statement(stmt)) - return; - if (is_ignored_macro(stmt)) - return; sm_msg("info: ignoring unreachable code."); print_unreached = 0; }