Skip to contentSkip to conversation

checkpatch: warn about uses of ENOTSUPP

PATCH Applied Jakub Kicinski 3 participants 4 messages May 11, 2020 – May 12, 2020

Subsystems (3)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH v3 1/1 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
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

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.

Recent example:
https://lore.kernel.org/netdev/[email protected]/

v3 (Joe):
- fix the "not file" condition.

v2 (Joe):
- add a link to recent discussion,
- don't match when scanning files, not patches to avoid sudden influx of conversion patches.
https://lore.kernel.org/netdev/[email protected]/

v1:
https://lore.kernel.org/netdev/[email protected]/

---
 scripts/checkpatch.pl | 11 +++++++++++
 1 file changed, 11 insertions(+)
scripts/checkpatch.pl +11 -0
index eac40f0abd56..2be07ed4d70c 100755
@@ -4199,6 +4199,17 @@ sub process {
 			     "ENOSYS means 'invalid syscall nr' and nothing else\n" . $herecurr);
 		}
 
+# ENOTSUPP is not a standard error code and should be avoided in new patches.
+# Folks usually mean EOPNOTSUPP (also called ENOTSUP), when they type ENOTSUPP.
+# Similarly to ENOSYS warning a small number of false positives is expected.
+		if (!$file && $line =~ /\bENOTSUPP\b/) {
+			if (WARN("ENOTSUPP",
+				 "ENOTSUPP is not a SUSV4 error code, prefer EOPNOTSUPP\n" . $herecurr) &&
+			    $fix) {
+				$fixed[$fixlinenr] =~ s/\bENOTSUPP\b/EOPNOTSUPP/;
+			}
+		}
+
 # function brace can't be on same line, except for #defines of do while,
 # or if closed on same line
 		if ($perl_version_ok &&
Signature · 1 line
2.25.4
maintainer
#1 lore raw
Quoted 28 lines · Jakub Kicinski

ENOTSUPP often feels like the right error code to use, but it's in fact not a standard Unix error. E.g.:

$ python
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

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.

Recent example:
https://lore.kernel.org/netdev/[email protected]/

v3 (Joe):
- fix the "not file" condition.

v2 (Joe):
- add a link to recent discussion,
- don't match when scanning files, not patches to avoid sudden influx of conversion patches.
https://lore.kernel.org/netdev/[email protected]/

Quoted 7 lines

v1:
https://lore.kernel.org/netdev/[email protected]/

---

Thanks.

No worries here and it's not worth a respin, but typically the patch changelog goes below the --- line.

maintainer
#2 lore raw

From: Joe Perches <[email protected]>
Date: Mon, 11 May 2020 10:16:34 -0700

Quoted 2 lines

No worries here and it's not worth a respin, but typically the patch changelog goes below the --- line.

I ask people explicitly to keep the changelog in the commit message proper, the more information we have in the GIT history the better.

maintainer Applied
#3 lore raw
In reply to Jakub Kicinski

From: Jakub Kicinski <[email protected]>
Date: Mon, 11 May 2020 10:08:07 -0700

Quoted 28 lines

ENOTSUPP often feels like the right error code to use, but it's in fact not a standard Unix error. E.g.:

$ python
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

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.

Recent example:
https://lore.kernel.org/netdev/[email protected]/

v3 (Joe):
- fix the "not file" condition.

v2 (Joe):
- add a link to recent discussion,
- don't match when scanning files, not patches to avoid sudden influx of conversion patches.
https://lore.kernel.org/netdev/[email protected]/

Quoted 6 lines

v1:
https://lore.kernel.org/netdev/[email protected]/

Applied, thanks Jakub.