smatch_type: never refer to ->bit_size directly
commit26d77513fb2bfd97a03cc1e0492cebd9f60e0408
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 16 Apr 2014 11:52:37 +0000 (16 14:52 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Wed, 16 Apr 2014 11:52:37 +0000 (16 14:52 +0300)
treeddaa294f012eebc76ee6ad2f4c2d07b8cd9789f8
parentf28e8d607f8dd8d5bc56e11706711935235b6a31
smatch_type: never refer to ->bit_size directly

I'm going to change how smatch handles sizeof() and it it ends up meaning
that sometimes we encounter type symbols which haven't been evaluated yet.
This means we sometimes need to call examine_symbol_type() before looking
looking at ->bit_size.  This should happen in one place which is
type_bits().  So always call type_bits() instead of looking at
sym->bit_size.

It turns out as well that most times we want the size in bytes instead of
bits.  I have introduced type_bytes() for this.

check_stack.c was checking the size of the stack usage but everything was
stored in bits instead of bytes and that doesn't make sense.  I have
changed everything to use bytes here.

In smatch_buf_size.c it was checking for -1 bytes but never worked.  We can
have -1 bits but -1 / 8 is zero.  type_bytes() never returns negatives.
check_kmalloc_wrong_size.c had the same issue.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
13 files changed:
check_cast_assign.c
check_kmalloc_wrong_size.c
check_overflow.c
check_pointer_math.c
check_precedence.c
check_rosenberg.c
check_signed.c
check_stack.c
smatch.h
smatch_buf_size.c
smatch_helper.c
smatch_math.c
smatch_type.c