*new* check_macros: find macro precedence bugs
[smatch.git] / check_kernel.c
blob458d978ac138b2e938db8567f24cfb16738a0aa8
1 /*
2 * sparse/check_kernel.c
4 * Copyright (C) 2010 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
8 */
11 * This is kernel specific stuff for smatch_extra.
14 #include "smatch.h"
15 #include "smatch_extra.h"
17 static void match_param_nonnull(const char *fn, struct expression *call_expr,
18 struct expression *assign_expr, void *_param)
20 int param = (int)_param;
21 struct expression *arg;
22 struct smatch_state *pre_state;
23 struct smatch_state *true_state;
25 arg = get_argument_from_call_expr(call_expr->args, param);
26 pre_state = get_state_expr(SMATCH_EXTRA, arg);
27 true_state = add_filter(pre_state, 0);
28 set_extra_expr_nomod(arg, true_state);
31 void check_kernel(int id)
33 if (option_project != PROJ_KERNEL)
34 return;
36 return_implies_state("IS_ERR_OR_NULL", 0, 0, &match_param_nonnull, (void *)0);
37 return_implies_state("tomoyo_memory_ok", 1, 1, &match_param_nonnull, (void *)0);