[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200510185148.2230767-1-kuba@kernel.org>
Date: Sun, 10 May 2020 11:51:48 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Joe Perches <joe@...ches.com>, davem@...emloft.net
Cc: netdev@...r.kernel.org, Jakub Kicinski <kuba@...nel.org>,
Andrew Lunn <andrew@...n.ch>
Subject: [PATCH net-next] checkpatch: warn about uses of ENOTSUPP
ENOTSUPP often feels like the right error code to use, but it's
in fact not a standard Unix error. E.g.:
$ python
>>> import errno
>>> errno.errorcode[errno.ENOTSUPP]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'errno' has no attribute 'ENOTSUPP'
There were numerous commits converting the uses back to EOPNOTSUPP
but in some cases we are stuck with the high error code for backward
compatibility reasons.
Let's try prevent more ENOTSUPPs from getting into the kernel.
Suggested-by: Andrew Lunn <andrew@...n.ch>
Signed-off-by: Jakub Kicinski <kuba@...nel.org>
---
Hi Joe, I feel like I already talked to you about this, but I lost
my email archive, so appologies if you already said no.
scripts/checkpatch.pl | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index eac40f0abd56..254877620bd8 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4199,6 +4199,14 @@ sub process {
"ENOSYS means 'invalid syscall nr' and nothing else\n" . $herecurr);
}
+# ENOTSUPP is not a standard error code and should be avoided.
+# Folks usually mean EOPNOTSUPP (also called ENOTSUP), when they type ENOTSUPP.
+# Similarly to ENOSYS warning a small number of false positives is expected.
+ if ($line =~ /\bENOTSUPP\b/) {
+ WARN("ENOTSUPP",
+ "ENOTSUPP is not a standard error code, prefer EOPNOTSUPP.\n" . $herecurr);
+ }
+
# function brace can't be on same line, except for #defines of do while,
# or if closed on same line
if ($perl_version_ok &&
--
2.25.4
Powered by blists - more mailing lists