Print this page
new smatch

Split Close
Expand all
Collapse all
          --- old/usr/src/tools/smatch/src/smatch_param_used.c
          +++ new/usr/src/tools/smatch/src/smatch_param_used.c
↓ open down ↓ 23 lines elided ↑ open up ↑
  24   24  static struct stree_stack *saved_stack;
  25   25  
  26   26  STATE(used);
  27   27  
  28   28  static void get_state_hook(int owner, const char *name, struct symbol *sym)
  29   29  {
  30   30          int arg;
  31   31  
  32   32          if (!option_info)
  33   33                  return;
  34      -        if (__in_fake_assign || __in_fake_parameter_assign || __in_function_def)
       34 +
       35 +        if (__in_fake_assign || __in_fake_parameter_assign || __in_function_def || __in_unmatched_hook)
  35   36                  return;
  36   37  
  37   38          arg = get_param_num_from_sym(sym);
  38      -        if (arg >= 0)
  39      -                set_state_stree(&used_stree, my_id, name, sym, &used);
       39 +        if (arg < 0)
       40 +                return;
       41 +        if (param_was_set_var_sym(name, sym))
       42 +                return;
       43 +        set_state_stree(&used_stree, my_id, name, sym, &used);
  40   44  }
  41   45  
  42   46  static void set_param_used(struct expression *call, struct expression *arg, char *key, char *unused)
  43   47  {
  44   48          struct symbol *sym;
  45   49          char *name;
  46   50          int arg_nr;
  47   51  
       52 +        if (!option_info)
       53 +                return;
       54 +
  48   55          name = get_variable_from_key(arg, key, &sym);
  49   56          if (!name || !sym)
  50   57                  goto free;
  51   58  
  52   59          arg_nr = get_param_num_from_sym(sym);
  53      -        if (arg_nr >= 0)
  54      -                set_state_stree(&used_stree, my_id, name, sym, &used);
       60 +        if (arg_nr < 0)
       61 +                goto free;
       62 +        if (param_was_set_var_sym(name, sym))
       63 +                goto free;
       64 +        set_state_stree(&used_stree, my_id, name, sym, &used);
  55   65  free:
  56   66          free_string(name);
  57   67  }
  58   68  
  59   69  static void process_states(void)
  60   70  {
  61   71          struct sm_state *tmp;
  62   72          int arg;
  63   73          const char *name;
  64   74  
↓ open down ↓ 50 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX