1/// Unsigned expressions cannot be lesser than zero. Presence of
2/// comparisons 'unsigned (<|<=) 0' often indicates a bug,
3/// usually wrong type of variable.
4///
5// Confidence: High
6// Copyright: (C) 2015 Andrzej Hajda, Samsung Electronics Co., Ltd. GPLv2.
7// URL: http://coccinelle.lip6.fr/
8
9virtual org
10virtual report
11
12@r_cmp depends on !(file in "ext")@
13position p;
14typedef uint8_t, uint16_t, uint32_t, uint64_t;
15{unsigned char, unsigned short, unsigned int, unsigned long, unsigned long long,
16	size_t, uint8_t, uint16_t, uint32_t, uint64_t} v;
17@@
18
19	(\( v@p < 0 \| v@p <= 0 \))
20
21@script:python depends on org@
22p << r_cmp.p;
23@@
24
25msg = "WARNING: Unsigned expression compared with zero."
26coccilib.org.print_todo(p[0], msg)
27
28@script:python depends on report@
29p << r_cmp.p;
30@@
31
32msg = "WARNING: Unsigned expression compared with zero."
33coccilib.report.print_report(p[0], msg)
34