From: Dan Carpenter Date: Mon, 19 Nov 2012 18:59:21 +0000 (+0300) Subject: check_sizeof_pointer: complain about sizeof(&foo) X-Git-Tag: 1.57~182 X-Git-Url: https://repo.or.cz/w/smatch.git/commitdiff_plain/fed96c1db6063ab325005d09fb8c785236aa741a 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 --- 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); }