From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751855AbcGRL0d (ORCPT ); Mon, 18 Jul 2016 07:26:33 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:34185 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751577AbcGRL01 (ORCPT ); Mon, 18 Jul 2016 07:26:27 -0400 Date: Mon, 18 Jul 2016 13:26:22 +0200 From: Thierry Reding To: Andy Whitcroft , Joe Perches Cc: linux-kernel@vger.kernel.org Subject: checkpatch: false positives for else after return Message-ID: <20160718112622.GA18547@ulmo.ba.sec> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="3MwIy2ne0vdjdPXF" Content-Disposition: inline User-Agent: Mutt/1.6.1 (2016-04-27) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --3MwIy2ne0vdjdPXF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --3MwIy2ne0vdjdPXF Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABCAAGBQJXjLzbAAoJEN0jrNd/PrOh1bgP/RxxB9YOYPjlYTRiB8dOTHJz 4B9TyeqkgRzDPKdwg8YuS/gaTEGIqGpfRcyTmX4d8rdPggLZveEW2d2wFQ3U08Pc zoSOpK1hNyeSNmjehaCyf7fC76r510eoNlo/OWUVYE+1Gj6/pE95JOhCqx3JxDt/ iz1gCTWe+5tsKvYy/s615MSanslFqupXu0rRHG9hm68wQ8ToYTAGZ0532Pe7aLYM h4mt4KmyYoWI1Sbe4NreyXQ2k/72yQEil2Pkgx5miLwa4VGsxa6FRRQMIUmKLL07 EnhHX1oJkiY+ElY9TWQ3AFJW3CiSZUwP2ZJXkSo96Wuc4zOlEAH0FFe3cF9gjE9i 5rJue6P/OdkeLtFHBRmlNbuzqp8g0O3EQ+8kzM/8Q4LkD8IJRizJ2FT4w1U3auyl pQt8TtzgWxM+7NIWhEoS0Z2Csw9YOBiX0X6AVKRXF8fV2OQSn4EIIb9fcWCfvidI Dl63AZ4ELxYrC7HG5QMkaLLMngL6fv6V3aVS0UygseYBwUjI9v9mOl/XY5xjOO4x zqgprsTf0FUl25oV0qkYo9l7/FKa/I7BcXndMPITMR/yi7jpxifenomFzCKNmYk+ 0NActJUR23SSr5cUAadaYGBUP+WuItCiy/FBoMVRwkTlcPJqFc0Unau0Xrw38Ey/ f8vIpYzpaMOxhJTdX1bz =ig5E -----END PGP SIGNATURE----- --3MwIy2ne0vdjdPXF--