2 * sparse/check_freeing_null.c
4 * Copyright (C) 2010 Dan Carpenter.
6 * Licensed under the Open Software License version 1.1
14 static void match_free(const char *fn
, struct expression
*expr
, void *data
)
16 struct expression
*arg_expr
;
20 arg_expr
= get_argument_from_call_expr(expr
->args
, 0);
21 if (!get_implied_value(arg_expr
, &sval
))
25 name
= expr_to_var(arg_expr
);
26 sm_msg("warn: calling %s() when '%s' is always NULL.", fn
, name
);
30 void check_freeing_null(int id
)
35 if (option_project
== PROJ_KERNEL
)
36 add_function_hook("kfree", &match_free
, NULL
);
38 add_function_hook("free", &match_free
, NULL
);