unreachable: silence "not actually initialized" false positives
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 22 May 2014 09:35:04 +0000 (22 12:35 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Thu, 22 May 2014 09:35:04 +0000 (22 12:35 +0300)
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 <dan.carpenter@oracle.com>
check_unreachable.c

index 63b1253..d906540 100644 (file)
@@ -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;
 }