flow: fix struct initialization bug
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 19 Dec 2013 16:58:21 +0000 (19 19:58 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Thu, 19 Dec 2013 16:58:21 +0000 (19 19:58 +0300)
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 <dan.carpenter@oracle.com>
smatch_flow.c

index b1aff67..ad1f2dc 100644 (file)
@@ -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);