extra: fix segfault parsing invalid code
[smatch.git] / check_db_info.c
blob2307efca5307874d84515c1aa49d6fa3b5e1aa80
1 /*
2 * smatch/check_db_info.c
4 * Copyright (C) 2010 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
8 */
10 #include "smatch.h"
11 #include "smatch_extra.h"
13 static int my_id;
15 static void match_return(struct expression *ret_value)
17 struct smatch_state *state;
18 long long val;
20 if (!ret_value)
21 return;
23 if (get_value(ret_value, &val)) {
24 sm_msg("info: return_value %lld", val);
25 return;
27 state = get_state_expr(SMATCH_EXTRA, ret_value);
28 if (!state) {
29 sm_msg("info: return_value unknown");
30 return;
32 sm_msg("info: return_value %s", state->name);
35 void check_db_info(int id)
37 if (!option_info)
38 return;
39 my_id = id;
40 add_hook(&match_return, RETURN_HOOK);