Print this page
12724 update smatch to 0.6.1-rc1-il-5

Split Close
Expand all
Collapse all
          --- old/usr/src/tools/smatch/src/smatch_struct_assignment.c
          +++ new/usr/src/tools/smatch/src/smatch_struct_assignment.c
↓ open down ↓ 143 lines elided ↑ open up ↑
 144  144          __split_expr(expr);
 145  145          __in_fake_struct_assign--;
 146  146          __in_fake_assign--;
 147  147  }
 148  148  
 149  149  static void handle_non_struct_assignments(struct expression *left, struct expression *right)
 150  150  {
 151  151          struct symbol *type;
 152  152          struct expression *assign;
 153  153  
      154 +        while (right && right->type == EXPR_ASSIGNMENT)
      155 +                right = strip_parens(right->left);
      156 +
 154  157          type = get_type(left);
 155  158          if (!type)
 156  159                  return;
 157  160          if (type->type == SYM_PTR) {
 158  161                  left = deref_expression(left);
 159  162                  if (right)
 160  163                          right = deref_expression(right);
 161  164                  else
 162  165                          right = unknown_value_expression(left);
 163  166                  assign = assign_expression(left, '=', right);
↓ open down ↓ 63 lines elided ↑ open up ↑
 227  230  static void __struct_members_copy(int mode, struct expression *faked,
 228  231                                    struct expression *left,
 229  232                                    struct expression *right)
 230  233  {
 231  234          struct symbol *struct_type, *tmp, *type;
 232  235          struct expression *left_member;
 233  236          struct expression *right_member;
 234  237          struct expression *assign;
 235  238          int op = '.';
 236  239  
 237      -
 238  240          if (__in_fake_assign)
 239  241                  return;
 240  242          faked_expression = faked;
 241  243  
 242  244          left = strip_expr(left);
 243  245          right = strip_expr(right);
 244  246  
      247 +        if (left->type == EXPR_PREOP && left->op == '*' && is_pointer(left))
      248 +                left = preop_expression(left, '(');
      249 +
 245  250          struct_type = get_struct_type(left);
 246  251          if (!struct_type) {
 247  252                  /*
 248  253                   * This is not a struct assignment obviously.  But this is where
 249  254                   * memcpy() is handled so it feels like a good place to add this
 250  255                   * code.
 251  256                   */
 252  257                  handle_non_struct_assignments(left, right);
 253  258                  goto done;
 254  259          }
↓ open down ↓ 325 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX