From dc4e47c54430cbadeb6320341f9296ac33c9bfb9 Mon Sep 17 00:00:00 2001 From: Patrick Pannuto Date: Fri, 23 Jul 2010 13:34:18 -0700 Subject: [PATCH] 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 (cherry picked from commit 39531a47164294315b5a7256b520fe22d6e87013) --- scripts/checkpatch.pl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 5b524669e5e..77bc0fef38d 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3446,6 +3446,11 @@ sub process { "Statements terminations use 1 semicolon\n" . $herecurr); } +# check for return codes on error paths + if ($line =~ /\breturn\s+-\d+/) { + ERROR("illegal return value, please use an error code"); + } + # check for gcc specific __FUNCTION__ if ($line =~ /__FUNCTION__/) { WARN("USE_FUNC",