From: Dan Carpenter Date: Thu, 19 Dec 2013 16:58:21 +0000 (+0300) Subject: flow: fix struct initialization bug X-Git-Tag: 1.60~452 X-Git-Url: https://repo.or.cz/w/smatch.git/commitdiff_plain/1e2ecd6329c1a83dad469165482e1070b9eff2a3 flow: fix struct initialization bug The index wasn't getting incremented properly so it got confused about which members were initialized and which were supposed to be set to zero. Signed-off-by: Dan Carpenter --- diff --git a/smatch_flow.c b/smatch_flow.c index b1aff677..ad1f2dcb 100644 --- a/smatch_flow.c +++ b/smatch_flow.c @@ -907,11 +907,15 @@ static void set_unset_to_zero(struct expression *symbol, struct symbol *type, st continue; } member_type = get_real_base_type(member); - if (!member_type || member_type->type == SYM_ARRAY) + if (!member_type || member_type->type == SYM_ARRAY) { + member_idx++; continue; + } /* TODO: this should be handled recursively and not ignored */ - if (member_type->type == SYM_STRUCT || member_type->type == SYM_UNION) + if (member_type->type == SYM_STRUCT || member_type->type == SYM_UNION) { + member_idx++; continue; + } deref = member_expression(symbol, '.', member->ident); assign = assign_expression(deref, zero_expr()); __split_expr(assign);