All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] checkpatch.pl: New instances of ENOSYS are errors
@ 2014-08-22  4:13 Andy Lutomirski
  2014-08-22 10:06 ` Joe Perches
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Lutomirski @ 2014-08-22  4:13 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.

 scripts/checkpatch.pl | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 182be0f..5749a44 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2372,6 +2372,15 @@ sub process {
 			     "Using $1 is unnecessary\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 =~ /ENOSYS/) {
+			my $herevet = "$here\n" . cat_vet($line) . "\n";
+			ERROR("ENOSYS",
+			      "ENOSYS means 'invalid syscall nr' and nothing else\n" .
+			      "       (ignore if this really is syscall entry code)\n" . $herevet);
+		}
+
 # Check for potential 'bare' types
 		my ($stat, $cond, $line_nr_next, $remain_next, $off_next,
 		    $realline_next);
-- 
1.9.3


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

* Re: [PATCH] checkpatch.pl: New instances of ENOSYS are errors
  2014-08-22  4:13 [PATCH] checkpatch.pl: New instances of ENOSYS are errors Andy Lutomirski
@ 2014-08-22 10:06 ` Joe Perches
  0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2014-08-22 10:06 UTC (permalink / raw)
  To: Andy Lutomirski; +Cc: Michael Kerrisk (man-pages), Andy Whitcroft, linux-kernel

On Thu, 2014-08-21 at 23:13 -0500, 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
[]
> @@ -2372,6 +2372,15 @@ sub process {
>  			     "Using $1 is unnecessary\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 =~ /ENOSYS/) {
> +			my $herevet = "$here\n" . cat_vet($line) . "\n";
> +			ERROR("ENOSYS",
> +			      "ENOSYS means 'invalid syscall nr' and nothing else\n" .
> +			      "       (ignore if this really is syscall entry code)\n" . $herevet);
> +		}
> +

It seems this would be noisy.

ENOSYS seems to be used for a lot of other purposes
than syscalls.

Maybe this comment should be changed to clarify:

include/uapi/asm-generic/errno.h:#define        ENOSYS          38      /* Function not implemented */

And this should probably be:

		if ($line =~ /\bENOSYS\b/) {

The $herevet should be $herecurr

And this should be moved after line 2902 so that
it doesn't emit on patch context lines like:

$ git diff drivers/acpi/apei/erst.c
diff --git a/drivers/acpi/apei/erst.c b/drivers/acpi/apei/erst.c
index ed65e9c..acccc07 100644--git a
--- a/drivers/acpi/apei/erst.c
+++ b/drivers/acpi/apei/erst.c
@@ -771,6 +771,7 @@ static int __erst_write_to_nvram(const struct cper_record_header *record)
 static int __erst_read_to_erange_from_nvram(u64 record_id, u64 *offset)
 {
        pr_unimpl_nvram();
+
        return -ENOSYS;
 }
 
$ git diff drivers/acpi/apei/erst.c | ./scripts/checkpatch.pl -
ERROR: ENOSYS means 'invalid syscall nr' and nothing else
       (ignore if this really is syscall entry code)
#10: FILE: drivers/acpi/apei/erst.c:775:
 ^Ireturn -ENOSYS;$



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

end of thread, other threads:[~2014-08-22 10:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-22  4:13 [PATCH] checkpatch.pl: New instances of ENOSYS are errors Andy Lutomirski
2014-08-22 10:06 ` Joe Perches

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.