From 369114c4b0c9a25f25934f6d458734386278693f Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 4 Dec 2017 15:31:41 +0300 Subject: [PATCH] struct_assignment: split handle_non_struct_assigments() into separate function This has no run time implications, it's just moves the code to a separate function. Signed-off-by: Dan Carpenter --- smatch_struct_assignment.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/smatch_struct_assignment.c b/smatch_struct_assignment.c index 8fdcdbc4..1cbcff05 100644 --- a/smatch_struct_assignment.c +++ b/smatch_struct_assignment.c @@ -137,6 +137,23 @@ static void split_fake_expr(struct expression *expr) __in_fake_assign--; } +static void handle_non_struct_assignments(struct expression *left, struct expression *right) +{ + struct symbol *type; + struct expression *assign; + + type = get_type(left); + if (!type || type->type != SYM_BASETYPE) + return; + right = strip_expr(right); + if (right && right->type == EXPR_PREOP && right->op == '&') + right = remove_addr(right); + else + right = unknown_value_expression(left); + assign = assign_expression(left, right); + split_fake_expr(assign); +} + static void set_inner_struct_members(int mode, struct expression *faked, struct expression *left, struct expression *right, struct symbol *member) { struct expression *left_member; @@ -212,18 +229,7 @@ static void __struct_members_copy(int mode, struct expression *faked, * memcpy() is handled so it feels like a good place to add this * code. */ - - type = get_type(left); - if (!type || type->type != SYM_BASETYPE) - goto done; - - right = strip_expr(right); - if (right && right->type == EXPR_PREOP && right->op == '&') - right = remove_addr(right); - else - right = unknown_value_expression(left); - assign = assign_expression(left, right); - split_fake_expr(assign); + handle_non_struct_assignments(left, right); goto done; } -- 2.11.4.GIT