lkml.org 
[lkml]   [2018]   [Jul]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] checkpatch: Check for illegal return codes
Date
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.

Signed-off-by: Patrick Pannuto <ppannuto@codeaurora.org>
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Signed-off-by: Prakruthi Deepak Heragu <pheragu@codeaurora.org>
---
scripts/checkpatch.pl | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index a9c0550..260d252 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6197,6 +6197,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",
--
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
\
 
 \ /
  Last update: 2018-07-03 20:10    [W:0.064 / U:0.624 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site