Print this page
new smatch


  87         struct range_list *rl;
  88 
  89         arg = get_argument_from_call_expr(call_expr->args, param);
  90         pre_state = get_state_expr(SMATCH_EXTRA, arg);
  91         if (estate_rl(pre_state)) {
  92                 rl = estate_rl(pre_state);
  93                 rl = remove_range(rl, null_ptr, null_ptr);
  94                 rl = remove_range(rl, err_ptr_min, err_ptr_max);
  95         } else {
  96                 rl = alloc_rl(valid_ptr_min_sval, valid_ptr_max_sval);
  97         }
  98         end_state = alloc_estate_rl(rl);
  99         set_extra_expr_nomod(arg, end_state);
 100 }
 101 
 102 static void match_param_err_or_null(const char *fn, struct expression *call_expr,
 103                         struct expression *assign_expr, void *_param)
 104 {
 105         int param = PTR_INT(_param);
 106         struct expression *arg;
 107         struct range_list *rl;
 108         struct smatch_state *pre_state;
 109         struct smatch_state *end_state;
 110 
 111         arg = get_argument_from_call_expr(call_expr->args, param);
 112         pre_state = get_state_expr(SMATCH_EXTRA, arg);




 113         call_results_to_rl(call_expr, &ptr_ctype, "0,(-4095)-(-1)", &rl);
 114         rl = rl_intersection(estate_rl(pre_state), rl);
 115         rl = cast_rl(get_type(arg), rl);
 116         end_state = alloc_estate_rl(rl);
 117         set_extra_expr_nomod(arg, end_state);
 118 }
 119 
 120 static void match_not_err(const char *fn, struct expression *call_expr,
 121                         struct expression *assign_expr, void *unused)
 122 {
 123         struct expression *arg;
 124         struct smatch_state *pre_state;
 125         struct range_list *rl;
 126 
 127         arg = get_argument_from_call_expr(call_expr->args, 0);
 128         pre_state = get_state_expr(SMATCH_EXTRA, arg);
 129         if (estate_rl(pre_state)) {
 130                 rl = estate_rl(pre_state);
 131                 rl = remove_range(rl, err_ptr_min, err_ptr_max);
 132         } else {
 133                 rl = alloc_rl(valid_ptr_min_sval, valid_ptr_max_sval);
 134         }




  87         struct range_list *rl;
  88 
  89         arg = get_argument_from_call_expr(call_expr->args, param);
  90         pre_state = get_state_expr(SMATCH_EXTRA, arg);
  91         if (estate_rl(pre_state)) {
  92                 rl = estate_rl(pre_state);
  93                 rl = remove_range(rl, null_ptr, null_ptr);
  94                 rl = remove_range(rl, err_ptr_min, err_ptr_max);
  95         } else {
  96                 rl = alloc_rl(valid_ptr_min_sval, valid_ptr_max_sval);
  97         }
  98         end_state = alloc_estate_rl(rl);
  99         set_extra_expr_nomod(arg, end_state);
 100 }
 101 
 102 static void match_param_err_or_null(const char *fn, struct expression *call_expr,
 103                         struct expression *assign_expr, void *_param)
 104 {
 105         int param = PTR_INT(_param);
 106         struct expression *arg;
 107         struct range_list *pre, *rl;
 108         struct smatch_state *pre_state;
 109         struct smatch_state *end_state;
 110 
 111         arg = get_argument_from_call_expr(call_expr->args, param);
 112         pre_state = get_state_expr(SMATCH_EXTRA, arg);
 113         if (pre_state)
 114                 pre = estate_rl(pre_state);
 115         else
 116                 pre = alloc_whole_rl(&ptr_ctype);
 117         call_results_to_rl(call_expr, &ptr_ctype, "0,(-4095)-(-1)", &rl);
 118         rl = rl_intersection(pre, rl);
 119         rl = cast_rl(get_type(arg), rl);
 120         end_state = alloc_estate_rl(rl);
 121         set_extra_expr_nomod(arg, end_state);
 122 }
 123 
 124 static void match_not_err(const char *fn, struct expression *call_expr,
 125                         struct expression *assign_expr, void *unused)
 126 {
 127         struct expression *arg;
 128         struct smatch_state *pre_state;
 129         struct range_list *rl;
 130 
 131         arg = get_argument_from_call_expr(call_expr->args, 0);
 132         pre_state = get_state_expr(SMATCH_EXTRA, arg);
 133         if (estate_rl(pre_state)) {
 134                 rl = estate_rl(pre_state);
 135                 rl = remove_range(rl, err_ptr_min, err_ptr_max);
 136         } else {
 137                 rl = alloc_rl(valid_ptr_min_sval, valid_ptr_max_sval);
 138         }