Print this page
new smatch


 251 
 252         if (__in_fake_assign)
 253                 return;
 254 
 255         right = strip_expr(expr->right);
 256         type = get_type(right);
 257         if (!type || type->type != SYM_PTR)
 258                 return;
 259 
 260         param = get_param_num(right);
 261         if (param < 0)
 262                 return;
 263 
 264         set_state_expr(my_id, right, &untracked);
 265 }
 266 
 267 
 268 static void match_param_assign_in_asm(struct statement *stmt)
 269 {
 270 
 271         struct expression *expr;
 272         struct symbol *type;
 273         int state = 0;
 274         int param;
 275 
 276         FOR_EACH_PTR(stmt->asm_inputs, expr) {
 277                 switch (state) {
 278                 case 0: /* identifier */
 279                 case 1: /* constraint */
 280                         state++;
 281                         continue;
 282                 case 2: /* expression */
 283                         state = 0;
 284 
 285                         expr = strip_expr(expr);
 286                         type = get_type(expr);
 287                         if (!type || type->type != SYM_PTR)
 288                                 continue;
 289                         param = get_param_num(expr);
 290                         if (param < 0)
 291                                 continue;
 292                         set_state_expr(my_id, expr, &untracked);
 293                         continue;
 294                 }
 295         } END_FOR_EACH_PTR(expr);
 296 }
 297 
 298 static void match_inline_start(struct expression *expr)
 299 {
 300         push_int(&tracked_stack, tracked);
 301 }
 302 
 303 static void match_inline_end(struct expression *expr)
 304 {
 305         tracked = pop_int(&tracked_stack);
 306 }
 307 
 308 void register_untracked_param(int id)
 309 {
 310         my_id = id;
 311 
 312         select_return_states_hook(INTERNAL, &assume_tracked);
 313         select_return_states_hook(UNTRACKED_PARAM, &mark_untracked);
 314         select_return_states_hook(LOST_PARAM, &mark_lost);
 315         add_hook(&match_after_call, FUNCTION_CALL_HOOK_AFTER_DB);


 251 
 252         if (__in_fake_assign)
 253                 return;
 254 
 255         right = strip_expr(expr->right);
 256         type = get_type(right);
 257         if (!type || type->type != SYM_PTR)
 258                 return;
 259 
 260         param = get_param_num(right);
 261         if (param < 0)
 262                 return;
 263 
 264         set_state_expr(my_id, right, &untracked);
 265 }
 266 
 267 
 268 static void match_param_assign_in_asm(struct statement *stmt)
 269 {
 270 
 271         struct expression *tmp, *expr;
 272         struct symbol *type;

 273         int param;
 274 
 275         FOR_EACH_PTR(stmt->asm_inputs, tmp) {
 276                 expr = strip_expr(tmp->expr);








 277                 type = get_type(expr);
 278                 if (!type || type->type != SYM_PTR)
 279                         continue;
 280                 param = get_param_num(expr);
 281                 if (param < 0)
 282                         continue;
 283                 set_state_expr(my_id, expr, &untracked);
 284         } END_FOR_EACH_PTR(tmp);


 285 }
 286 
 287 static void match_inline_start(struct expression *expr)
 288 {
 289         push_int(&tracked_stack, tracked);
 290 }
 291 
 292 static void match_inline_end(struct expression *expr)
 293 {
 294         tracked = pop_int(&tracked_stack);
 295 }
 296 
 297 void register_untracked_param(int id)
 298 {
 299         my_id = id;
 300 
 301         select_return_states_hook(INTERNAL, &assume_tracked);
 302         select_return_states_hook(UNTRACKED_PARAM, &mark_untracked);
 303         select_return_states_hook(LOST_PARAM, &mark_lost);
 304         add_hook(&match_after_call, FUNCTION_CALL_HOOK_AFTER_DB);