mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Guenter Roeck <linux@roeck-us.net>, Andy Whitcroft <apw@canonical.com>
Cc: Dwaipayan Ray <dwaipayanray1@gmail.com>,
	Lukas Bulwahn <lukas.bulwahn@gmail.com>,
	linux-kernel@vger.kernel.org,
	Ricardo Ribalda <ribalda@chromium.org>
Subject: Re: [PATCH] checkpatch: Do not complain about positive return values starting with EPOLL
Date: Sun, 20 Jun 2021 12:20:54 -0700	[thread overview]
Message-ID: <eb064d63c63c3ba711eb46edb8617a9d20a272e6.camel@perches.com> (raw)
In-Reply-To: <20210620154555.3848275-1-linux@roeck-us.net>

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);
>  			}



      reply	other threads:[~2021-06-21 15:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-20 15:45 Guenter Roeck
2021-06-20 19:20 ` Joe Perches [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=eb064d63c63c3ba711eb46edb8617a9d20a272e6.camel@perches.com \
    --to=joe@perches.com \
    --cc=apw@canonical.com \
    --cc=dwaipayanray1@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=lukas.bulwahn@gmail.com \
    --cc=ribalda@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®