UPSTREAM: coccinelle: tests: unsigned value cannot be lesser than zero
authorAndrzej Hajda <a.hajda@samsung.com>
Thu, 7 Jan 2016 09:36:51 +0000 (10:36 +0100)
committerHuang, Tao <huangtao@rock-chips.com>
Wed, 12 Jul 2017 13:17:10 +0000 (21:17 +0800)
commitb6927d861cef9c1a29a2b0d781db76d8e2e46353
tree45ebf8f737d1fe5e07a7de101a37ea3b4f19f932
parent0dc92faf3e93d11203bd3a50d12061456d76dc1a
UPSTREAM: coccinelle: tests: unsigned value cannot be lesser than zero

Unsigned expressions cannot be lesser than zero. Presence of comparisons
'unsigned (<|<=|>|>=) 0' often indicates a bug, usually wrong type of variable.
The patch beside finding such comparisons tries to eliminate false positives,
mainly by bypassing range checks.

gcc can detect such comparisons also using -Wtype-limits switch, but it warns
also in correct cases, making too much noise.

Change-Id: I9fbf55a16d9ae508ca46cba2f8292d5e4b4cc697
Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Michal Marek <mmarek@suse.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 3f984cb39907f87515d83657ecd471ae396a6c4a)
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [new file with mode: 0644]