diff options
author | Andy Whitcroft <apw@canonical.com> | 2010-10-26 14:23:14 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-26 16:52:20 -0700 |
commit | 53a3c4487a05b8f26ef72fe434a750a3402c998f (patch) | |
tree | dfe0b1f85cbf1082ceb52b71bb157cc715e22293 /scripts/checkpatch.pl | |
parent | 9446ef569c288e683225fec8337a0b2b81e75cc5 (diff) | |
download | linux-3.10-53a3c4487a05b8f26ef72fe434a750a3402c998f.tar.gz linux-3.10-53a3c4487a05b8f26ef72fe434a750a3402c998f.tar.bz2 linux-3.10-53a3c4487a05b8f26ef72fe434a750a3402c998f.zip |
checkpatch: returning errno typically should be negative
Add a (strict mode only) test to check for non-negative returns of what
appear to be errno values as the majority case these should indeed be
negative.
Suggested-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-x | scripts/checkpatch.pl | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 3cec2990d51..bcdb54bd61a 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2204,6 +2204,13 @@ sub process { ERROR("space required before the open parenthesis '('\n" . $herecurr); } } +# Return of what appears to be an errno should normally be -'ve + if ($line =~ /^.\s*return\s*(E[A-Z]*)\s*;/) { + my $name = $1; + if ($name ne 'EOF' && $name ne 'ERROR') { + WARN("return of an errno should typically be -ve (return -$1)\n" . $herecurr); + } + } # Need a space before open parenthesis after if, while etc if ($line=~/\b(if|while|for|switch)\(/) { |