Print this page
12166 resync smatch to 0.6.1-rc1-il-3

Split Close
Expand all
Collapse all
          --- old/usr/src/tools/smatch/src/check_frees_param.c
          +++ new/usr/src/tools/smatch/src/check_frees_param.c
↓ open down ↓ 21 lines elided ↑ open up ↑
  22   22   */
  23   23  
  24   24  #include "smatch.h"
  25   25  #include "smatch_extra.h"
  26   26  #include "smatch_slist.h"
  27   27  
  28   28  static int my_id;
  29   29  
  30   30  STATE(freed);
  31   31  STATE(ignore);
  32      -STATE(param);
  33   32  
  34   33  static void set_ignore(struct sm_state *sm, struct expression *mod_expr)
  35   34  {
  36   35          set_state(my_id, sm->name, sm->sym, &ignore);
  37   36  }
  38   37  
  39      -static void match_function_def(struct symbol *sym)
  40      -{
  41      -        struct symbol *arg;
  42      -        int i;
  43      -
  44      -        i = -1;
  45      -        FOR_EACH_PTR(sym->ctype.base_type->arguments, arg) {
  46      -                i++;
  47      -                if (!arg->ident)
  48      -                        continue;
  49      -                set_state(my_id, arg->ident->name, arg, &param);
  50      -        } END_FOR_EACH_PTR(arg);
  51      -}
  52      -
  53   38  static void freed_variable(struct expression *expr)
  54   39  {
  55   40          struct sm_state *sm;
  56   41  
  57   42          expr = strip_expr(expr);
  58   43          if (get_param_num(expr) < 0)
  59   44                  return;
  60   45  
  61   46          sm = get_sm_state_expr(my_id, expr);
  62   47          if (sm && slist_has_state(sm->possible, &ignore))
↓ open down ↓ 41 lines elided ↑ open up ↑
 104   89  
 105   90  void check_frees_param(int id)
 106   91  {
 107   92          my_id = id;
 108   93  
 109   94          if (option_project == PROJ_KERNEL) {
 110   95                  /* The kernel uses check_frees_param_strict.c */
 111   96                  return;
 112   97          }
 113   98  
 114      -        add_hook(&match_function_def, FUNC_DEF_HOOK);
 115      -
 116   99          add_function_hook("free", &match_free, INT_PTR(0));
 117  100  
 118  101          select_return_implies_hook(PARAM_FREED, &set_param_freed);
 119  102          add_modification_hook(my_id, &set_ignore);
 120  103  
 121  104          all_return_states_hook(&process_states);
 122  105  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX