math: handle MOD operation better
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 7 Feb 2013 06:52:12 +0000 (7 09:52 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Thu, 7 Feb 2013 06:52:12 +0000 (7 09:52 +0300)
For implied_min and implied_max we should pretty much only look at the
right side.  We could look at the left, but it's a bit of code to do that
properly.

If we want only one value then we need to look at the left side.

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

index 08050c4..2805b4a 100644 (file)
@@ -258,13 +258,12 @@ static sval_t handle_mod(struct expression *expr, int *undefined, int implied)
                return bogus;
        }
 
-       left = _get_value(expr->left, undefined, implied);
-       if (!*undefined)
-               return sval_binop(left, '%', right);
-
        switch (implied) {
        case NOTIMPLIED:
        case IMPLIED:
+               left = _get_value(expr->left, undefined, implied);
+               if (!*undefined)
+                       return sval_binop(left, '%', right);
                return bogus;
        case IMPLIED_MIN:
        case FUZZY_MIN: