forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/…
…mmarek/kbuild Pull misc kbuild updates from Michal Marek: - Fix for make O=... perf-tar* - make tags revamp and fix for the fallout. Patch for warnings about line breaks inside DEFINE_PER_CPU macros is pending - New coccinelle test * 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild: coccinelle: tests: unsigned value cannot be lesser than zero tags: Unify emacs and exuberant rules tags: Drop the _PE rule tags: Do not try to index defconfigs tags: Process Kconfig files in a single pass tags: Fix erroneous pattern match in a comment aic7xxx: Avoid name collision with <linux/list.h> tags: Treat header files as C code package Makefile: fix perf-tar targets when outdir is set scripts/tags.sh: Teach tags about more powerpc macros
- Loading branch information
Showing
8 changed files
with
188 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/// 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.