lkml.org 
[lkml]   [2021]   [Jun]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2] checkpatch: Do not complain about positive return values starting with EPOLL
From
Date
On Mon, 2021-06-21 at 17:43 -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.
>
> Cc: Ricardo Ribalda <ribalda@chromium.org>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
> v2: Replaced 'rindex($name, 'EPOLL', 0) != 0' with '$name !~ /^EPOLL/'

Acked-by: Joe Perches <joe@perches.com>

>
>  scripts/checkpatch.pl | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 23697a6b1eaa..9ab006df01fe 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -5458,7 +5458,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);
>   }


\
 
 \ /
  Last update: 2021-06-22 17:52    [W:0.034 / U:0.672 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site