2 * smatch/check_return.c
4 * Copyright (C) 2010 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
11 #include "smatch_slist.h"
15 static void must_check(const char *fn
, struct expression
*expr
, void *data
)
17 struct statement
*stmt
;
19 stmt
= last_ptr_list((struct ptr_list
*)big_statement_stack
);
20 if (stmt
->type
== STMT_EXPRESSION
&& stmt
->expression
== expr
)
21 sm_msg("warn: unchecked '%s'", fn
);
24 static void register_must_check_funcs(void)
28 static char name
[256];
31 snprintf(name
, 256, "%s.must_check_funcs", option_project_str
);
33 token
= get_tokens_file(name
);
36 if (token_type(token
) != TOKEN_STREAMBEGIN
)
39 while (token_type(token
) != TOKEN_STREAMEND
) {
40 if (token_type(token
) != TOKEN_IDENT
)
42 func
= show_ident(token
->ident
);
43 add_function_hook(func
, &must_check
, NULL
);
49 void check_return(int id
)
52 register_must_check_funcs();