From da551d77ad62946b3dc701b27895333f5666b0ef Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 12 Jun 2013 10:31:16 +0300 Subject: [PATCH] comparison: pull get_comparison_strings() into its own function I have pulled get_comparison_strings() into a separate patch instead of doing it inside get_comparison(). I will use this new helper function again in a later patch. Signed-off-by: Dan Carpenter --- smatch_comparison.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/smatch_comparison.c b/smatch_comparison.c index ffda7e50..14371f9b 100644 --- a/smatch_comparison.c +++ b/smatch_comparison.c @@ -425,22 +425,13 @@ static void match_assign(struct expression *expr) match_normal_assign(expr); } -int get_comparison(struct expression *a, struct expression *b) +static int get_comparison_strings(char *one, char *two) { - char *one = NULL; - char *two = NULL; char buf[256]; struct smatch_state *state; int invert = 0; int ret = 0; - one = expr_to_var(a); - if (!one) - goto free; - two = expr_to_var(b); - if (!two) - goto free; - if (strcmp(one, two) > 0) { char *tmp = one; @@ -457,6 +448,23 @@ int get_comparison(struct expression *a, struct expression *b) if (invert) ret = flip_op(ret); + return ret; +} + +int get_comparison(struct expression *a, struct expression *b) +{ + char *one = NULL; + char *two = NULL; + int ret = 0; + + one = expr_to_var(a); + if (!one) + goto free; + two = expr_to_var(b); + if (!two) + goto free; + + ret = get_comparison_strings(one, two); free: free_string(one); free_string(two); -- 2.11.4.GIT