From fed96c1db6063ab325005d09fb8c785236aa741a Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 19 Nov 2012 21:59:21 +0300 Subject: [PATCH] check_sizeof_pointer: complain about sizeof(&foo) There aren't any cases of this in the kernel. I think someone else already fixed them all. Signed-off-by: Dan Carpenter --- check_sizeof_pointer.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/check_sizeof_pointer.c b/check_sizeof_pointer.c index 7879628f..118ec106 100644 --- a/check_sizeof_pointer.c +++ b/check_sizeof_pointer.c @@ -84,10 +84,18 @@ static void match_check_params(struct expression *call) } END_FOR_EACH_PTR(arg); } +static void match_sizeof(struct expression *expr) +{ + if (expr->type == EXPR_PREOP && expr->op == '&') { + sm_msg("warn: sizoef(&pointer)?"); + } +} + void check_sizeof_pointer(int id) { my_id = id; add_hook(&match_call_assignment, CALL_ASSIGNMENT_HOOK); add_hook(&match_check_params, FUNCTION_CALL_HOOK); + add_hook(&match_sizeof, SIZEOF_HOOK); } -- 2.11.4.GIT