summaryrefslogtreecommitdiff
path: root/scripts/checkpatch.pl
diff options
context:
space:
mode:
authorPatrick Pannuto <ppannuto@codeaurora.org>2010-07-23 13:34:18 -0700
committerDavid Keitel <dkeitel@codeaurora.org>2016-03-23 20:51:39 -0700
commit769b0796d59658ecac2be4313eda52874acedd67 (patch)
treee8eeb882d7c874137f3bdd44991b3e945e01be13 /scripts/checkpatch.pl
parentb6d250b4e795c16dacde427b8f00ac8c2091dedd (diff)
checkpatch: Check for illegal return codes
The only legal integer return is 0, anything else following "return" should be -ERRCODE or a function. http://lkml.org/lkml/2010/7/23/318 There's lots of "return -1;" statements in this patch - it's obscene that this is used to indicate "some error occurred" in kernel space rather than a real errno value - even when an existing function (eg, request_irq) gave you an error code already. Please note this for the future - and please review patches on this point internally first. Change-Id: I16268b2ee034f0b3b899115e45c28acfa734ddec Signed-off-by: Patrick Pannuto <ppannuto@codeaurora.org> (cherry picked from commit 39531a47164294315b5a7256b520fe22d6e87013) Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-xscripts/checkpatch.pl6
1 files changed, 6 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 8866ce3abdc8..0939b70a4230 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5587,6 +5587,12 @@ sub process {
"switch default: should use break\n" . $herectx);
}
+# check for return codes on error paths
+ if ($line =~ /\breturn\s+-\d+/) {
+ ERROR("NO_ERROR_CODE",
+ "illegal return value, please use an error code");
+ }
+
# check for gcc specific __FUNCTION__
if ($line =~ /\b__FUNCTION__\b/) {
if (WARN("USE_FUNC",