Print this page
new smatch


 108 
 109         arg_expr = get_argument_from_call_expr(expr->args, arg_no);
 110         if (get_state_expr(my_id, arg_expr))
 111                 set_state_expr(my_id, arg_expr, &unallocated);
 112         set_equiv_state_expr(my_id, arg_expr, &unallocated);
 113 }
 114 
 115 static void match_unwind_function(const char *fn, struct expression *expr, void *unused)
 116 {
 117         set_state(my_id, "unwind_function", NULL, &called);
 118 }
 119 
 120 static int func_returns_int(void)
 121 {
 122         struct symbol *type;
 123 
 124         type = get_base_type(cur_func_sym);
 125         if (!type || type->type != SYM_FN)
 126                 return 0;
 127         type = get_base_type(type);
 128         if (type->ctype.base_type == &int_type) {
 129                 return 1;
 130         }
 131         return 0;
 132 }
 133 
 134 static void match_return(struct expression *ret_value)
 135 {
 136         struct stree *stree;
 137         struct sm_state *tmp;
 138         sval_t sval;
 139 
 140         if (!func_returns_int())
 141                 return;
 142         if (get_value(ret_value, &sval) && sval_cmp_val(sval, 0) >= 0)
 143                 return;
 144         if (!implied_not_equal(ret_value, 0))
 145                 return;
 146         if (get_state(my_id, "unwind_function", NULL) == &called)
 147                 return;
 148 




 108 
 109         arg_expr = get_argument_from_call_expr(expr->args, arg_no);
 110         if (get_state_expr(my_id, arg_expr))
 111                 set_state_expr(my_id, arg_expr, &unallocated);
 112         set_equiv_state_expr(my_id, arg_expr, &unallocated);
 113 }
 114 
 115 static void match_unwind_function(const char *fn, struct expression *expr, void *unused)
 116 {
 117         set_state(my_id, "unwind_function", NULL, &called);
 118 }
 119 
 120 static int func_returns_int(void)
 121 {
 122         struct symbol *type;
 123 
 124         type = get_base_type(cur_func_sym);
 125         if (!type || type->type != SYM_FN)
 126                 return 0;
 127         type = get_base_type(type);
 128         if (type && type->ctype.base_type == &int_type) {
 129                 return 1;
 130         }
 131         return 0;
 132 }
 133 
 134 static void match_return(struct expression *ret_value)
 135 {
 136         struct stree *stree;
 137         struct sm_state *tmp;
 138         sval_t sval;
 139 
 140         if (!func_returns_int())
 141                 return;
 142         if (get_value(ret_value, &sval) && sval_cmp_val(sval, 0) >= 0)
 143                 return;
 144         if (!implied_not_equal(ret_value, 0))
 145                 return;
 146         if (get_state(my_id, "unwind_function", NULL) == &called)
 147                 return;
 148