All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Andy Whitcroft <apw@canonical.com>, Joe Perches <joe@perches.com>
Cc: linux-kernel@vger.kernel.org
Subject: checkpatch: false positives for else after return
Date: Mon, 18 Jul 2016 13:26:22 +0200	[thread overview]
Message-ID: <20160718112622.GA18547@ulmo.ba.sec> (raw)

[-- Attachment #1: Type: text/plain, Size: 973 bytes --]

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?

Thanks,
Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

             reply	other threads:[~2016-07-18 11:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-18 11:26 Thierry Reding [this message]
2016-07-18 15:30 ` checkpatch: false positives for else after return Joe Perches

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=20160718112622.GA18547@ulmo.ba.sec \
    --to=thierry.reding@gmail.com \
    --cc=apw@canonical.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.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 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.