2 * Copyright (C) 2015 Oracle.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
19 #include "smatch_slist.h"
25 static void clear(struct sm_state
*sm
, struct expression
*mod_expr
)
27 set_state(my_id
, sm
->name
, sm
->sym
, &undefined
);
30 static void match_while_count_down(struct expression
*expr
)
32 struct statement
*stmt
= __cur_stmt
;
34 if (expr
->type
!= EXPR_POSTOP
|| expr
->op
!= SPECIAL_DECREMENT
)
37 if (!stmt
|| stmt
->type
!= STMT_ITERATOR
)
40 set_true_false_states_expr(my_id
, strip_expr(expr
->unop
), NULL
, &timed_out
);
43 static void match_test(struct expression
*expr
)
48 sm
= get_sm_state_expr(my_id
, expr
);
49 if (!sm
|| !slist_has_state(sm
->possible
, &timed_out
))
52 name
= expr_to_str(expr
);
53 sm_msg("warn: should this be '%s == -1'", name
);
57 void check_postop_timeout(int id
)
60 add_hook(&match_while_count_down
, CONDITION_HOOK
);
61 add_hook(&match_test
, CONDITION_HOOK
);
62 add_modification_hook(my_id
, &clear
);