kernel: use hard coded returns from IS_ERR() for u-boot
[smatch.git] / smatch_refcount.c
blob9ab785ee155cb2cf2e46ce24a41b3e8897815667
1 /*
2 * Copyright (C) 2021 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
18 #include "smatch.h"
19 #include "smatch_extra.h"
20 #include "smatch_slist.h"
22 static int my_id;
24 STATE(inc);
25 STATE(dec);
27 static void match_inc(struct expression *expr, const char *name, struct symbol *sym)
29 set_state(my_id, name, sym, &inc);
32 static void match_dec(struct expression *expr, const char *name, struct symbol *sym)
34 set_state(my_id, name, sym, &dec);
37 int was_inced(const char *name, struct symbol *sym)
39 return get_state(my_id, name, sym) == &inc;
42 void register_refcount(int id)
44 my_id = id;
46 if (option_project != PROJ_KERNEL)
47 return;
49 add_modification_hook(my_id, &set_undefined);
51 add_refcount_inc_hook(&match_inc);
52 add_refcount_dec_hook(&match_dec);