提交 53a3c448 编写于 作者: A Andy Whitcroft 提交者: Linus Torvalds

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: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NAndy Whitcroft <apw@canonical.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 9446ef56
...@@ -2204,6 +2204,13 @@ sub process { ...@@ -2204,6 +2204,13 @@ sub process {
ERROR("space required before the open parenthesis '('\n" . $herecurr); 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 # Need a space before open parenthesis after if, while etc
if ($line=~/\b(if|while|for|switch)\(/) { if ($line=~/\b(if|while|for|switch)\(/) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册