* [PATCH] checkpatch: Do not complain about positive return values starting with EPOLL
@ 2021-06-20 15:45 Guenter Roeck
2021-06-20 19:20 ` Joe Perches
0 siblings, 1 reply; 2+ messages in thread
From: Guenter Roeck @ 2021-06-20 15:45 UTC (permalink / raw)
To: Andy Whitcroft
Cc: Joe Perches, Dwaipayan Ray, Lukas Bulwahn, linux-kernel,
Guenter Roeck, Ricardo Ribalda
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.
Cc: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
scripts/checkpatch.pl | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 23697a6b1eaa..cf82dbd7d9d1 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5458,7 +5458,8 @@ 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' &&
+ rindex($name, 'EPOLL', 0) != 0) {
WARN("USE_NEGATIVE_ERRNO",
"return of an errno should typically be negative (ie: return -$1)\n" . $herecurr);
}
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] checkpatch: Do not complain about positive return values starting with EPOLL
2021-06-20 15:45 [PATCH] checkpatch: Do not complain about positive return values starting with EPOLL Guenter Roeck
@ 2021-06-20 19:20 ` Joe Perches
0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2021-06-20 19:20 UTC (permalink / raw)
To: Guenter Roeck, Andy Whitcroft
Cc: Dwaipayan Ray, Lukas Bulwahn, linux-kernel, Ricardo Ribalda
On Sun, 2021-06-20 at 08:45 -0700, Guenter Roeck wrote:
> 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.
Seems OK but
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -5458,7 +5458,8 @@ 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' &&
> + rindex($name, 'EPOLL', 0) != 0) {
rindex is a bit harder to read so my preference would be for the simpler:
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);
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-21 15:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-20 15:45 [PATCH] checkpatch: Do not complain about positive return values starting with EPOLL Guenter Roeck
2021-06-20 19:20 ` 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.