Print this page
11506 smatch resync


 141 
 142         FOR_EACH_MY_SM(SMATCH_EXTRA, __get_cur_stree(), tmp) {
 143                 param = get_param_num_from_sym(tmp->sym);
 144                 if (param < 0)
 145                         continue;
 146 
 147                 param_name = get_param_name(tmp);
 148                 if (!param_name)
 149                         continue;
 150 
 151                 state = __get_state(my_id, tmp->name, tmp->sym);
 152                 if (!state)
 153                         state = tmp->state;
 154 
 155                 if (estate_is_whole(state) || estate_is_empty(state))
 156                         continue;
 157                 old = get_state_stree(start_states, SMATCH_EXTRA, tmp->name, tmp->sym);
 158                 if (old && rl_equiv(estate_rl(old), estate_rl(state)))
 159                         continue;
 160 



 161                 rl = generify_mtag_range(state);
 162                 sql_insert_return_states(return_id, return_ranges, PARAM_LIMIT,
 163                                          param, param_name, show_rl(rl));
 164         } END_FOR_EACH_SM(tmp);
 165 }
 166 
 167 static void extra_mod_hook(const char *name, struct symbol *sym, struct expression *expr, struct smatch_state *state)
 168 {
 169         struct smatch_state *orig_vals;
 170         int param;
 171 
 172         param = get_param_num_from_sym(sym);
 173         if (param < 0)
 174                 return;
 175 
 176         orig_vals = get_orig_estate_type(name, sym, estate_type(state));
 177         set_state(my_id, name, sym, orig_vals);
 178 }
 179 
 180 static void match_save_states(struct expression *expr)
 181 {
 182         push_stree(&saved_stack, start_states);
 183         start_states = NULL;
 184 }
 185 
 186 static void match_restore_states(struct expression *expr)
 187 {
 188         free_stree(&start_states);
 189         start_states = pop_stree(&saved_stack);
 190 }
 191 
 192 void register_param_limit(int id)
 193 {
 194         my_id = id;
 195 

 196         add_hook(&save_start_states, AFTER_DEF_HOOK);
 197         add_hook(&free_start_states, AFTER_FUNC_HOOK);
 198 
 199         add_extra_mod_hook(&extra_mod_hook);
 200         add_unmatched_state_hook(my_id, &unmatched_state);
 201         add_merge_hook(my_id, &merge_estates);
 202 
 203         add_hook(&match_save_states, INLINE_FN_START);
 204         add_hook(&match_restore_states, INLINE_FN_END);
 205 
 206         add_split_return_callback(&print_return_value_param);
 207 }
 208 


 141 
 142         FOR_EACH_MY_SM(SMATCH_EXTRA, __get_cur_stree(), tmp) {
 143                 param = get_param_num_from_sym(tmp->sym);
 144                 if (param < 0)
 145                         continue;
 146 
 147                 param_name = get_param_name(tmp);
 148                 if (!param_name)
 149                         continue;
 150 
 151                 state = __get_state(my_id, tmp->name, tmp->sym);
 152                 if (!state)
 153                         state = tmp->state;
 154 
 155                 if (estate_is_whole(state) || estate_is_empty(state))
 156                         continue;
 157                 old = get_state_stree(start_states, SMATCH_EXTRA, tmp->name, tmp->sym);
 158                 if (old && rl_equiv(estate_rl(old), estate_rl(state)))
 159                         continue;
 160 
 161                 if (is_ignored_kernel_data(param_name))
 162                         continue;
 163 
 164                 rl = generify_mtag_range(state);
 165                 sql_insert_return_states(return_id, return_ranges, PARAM_LIMIT,
 166                                          param, param_name, show_rl(rl));
 167         } END_FOR_EACH_SM(tmp);
 168 }
 169 
 170 static void extra_mod_hook(const char *name, struct symbol *sym, struct expression *expr, struct smatch_state *state)
 171 {
 172         struct smatch_state *orig_vals;
 173         int param;
 174 
 175         param = get_param_num_from_sym(sym);
 176         if (param < 0)
 177                 return;
 178 
 179         orig_vals = get_orig_estate_type(name, sym, estate_type(state));
 180         set_state(my_id, name, sym, orig_vals);
 181 }
 182 
 183 static void match_save_states(struct expression *expr)
 184 {
 185         push_stree(&saved_stack, start_states);
 186         start_states = NULL;
 187 }
 188 
 189 static void match_restore_states(struct expression *expr)
 190 {
 191         free_stree(&start_states);
 192         start_states = pop_stree(&saved_stack);
 193 }
 194 
 195 void register_param_limit(int id)
 196 {
 197         my_id = id;
 198 
 199         set_dynamic_states(my_id);
 200         add_hook(&save_start_states, AFTER_DEF_HOOK);
 201         add_hook(&free_start_states, AFTER_FUNC_HOOK);
 202 
 203         add_extra_mod_hook(&extra_mod_hook);
 204         add_unmatched_state_hook(my_id, &unmatched_state);
 205         add_merge_hook(my_id, &merge_estates);
 206 
 207         add_hook(&match_save_states, INLINE_FN_START);
 208         add_hook(&match_restore_states, INLINE_FN_END);
 209 
 210         add_split_return_callback(&print_return_value_param);
 211 }
 212