Re: [PATCH] checkpatch.pl: New instances of ENOSYS are errors

From: Joe Perches
Date: Fri Aug 22 2014 - 06:06:26 EST


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;$


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/