/// Unsigned expressions cannot be lesser than zero. Presence of
/// comparisons 'unsigned (<|<=|>|>=) 0' often indicates a bug,
/// usually wrong type of variable.
///
/// To reduce number of false positives following tests have been added:
/// - parts of range checks are skipped, eg. "if (u < 0 || u > 15) ...",
/// developers prefer to keep such code,
/// - comparisons "<= 0" and "> 0" are performed only on results of
/// signed functions/macros,
/// - hardcoded list of signed functions/macros with always non-negative
/// result is used to avoid false positives difficult to detect by other ways
///
// Confidence: Average
// Copyright: (C) 2015 Andrzej Hajda, Samsung Electronics Co., Ltd. GPLv2.
// URL: http://coccinelle.lip6.fr/
// Options: --all-includes
virtual context
virtual org
virtual report
@r_cmp@
position p;
typedef bool, u8, u16, u32, u64;
{unsigned char, unsigned short, unsigned int, unsigned long, unsigned long long,
size_t, bool, u8, u16, u32, u64} v;
expression e;
@@
\( v = e \| &v \)
...
(\( v@p < 0 \| v@p <= 0 \| v@p >= 0 \| v@p > 0 \))
@r@
position r_cmp.p;
typedef s8, s16, s32, s64;
{char, short, int, long, long long, ssize_t, s8, s16, s32, s64} vs;
expression c, e, v;
identifier f !~ "^(ata_id_queue_depth|btrfs_copy_from_user|dma_map_sg|dma_map_sg_attrs|fls|fls64|gameport_time|get_write_extents|nla_len|ntoh24|of_flat_dt_match|of_get_child_count|uart_circ_chars_pending|[A-Z0-9_]+)$";
@@
(
v = f(...)@vs;
... when != v = e;
* (\( v@p <=@e 0 \| v@p >@e 0 \))
... when any
|
(
(\( v@p < 0 \| v@p <= 0 \)) || ... || (\( v >= c \| v > c \))
|
(\( v >= c \| v > c \)) || ... || (\( v@p < 0 \| v@p <= 0 \))
|
(\( v@p >= 0 \| v@p > 0 \)) && ... && (\( v < c \| v <= c \))
|
((\( v < c \| v <= c \) && ... && \( v@p >= 0 \| v@p > 0 \)))
|
* (\( v@p <@e 0 \| v@p >=@e 0 \))
)
)
@script:python depends on org@
p << r_cmp.p;
e << r.e;
@@
msg = "WARNING: Unsigned expression compared with zero: %s" % (e)
coccilib.org.print_todo(p[0], msg)
@script:python depends on report@
p << r_cmp.p;
e << r.e;
@@
msg = "WARNING: Unsigned expression compared with zero: %s" % (e)
coccilib.report.print_report(p[0], msg)
='hidden' name='id' value='83a718d6294964fd1b227fa5f1ad001bc1fe7656'/>
Merge branch 'libnvdimm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm
Pull DAX updates from Dan Williams:
"The completion of Jan's DAX work for 4.10.
As I mentioned in the libnvdimm-for-4.10 pull request, these are some
final fixes for the DAX dirty-cacheline-tracking invalidation work
that was merged through the -mm, ext4, and xfs trees in -rc1. These
patches were prepared prior to the merge window, but we waited for
4.10-rc1 to have a stable merge base after all the prerequisites were
merged.
Quoting Jan on the overall changes in these patches:
"So I'd like all these 6 patches to go for rc2. The first three
patches fix invalidation of exceptional DAX entries (a bug which
is there for a long time) - without these patches data loss can
occur on power failure even though user called fsync(2). The other
three patches change locking of DAX faults so that ->iomap_begin()
is called in a more relaxed locking context and we are safe to
start a transaction there for ext4"
These have received a build success notification from the kbuild
robot, and pass the latest libnvdimm unit tests. There have not been
any -next releases since -rc1, so they have not appeared there"
* 'libnvdimm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm:
ext4: Simplify DAX fault path
dax: Call ->iomap_begin without entry lock during dax fault
dax: Finish fault completely when loading holes
dax: Avoid page invalidation races and unnecessary radix tree traversals
mm: Invalidate DAX radix tree entries only if appropriate
ext2: Return BH_New buffers for zeroed blocks
Diffstat (limited to 'tools/testing/selftests/ftrace')