check_overflow: don't complain about if (ptr < &array[ARRAY_SIZE(array)])
commitd95d60047de039829fe424e4ed86762b0c66f58e
authorDan Carpenter <error27@gmail.com>
Sun, 14 Feb 2010 20:19:08 +0000 (14 23:19 +0300)
committerDan Carpenter <error27@gmail.com>
Sun, 14 Feb 2010 20:19:08 +0000 (14 23:19 +0300)
tree6410a4f703669c0eab69f91adb316255c050c929
parent12d17821c13ab20703fd7d412d7b8f2c53492c22
check_overflow:  don't complain about if (ptr < &array[ARRAY_SIZE(array)])

This is a common way of looping over an array.

for (p = a; p < &a[ARRAY_SIZE(a)]; p++)
printf("%d\n", *p);

I was strict about which places to not complain about.  The offset has
to be known at compile time.  It has to be a comparison.

The bad bit is that if you dereference p after the end of the array
smatch will not complain.  That should maybe be added to another check.

Signed-off-by: Dan Carpenter <error27@gmail.com>
check_overflow.c
validation/sm_array_overflow3.c [new file with mode: 0644]