From: Joe Perches <joe@perches.com>
To: Thierry Reding <thierry.reding@gmail.com>,
Andy Whitcroft <apw@canonical.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: checkpatch: false positives for else after return
Date: Mon, 18 Jul 2016 08:30:42 -0700 [thread overview]
Message-ID: <1468855842.1900.14.camel@perches.com> (raw)
In-Reply-To: <20160718112622.GA18547@ulmo.ba.sec>
On Mon, 2016-07-18 at 13:26 +0200, Thierry Reding wrote:
> Hi,
>
> I've run across what I think is a false positive for checkpatch's
> UNNECESSARY_ELSE check. The code that triggers it is in the
> tegra_sor_probe() function in drivers/gpu/drm/tegra/sor.c. For
> reference, here's the code:
>
> if (sor->soc->supports_hdmi) {
> sor->ops = &tegra_sor_hdmi_ops;
> } else if (sor->soc->supports_lvds) {
> dev_err(&pdev->dev, "LVDS not supported yet\n");
> return -ENODEV;
> } else {
> dev_err(&pdev->dev, "unknown (non-DP) support\n");
> return -ENODEV;
> }
>
> For the first case (HDMI supported on SoC) the code should continue
> normally, but otherwise we need to error out because we don't support
> the configuration.
>
> I can't come up with an alternative way of writing the above, and at the
> same time I can't see what's wrong with the above. It looks like a
> legitimate use of an else to me.
>
> I made an attempt at fixing the check myself but failed miserably. Regex
> isn't among my strong skills =\
>
> Any ideas on how to deal with this?
Hi Thierry.
Ignore checkpatch when it's wrong.
The message is:
"else is not generally useful after a break or return"
and that statement is true.
checkpatch is not, and will not become, a code flow
analysis tool. It's a very brain-dead, stupid little
script that looks at very simple patch table rules.
prev parent reply other threads:[~2016-07-18 15:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-18 11:26 checkpatch: false positives for else after return Thierry Reding
2016-07-18 15:30 ` 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=1468855842.1900.14.camel@perches.com \
--to=joe@perches.com \
--cc=apw@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=thierry.reding@gmail.com \
/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 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.