check_sizeof_pointer: complain about sizeof(&foo)
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 19 Nov 2012 18:59:21 +0000 (19 21:59 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Mon, 19 Nov 2012 18:59:21 +0000 (19 21:59 +0300)
There aren't any cases of this in the kernel.  I think someone else already
fixed them all.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
check_sizeof_pointer.c

index 7879628..118ec10 100644 (file)
@@ -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);
 }