buf_size: first get the size in bytes then convert to elements
commita7c7764499591fb7908573a9622f3297f49a8fd8
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 13 Jun 2012 13:53:09 +0000 (13 16:53 +0300)
committerDan Carpenter <dan.carpenter@oracle.com>
Wed, 13 Jun 2012 13:53:09 +0000 (13 16:53 +0300)
treea1df38bfc38387ee39f294ddaa54f3b4ad5896bd
parent6628c310ce41b1e23922637040fea0fe164be01d
buf_size: first get the size in bytes then convert to elements

This is a cleanup and reduces the number of lines needed.

get_array_size_bytes() was already handling some things as a special case
because it wanted to avoid rounding errors from converting from
bytes -> elements -> bytes.  Using bytes first and handling elements as
a special case is a more logical in some ways.

This also fixes the issue of casting.  We first get the number of bytes and
then we calculate the number of elements.

Also I'm not sure why get_array_size_bytes() queries the DB but
get_array_size() did not query the DB.  But this changes that as well.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch_buf_size.c
validation/sm_buf_size3.c [new file with mode: 0644]