From 04a122ec5645d2e3a41ecd653d1f3cecc9deb230 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 19 Nov 2012 19:46:08 +0300 Subject: [PATCH] sval: type: handle type_bits() for addresses Sparse doesn't set the ->bit_size field if you have an ampersand address. So say smatch has to evaluate the expression if (&foo - &bar > 0) { ... it wants to cast both sides to the right type but it doesn't know how. Signed-off-by: Dan Carpenter --- smatch_type.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/smatch_type.c b/smatch_type.c index 614235c9..6f71e44e 100644 --- a/smatch_type.c +++ b/smatch_type.c @@ -28,6 +28,8 @@ int type_bits(struct symbol *type) { if (!type) return 0; + if (type->type == SYM_PTR) /* Sparse doesn't set this for &pointers */ + return bits_in_pointer; return type->bit_size; } -- 2.11.4.GIT