From 6443fae2e8c28d5e0dae115e5cff1759f67bfb21 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 16 Mar 2010 14:08:47 +0300 Subject: [PATCH] math: cleanup: make handling binops a switch() statement Signed-off-by: Dan Carpenter --- smatch_math.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/smatch_math.c b/smatch_math.c index 9416776f..5bf0a231 100644 --- a/smatch_math.c +++ b/smatch_math.c @@ -82,25 +82,36 @@ static long long handle_binop(struct expression *expr, int *discard, int *undefi left = _get_value(expr->left, discard, undefined, implied); right = _get_value(expr->right, discard, undefined, implied); - if (expr->op == '*') { + + switch (expr->op) { + case '*': ret = left * right; - } else if (expr->op == '/') { + break; + case '/': ret = left / right; - } else if (expr->op == '+') { + break; + case '+': ret = left + right; - } else if (expr->op == '-') { + break; + case '-': ret = left - right; - } else if (expr->op == '|') { + break; + case '|': ret = left | right; - } else if (expr->op == '&') { + break; + case '&': ret = left & right; - } else if (expr->op == SPECIAL_RIGHTSHIFT) { + break; + case SPECIAL_RIGHTSHIFT: ret = left >> right; - } else if (expr->op == SPECIAL_LEFTSHIFT) { + break; + case SPECIAL_LEFTSHIFT: ret = left << right; - } else if (expr->op == '^') { + break; + case '^': ret = left ^ right; - } else { + break; + default: *undefined = 1; *discard = 1; } -- 2.11.4.GIT