unwind: literals higher than zero are not an error code
[smatch.git] / smatch_project.c
blobc6ea760d450034be5d06d1beffc83b9de61020fd
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 static char name[256];
27 snprintf(name, 256, "%s.no_return_funcs", option_project_str);
28 name[255] = '\0';
29 token = get_tokens_file(name);
30 if (!token)
31 return;
32 if (token_type(token) != TOKEN_STREAMBEGIN)
33 return;
34 token = token->next;
35 while (token_type(token) != TOKEN_STREAMEND) {
36 if (token_type(token) != TOKEN_IDENT)
37 return;
38 func = show_ident(token->ident);
39 add_function_hook(func, &__match_nullify_path_hook, NULL);
40 token = token->next;
42 clear_token_alloc();
45 static void register_ignored_macros(void)
47 struct token *token;
48 char *macro;
49 static char name[256];
51 snprintf(name, 256, "%s.ignored_macros", option_project_str);
52 name[255] = '\0';
53 token = get_tokens_file(name);
54 if (!token)
55 return;
56 if (token_type(token) != TOKEN_STREAMBEGIN)
57 return;
58 token = token->next;
59 while (token_type(token) != TOKEN_STREAMEND) {
60 if (token_type(token) != TOKEN_IDENT)
61 return;
62 macro = alloc_string(show_ident(token->ident));
63 add_ptr_list(&__ignored_macros, macro);
64 token = token->next;
66 clear_token_alloc();
69 void register_project(int id)
71 if (option_project != PROJ_KERNEL)
72 add_function_hook("exit", &__match_nullify_path_hook, NULL);
73 register_no_return_funcs();
74 register_ignored_macros();