From 2e60f50a35e867f4a6ffb91d7ddf09685a2d87e9 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 30 Jan 2015 18:34:18 +0300 Subject: [PATCH] type_val: ignore kmalloc() It's true that kmalloc() does set the data to unknown values, but if we ever use the unknown values, that is another problem and should eventually trigger a different kind of warning. So since these unknown values are never used, it means we can ignore them. Signed-off-by: Dan Carpenter --- smatch_type_val.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/smatch_type_val.c b/smatch_type_val.c index 74482caf..85e8097f 100644 --- a/smatch_type_val.c +++ b/smatch_type_val.c @@ -193,6 +193,23 @@ static int is_ignored_macro(void) return 0; } +static int is_ignored_function(void) +{ + struct expression *expr; + + expr = get_faked_expression(); + if (!expr || expr->type != EXPR_ASSIGNMENT) + return 0; + expr = strip_expr(expr->right); + if (!expr || expr->type != EXPR_CALL || expr->fn->type != EXPR_SYMBOL) + return 0; + + if (sym_name_is("kmalloc", expr->fn)) + return 1; + + return 0; +} + static int is_uncasted_function(void) { struct expression *expr; @@ -227,6 +244,8 @@ static void match_assign_value(struct expression *expr) if (is_fake_call(expr->right)) { if (is_ignored_macro()) goto free; + if (is_ignored_function()) + goto free; if (is_uncasted_function()) goto free; add_fake_type_val(member, alloc_whole_rl(get_type(expr->left)), is_ignored_fake_assignment()); -- 2.11.4.GIT