buf_size: remove the &* and [0] from around the pointer earlier
[smatch.git] / smatch_project.c
blob5fe8261e2dd6b23aa798de658184b6dd2f3e8ba5
1 /*
2 * sparse/smatch_project.c
4 * Copyright (C) 2010 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
8 */
11 * This file is only for very generic stuff, that is reusable
12 * between projects. If you need something special create a
13 * check_your_project.c.
17 #include "smatch.h"
18 #include "smatch_extra.h"
20 static void register_no_return_funcs(void)
22 struct token *token;
23 const char *func;
24 char name[256];
26 if (option_project == PROJ_NONE)
27 strcpy(name, "no_return_funcs");
28 else
29 snprintf(name, 256, "%s.no_return_funcs", option_project_str);
31 token = get_tokens_file(name);
32 if (!token)
33 return;
34 if (token_type(token) != TOKEN_STREAMBEGIN)
35 return;
36 token = token->next;
37 while (token_type(token) != TOKEN_STREAMEND) {
38 if (token_type(token) != TOKEN_IDENT)
39 return;
40 func = show_ident(token->ident);
41 add_function_hook(func, &__match_nullify_path_hook, NULL);
42 token = token->next;
44 clear_token_alloc();
47 static void return_implies(struct expression *call_expr, int param, char *key, char *value)
49 struct range_list *rl;
50 struct expression *arg;
52 arg = get_argument_from_call_expr(call_expr->args, param);
53 get_value_ranges(value, &rl);
54 set_extra_expr_nomod(arg, alloc_estate_range_list(rl));
57 static void register_ignored_macros(void)
59 struct token *token;
60 char *macro;
61 char name[256];
63 if (option_project == PROJ_NONE)
64 strcpy(name, "ignored_macros");
65 else
66 snprintf(name, 256, "%s.ignored_macros", option_project_str);
68 token = get_tokens_file(name);
69 if (!token)
70 return;
71 if (token_type(token) != TOKEN_STREAMBEGIN)
72 return;
73 token = token->next;
74 while (token_type(token) != TOKEN_STREAMEND) {
75 if (token_type(token) != TOKEN_IDENT)
76 return;
77 macro = alloc_string(show_ident(token->ident));
78 add_ptr_list(&__ignored_macros, macro);
79 token = token->next;
81 clear_token_alloc();
84 struct param_implication {
85 int param;
86 struct range_list *rl;
89 void register_project(int id)
91 register_no_return_funcs();
92 register_ignored_macros();
93 add_db_return_implies_callback(RANGE_CAP, &return_implies);