2 * Copyright (C) 2010 Dan Carpenter.
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"
23 static void must_check(const char *fn
, struct expression
*expr
, void *data
)
25 struct statement
*stmt
;
27 stmt
= last_ptr_list((struct ptr_list
*)big_statement_stack
);
28 if (stmt
->type
== STMT_EXPRESSION
&& stmt
->expression
== expr
)
29 sm_msg("warn: unchecked '%s'", fn
);
32 static void register_must_check_funcs(void)
36 static char name
[256];
39 snprintf(name
, 256, "%s.must_check_funcs", option_project_str
);
41 token
= get_tokens_file(name
);
44 if (token_type(token
) != TOKEN_STREAMBEGIN
)
47 while (token_type(token
) != TOKEN_STREAMEND
) {
48 if (token_type(token
) != TOKEN_IDENT
)
50 func
= show_ident(token
->ident
);
51 add_function_hook(func
, &must_check
, NULL
);
57 void check_return(int id
)
60 register_must_check_funcs();