2018-11-06 16:38:30 +08:00
|
|
|
/// Unsigned expressions cannot be lesser than zero. Presence of
|
|
|
|
/// comparisons 'unsigned (<|<=) 0' often indicates a bug,
|
|
|
|
/// usually wrong type of variable.
|
|
|
|
///
|
|
|
|
// Confidence: High
|
|
|
|
// Copyright: (C) 2015 Andrzej Hajda, Samsung Electronics Co., Ltd. GPLv2.
|
|
|
|
// URL: http://coccinelle.lip6.fr/
|
|
|
|
|
|
|
|
virtual org
|
|
|
|
virtual report
|
|
|
|
|
|
|
|
@r_cmp depends on !(file in "ext")@
|
|
|
|
position p;
|
2020-05-28 00:26:57 +08:00
|
|
|
typedef uint8_t, uint16_t, uint32_t, uint64_t;
|
2018-11-06 16:38:30 +08:00
|
|
|
{unsigned char, unsigned short, unsigned int, unsigned long, unsigned long long,
|
2020-05-28 00:26:57 +08:00
|
|
|
size_t, uint8_t, uint16_t, uint32_t, uint64_t} v;
|
2018-11-06 16:38:30 +08:00
|
|
|
@@
|
|
|
|
|
|
|
|
(\( v@p < 0 \| v@p <= 0 \))
|
|
|
|
|
|
|
|
@script:python depends on org@
|
|
|
|
p << r_cmp.p;
|
|
|
|
@@
|
|
|
|
|
|
|
|
msg = "WARNING: Unsigned expression compared with zero."
|
|
|
|
coccilib.org.print_todo(p[0], msg)
|
|
|
|
|
|
|
|
@script:python depends on report@
|
|
|
|
p << r_cmp.p;
|
|
|
|
@@
|
|
|
|
|
|
|
|
msg = "WARNING: Unsigned expression compared with zero."
|
|
|
|
coccilib.report.print_report(p[0], msg)
|