All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v3] checkpatch: warn about uses of ENOTSUPP
@ 2020-05-11 17:08 Jakub Kicinski
  2020-05-11 17:16 ` Joe Perches
  2020-05-12  0:00 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Jakub Kicinski @ 2020-05-11 17:08 UTC (permalink / raw)
  To: Joe Perches, davem; +Cc: netdev, andrew, linux-kernel, 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
>>> 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/20200510182252.GA411829@lunn.ch/

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/20200511165319.2251678-1-kuba@kernel.org/

v1:
https://lore.kernel.org/netdev/20200510185148.2230767-1-kuba@kernel.org/

Suggested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Acked-by: Joe Perches <joe@perches.com>
---
 scripts/checkpatch.pl | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index eac40f0abd56..2be07ed4d70c 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -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 &&
-- 
2.25.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next v3] checkpatch: warn about uses of ENOTSUPP
  2020-05-11 17:08 [PATCH net-next v3] checkpatch: warn about uses of ENOTSUPP Jakub Kicinski
@ 2020-05-11 17:16 ` Joe Perches
  2020-05-11 20:43   ` David Miller
  2020-05-12  0:00 ` David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Joe Perches @ 2020-05-11 17:16 UTC (permalink / raw)
  To: Jakub Kicinski, davem; +Cc: netdev, andrew, linux-kernel

On Mon, 2020-05-11 at 10:08 -0700, Jakub Kicinski wrote:
> 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.
> 
> Recent example:
> https://lore.kernel.org/netdev/20200510182252.GA411829@lunn.ch/
> 
> 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/20200511165319.2251678-1-kuba@kernel.org/
> 
> v1:
> https://lore.kernel.org/netdev/20200510185148.2230767-1-kuba@kernel.org/
> 
> Suggested-by: Andrew Lunn <andrew@lunn.ch>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> Acked-by: Joe Perches <joe@perches.com>
> ---

Thanks.

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



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next v3] checkpatch: warn about uses of ENOTSUPP
  2020-05-11 17:16 ` Joe Perches
@ 2020-05-11 20:43   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2020-05-11 20:43 UTC (permalink / raw)
  To: joe; +Cc: kuba, netdev, andrew, linux-kernel

From: Joe Perches <joe@perches.com>
Date: Mon, 11 May 2020 10:16:34 -0700

> 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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next v3] checkpatch: warn about uses of ENOTSUPP
  2020-05-11 17:08 [PATCH net-next v3] checkpatch: warn about uses of ENOTSUPP Jakub Kicinski
  2020-05-11 17:16 ` Joe Perches
@ 2020-05-12  0:00 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2020-05-12  0:00 UTC (permalink / raw)
  To: kuba; +Cc: joe, netdev, andrew, linux-kernel

From: Jakub Kicinski <kuba@kernel.org>
Date: Mon, 11 May 2020 10:08:07 -0700

> 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.
> 
> Recent example:
> https://lore.kernel.org/netdev/20200510182252.GA411829@lunn.ch/
> 
> 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/20200511165319.2251678-1-kuba@kernel.org/
> 
> v1:
> https://lore.kernel.org/netdev/20200510185148.2230767-1-kuba@kernel.org/
> 
> Suggested-by: Andrew Lunn <andrew@lunn.ch>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> Acked-by: Joe Perches <joe@perches.com>

Applied, thanks Jakub.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-05-12  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-11 17:08 [PATCH net-next v3] checkpatch: warn about uses of ENOTSUPP Jakub Kicinski
2020-05-11 17:16 ` Joe Perches
2020-05-11 20:43   ` David Miller
2020-05-12  0:00 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.