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_container_of.c
          +++ new/usr/src/tools/smatch/src/smatch_container_of.c
↓ open down ↓ 520 lines elided ↑ open up ↑
 521  521                  if (!type)
 522  522                          return NULL;
 523  523          }
 524  524  
 525  525          if (star || type->type == SYM_BASETYPE) {
 526  526                  run_sql(save_vals, &db_info,
 527  527                          "select value from mtag_data where tag = %lld and offset = %d and type = %d;",
 528  528                          tag, arg_offset, DATA_VALUE);
 529  529          } else {  /* presumably the parameter is a struct pointer */
 530  530                  run_sql(save_vals, &db_info,
 531      -                        "select offset, value from mtag_data where tag = %lld and type = %d;",
      531 +                        "select offset, value from mtag_data where tag = %lld and type = %d order by offset;",
 532  532                          tag, DATA_VALUE);
 533  533          }
 534  534  
 535  535          if (db_info.prev_offset != -1)
 536  536                  set_param_value(&db_info.stree, arg, db_info.prev_offset, db_info.rl);
 537  537  
 538  538          // FIXME: handle an offset correctly
 539  539          if (!star && !arg_offset) {
 540  540                  sval_t sval;
 541  541  
↓ open down ↓ 30 lines elided ↑ open up ↑
 572  572                  return;
 573  573  
 574  574          if (!get_toplevel_mtag(cur_func_sym, &cur_tag))
 575  575                  return;
 576  576  
 577  577          while (true) {
 578  578                  container_offset = strtoul(p, &p, 0);
 579  579                  if (local_debug)
 580  580                          sm_msg("%s: cur_tag = %llu container_offset = %d",
 581  581                                 __func__, cur_tag, container_offset);
 582      -                if (!mtag_map_select_container(cur_tag, container_offset, &container_tag))
      582 +                if (!mtag_map_select_container(cur_tag, -container_offset, &container_tag))
 583  583                          return;
 584  584                  cur_tag = container_tag;
 585  585                  if (local_debug)
 586  586                          sm_msg("%s: container_tag = %llu p = '%s'",
 587  587                                 __func__, container_tag, p);
 588  588                  if (!p)
 589  589                          return;
 590  590                  if (p[0] != '-')
 591  591                          break;
 592  592                  p++;
↓ open down ↓ 3 lines elided ↑ open up ↑
 596  596                  return;
 597  597  
 598  598          p++;
 599  599          arg_offset = strtoul(p, &p, 0);
 600  600          if (p && *p && *p != ')')
 601  601                  return;
 602  602  
 603  603          if (!arg_offset || star) {
 604  604                  arg_tag = container_tag;
 605  605          } else {
 606      -                if (!mtag_map_select_tag(container_tag, -arg_offset, &arg_tag))
      606 +                if (!mtag_map_select_tag(container_tag, arg_offset, &arg_tag))
 607  607                          return;
 608  608          }
 609  609  
 610  610          stree = load_tag_info_sym(arg_tag, arg, arg_offset, star);
 611  611          FOR_EACH_SM(stree, sm) {
 612  612                  set_state(sm->owner, sm->name, sm->sym, sm->state);
 613  613          } END_FOR_EACH_SM(sm);
 614  614          free_stree(&stree);
 615  615  }
 616  616  
↓ open down ↓ 31 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX