From 47beedc2779e676ba43de589d22823a3a1ecb54f Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 9 May 2013 10:00:44 +0300 Subject: [PATCH] math: handle sizeof for zero size bitfields It's valid to define a bit field as holding zero bits and this is used in the kernel. Signed-off-by: Dan Carpenter --- smatch_math.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/smatch_math.c b/smatch_math.c index 17cabb21..e7b47145 100644 --- a/smatch_math.c +++ b/smatch_math.c @@ -704,9 +704,12 @@ static sval_t handle_sizeof(struct expression *expr) examine_symbol_type(sym); ret.type = size_t_ctype; - if (sym->bit_size <= 0) /* sizeof(void) */ - ret.value = 1; - else + if (sym->bit_size <= 0) /* sizeof(void) */ { + if (get_real_base_type(sym) == &void_ctype) + ret.value = 1; + else + ret.value = 0; + } else ret.value = bits_to_bytes(sym->bit_size); return ret; -- 2.11.4.GIT