]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
checkpatch: do not complain about positive return values starting with EPOLL
authorGuenter Roeck <linux@roeck-us.net>
Thu, 1 Jul 2021 01:56:25 +0000 (18:56 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 1 Jul 2021 18:06:06 +0000 (11:06 -0700)
checkpatch complains about positive return values of poll functions.
Example:

WARNING: return of an errno should typically be negative (ie: return -EPOLLIN)
+ return EPOLLIN;

Poll functions return positive values.  The defines for the return values
of poll functions all start with EPOLL, resulting in a number of false
positives.  An often used workaround is to assign poll function return
values to variables and returning that variable, but that is a less than
perfect solution.

There is no error definition which starts with EPOLL, so it is safe to
omit the warning for return values starting with EPOLL.

Link: https://lkml.kernel.org/r/20210622004334.638680-1-linux@roeck-us.net
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Joe Perches <joe@perches.com>
Cc: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
scripts/checkpatch.pl

index dad87c368632618470269a0303b558b03e6b9833..461d4221e4a4a1d94664adde8d225a19d2328dbf 100755 (executable)
@@ -5462,7 +5462,7 @@ sub process {
 # Return of what appears to be an errno should normally be negative
                if ($sline =~ /\breturn(?:\s*\(+\s*|\s+)(E[A-Z]+)(?:\s*\)+\s*|\s*)[;:,]/) {
                        my $name = $1;
-                       if ($name ne 'EOF' && $name ne 'ERROR') {
+                       if ($name ne 'EOF' && $name ne 'ERROR' && $name !~ /^EPOLL/) {
                                WARN("USE_NEGATIVE_ERRNO",
                                     "return of an errno should typically be negative (ie: return -$1)\n" . $herecurr);
                        }