db: track some more ==p1 return values
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 28 Jun 2013 13:27:54 +0000 (28 16:27 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Fri, 28 Jun 2013 13:27:54 +0000 (28 16:27 +0300)
The problem here is that the code thinks it can split apart the return
value into something meaningful because it knows how the function was
called.  But actually the parameter has not been modified within the
function.

So instead of splitting it apart just return that it is equal to a
parameter.

I added some NULL checks for void functions so we don't crash.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch_comparison.c
smatch_db.c

index a6bfea9..44c7d7f 100644 (file)
@@ -544,6 +544,8 @@ static char *chunk_to_var_sym(struct expression *expr, struct symbol **sym)
        char buf[128];
 
        expr = strip_expr(expr);
+       if (!expr)
+               return NULL;
        if (sym)
                *sym = NULL;
 
index 9be9f54..a09c0e1 100644 (file)
@@ -797,6 +797,9 @@ static int call_return_state_hooks_split_possible(struct expression *expr)
        char *compare_str;
        char buf[128];
 
+       if (!expr || expr_equal_to_param(expr))
+               return 0;
+
        sm = get_sm_state_expr(SMATCH_EXTRA, expr);
        if (!sm || !sm->merged)
                return 0;