* [PATCH v2] checkpatch.pl: New instances of ENOSYS are errors
@ 2014-08-22 16:26 Andy Lutomirski
2014-08-22 17:27 ` Joe Perches
2014-08-25 10:29 ` Pavel Machek
0 siblings, 2 replies; 4+ messages in thread
From: Andy Lutomirski @ 2014-08-22 16:26 UTC (permalink / raw)
To: Michael Kerrisk (man-pages), Andy Whitcroft, Joe Perches
Cc: linux-kernel, Andy Lutomirski
ENOSYS means that a nonexistent system call was called. We have a
bad habit of using it for things like invalid operations on
otherwise valid syscalls. We should avoid this in new code.
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
---
Pervasive incorrect usage of ENOSYS came up at the kernel summit ABI
review discussion. Let's see if checkpatch can help.
I'll submit a separate patch for include/uapi/asm-generic/errno.h.
Changes from v1:
- Moved later so that it won't warn on context lines.
- Use $herecur.
- Improve regex pattern.
scripts/checkpatch.pl | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 182be0f..0a68a29 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2931,6 +2931,14 @@ sub process {
"Prefer dev_$level(... to dev_printk(KERN_$orig, ...\n" . $herecurr);
}
+# ENOSYS means "bad syscall nr" and nothing else
+# (note that this doesn't run on assembly files, so entry*.S is okay)
+ if ($line =~ /\bENOSYS\b/) {
+ ERROR("ENOSYS",
+ "ENOSYS means 'invalid syscall nr' and nothing else\n" .
+ " (ignore if this really is syscall entry code)\n" . $herecurr);
+ }
+
# function brace can't be on same line, except for #defines of do while,
# or if closed on same line
if (($line=~/$Type\s*$Ident\(.*\).*\s{/) and
--
1.9.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] checkpatch.pl: New instances of ENOSYS are errors
2014-08-22 16:26 [PATCH v2] checkpatch.pl: New instances of ENOSYS are errors Andy Lutomirski
@ 2014-08-22 17:27 ` Joe Perches
2014-08-25 10:29 ` Pavel Machek
1 sibling, 0 replies; 4+ messages in thread
From: Joe Perches @ 2014-08-22 17:27 UTC (permalink / raw)
To: Andy Lutomirski; +Cc: Michael Kerrisk (man-pages), Andy Whitcroft, linux-kernel
On Fri, 2014-08-22 at 09:26 -0700, Andy Lutomirski wrote:
> ENOSYS means that a nonexistent system call was called. We have a
> bad habit of using it for things like invalid operations on
> otherwise valid syscalls. We should avoid this in new code.
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -2931,6 +2931,14 @@ sub process {
> "Prefer dev_$level(... to dev_printk(KERN_$orig, ...\n" . $herecurr);
> }
>
> +# ENOSYS means "bad syscall nr" and nothing else
> +# (note that this doesn't run on assembly files, so entry*.S is okay)
> + if ($line =~ /\bENOSYS\b/) {
> + ERROR("ENOSYS",
> + "ENOSYS means 'invalid syscall nr' and nothing else\n" .
> + " (ignore if this really is syscall entry code)\n" . $herecurr);
> + }
> +
> # function brace can't be on same line, except for #defines of do while,
> # or if closed on same line
> if (($line=~/$Type\s*$Ident\(.*\).*\s{/) and
Hi again Andy.
I think this is OK, but you seem to be making
this patch against an old version of checkpatch.
It applies with an offset of a few hundred lines
to Linus' tree and to -next.
Some trivial comments:
I think the "(note that" comment line isn't very useful.
All the tests after:
next if ($realfile !~ /\.(h|c)$/);
have that attribute.
checkpatch doesn't use multi-line message descriptions.
The "(ignore if this" line should not be on a separate line
but simply use a longer single output line.
ERROR types should not have false positives.
I'd prefer WARN.
cheers, Joe
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] checkpatch.pl: New instances of ENOSYS are errors
2014-08-22 16:26 [PATCH v2] checkpatch.pl: New instances of ENOSYS are errors Andy Lutomirski
2014-08-22 17:27 ` Joe Perches
@ 2014-08-25 10:29 ` Pavel Machek
2014-08-25 18:38 ` Andy Lutomirski
1 sibling, 1 reply; 4+ messages in thread
From: Pavel Machek @ 2014-08-25 10:29 UTC (permalink / raw)
To: Andy Lutomirski
Cc: Michael Kerrisk (man-pages), Andy Whitcroft, Joe Perches,
linux-kernel
On Fri 2014-08-22 09:26:31, Andy Lutomirski wrote:
> ENOSYS means that a nonexistent system call was called. We have a
> bad habit of using it for things like invalid operations on
> otherwise valid syscalls. We should avoid this in new code.
Is it good idea? I mean, doing EINVAL for subcalls is pretty
unhelpful.
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] checkpatch.pl: New instances of ENOSYS are errors
2014-08-25 10:29 ` Pavel Machek
@ 2014-08-25 18:38 ` Andy Lutomirski
0 siblings, 0 replies; 4+ messages in thread
From: Andy Lutomirski @ 2014-08-25 18:38 UTC (permalink / raw)
To: Pavel Machek
Cc: Joe Perches, Andy Whitcroft, Michael Kerrisk,
linux-kernel@vger.kernel.org
On Aug 25, 2014 3:29 AM, "Pavel Machek" <pavel@ucw.cz> wrote:
>
> On Fri 2014-08-22 09:26:31, Andy Lutomirski wrote:
> > ENOSYS means that a nonexistent system call was called. We have a
> > bad habit of using it for things like invalid operations on
> > otherwise valid syscalls. We should avoid this in new code.
>
> Is it good idea? I mean, doing EINVAL for subcalls is pretty
> unhelpful.
EOPNOTSUPP?
The problem is that user code wants to do:
bool foo_wrapper(int op)
{
if (foo_not_supported)
return false
if (foo(op) != 0) {
if (errno == ENOSYS)
foo_not_supported = true;
return false;
}
return true;
}
foo_wrapper(FOO_OP_A);
foo_wrapper(FOO_OP_B);
If FOO_OP_A returns -ENOSYS but FOO_OP_B does not, then this doesn't work.
--Andy
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-08-25 18:38 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-22 16:26 [PATCH v2] checkpatch.pl: New instances of ENOSYS are errors Andy Lutomirski
2014-08-22 17:27 ` Joe Perches
2014-08-25 10:29 ` Pavel Machek
2014-08-25 18:38 ` Andy Lutomirski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox