Dual pass system [patch #1]
[smatch.git] / check_type.c
blob2401654722f52451a91afd0c64bf07e901041527
1 /*
2 * sparse/check_type.c
4 * Copyright (C) 2009 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
8 */
10 #include "smatch.h"
12 static int my_id;
14 static void match_free(const char *fn, struct expression *expr, void *data)
16 struct expression *arg_expr;
17 char *name;
18 struct symbol *sym;
19 struct symbol *type;
21 arg_expr = get_argument_from_call_expr(expr->args, 0);
22 name = get_variable_from_expr(arg_expr, &sym);
23 if (!name ||!sym)
24 goto exit;
25 type = get_ptr_type(arg_expr);
26 if (type && type->ident && !strcmp("sk_buff", type->ident->name))
27 sm_msg("error: use kfree_skb() here instead of kfree()");
28 exit:
29 free_string(name);
32 void check_type(int id)
34 if (!option_spammy)
35 return;
37 my_id = id;
38 add_function_hook("kfree", &match_free, NULL);