type: simplify get_binop_type()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 10 Oct 2012 06:30:27 +0000 (10 09:30 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Wed, 10 Oct 2012 06:30:27 +0000 (10 09:30 +0300)
Move a test for NULL a couple lines earlier.

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

index 1de6073..8e808a6 100644 (file)
@@ -31,14 +31,14 @@ static struct symbol *get_binop_type(struct expression *expr)
        left = get_type(expr->left);
        right = get_type(expr->right);
 
-       if (left && (left->type == SYM_PTR || left->type == SYM_ARRAY))
-               return left;
-       if (right && (right->type == SYM_PTR || right->type == SYM_ARRAY))
-               return right;
-
        if (!left || !right)
                return NULL;
 
+       if (left->type == SYM_PTR || left->type == SYM_ARRAY)
+               return left;
+       if (right->type == SYM_PTR || right->type == SYM_ARRAY)
+               return right;
+
        if (type_max(left) < type_max(&int_ctype) &&
            type_max(right) < type_max(&int_ctype))
                return &int_ctype;