From: Andy Whitcroft Date: Tue, 26 Oct 2010 21:23:14 +0000 (-0700) Subject: checkpatch: returning errno typically should be negative X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=53a3c4487a05b8f26ef72fe434a750a3402c998f;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git 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 Signed-off-by: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 3cec2990d51e..bcdb54bd61a0 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)\(/) {