Print this page
11506 smatch resync


  15  * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
  16  */
  17 
  18 #include "smatch.h"
  19 #include "smatch_slist.h"
  20 #include "smatch_extra.h"
  21 
  22 static int my_id;
  23 
  24 STATE(positive);
  25 STATE(ok);
  26 
  27 static void ok_to_use(struct sm_state *sm, struct expression *mod_expr)
  28 {
  29         if (sm->state != &ok)
  30                 set_state(my_id, sm->name, sm->sym, &ok);
  31 }
  32 
  33 static void match_assign(const char *fn, struct expression *expr, void *unused)
  34 {






  35         set_state_expr(my_id, expr->left, &positive);
  36 }
  37 
  38 static void match_condition(struct expression *expr)
  39 {
  40         if (!get_state_expr(my_id, expr))
  41                 return;
  42         /* If the variable is zero that's ok */
  43         set_true_false_states_expr(my_id, expr, NULL, &ok);
  44 }
  45 
  46 static void match_return(struct expression *ret_value)
  47 {
  48         struct smatch_state *state;
  49         struct sm_state *sm;
  50         sval_t min;
  51 
  52         sm = get_sm_state_expr(my_id, ret_value);
  53         if (!sm)
  54                 return;




  15  * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
  16  */
  17 
  18 #include "smatch.h"
  19 #include "smatch_slist.h"
  20 #include "smatch_extra.h"
  21 
  22 static int my_id;
  23 
  24 STATE(positive);
  25 STATE(ok);
  26 
  27 static void ok_to_use(struct sm_state *sm, struct expression *mod_expr)
  28 {
  29         if (sm->state != &ok)
  30                 set_state(my_id, sm->name, sm->sym, &ok);
  31 }
  32 
  33 static void match_assign(const char *fn, struct expression *expr, void *unused)
  34 {
  35         struct range_list *rl;
  36 
  37         if (!get_implied_rl(expr->right, &rl))
  38                 return;
  39         if (rl_max(rl).value != 1)
  40                 return;
  41         set_state_expr(my_id, expr->left, &positive);
  42 }
  43 
  44 static void match_condition(struct expression *expr)
  45 {
  46         if (!get_state_expr(my_id, expr))
  47                 return;
  48         /* If the variable is zero that's ok */
  49         set_true_false_states_expr(my_id, expr, NULL, &ok);
  50 }
  51 
  52 static void match_return(struct expression *ret_value)
  53 {
  54         struct smatch_state *state;
  55         struct sm_state *sm;
  56         sval_t min;
  57 
  58         sm = get_sm_state_expr(my_id, ret_value);
  59         if (!sm)
  60                 return;