From patchwork Tue Oct 16 16:14:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Colin King X-Patchwork-Id: 10643857 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3B92D15E2 for ; Tue, 16 Oct 2018 16:14:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28C1B2A4A0 for ; Tue, 16 Oct 2018 16:14:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1CA6C2A4EA; Tue, 16 Oct 2018 16:14:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B6352A4A0 for ; Tue, 16 Oct 2018 16:14:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727061AbeJQAFd (ORCPT ); Tue, 16 Oct 2018 20:05:33 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:38589 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727016AbeJQAFd (ORCPT ); Tue, 16 Oct 2018 20:05:33 -0400 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1gCRz9-0005PV-6p; Tue, 16 Oct 2018 16:14:19 +0000 From: Colin King To: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , =?utf-8?q?Stefan_Br=C3=BCns?= , Greg Kroah-Hartman , linux-iio@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][V2] iio: adc: ina2xx: add in early -EINVAL returns in case statements Date: Tue, 16 Oct 2018 17:14:18 +0100 Message-Id: <20181016161418.29213-1-colin.king@canonical.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Colin Ian King Static analysis with CoverityScan is throwing warnings that specific case statements are missing breaks. Rather than adding breaks, add return -EINVAL to the specific case statements to clarify the error return paths. Fix also saves 50 bytes. Before: text data bss dec hex filename 21418 4936 128 26482 6772 drivers/iio/adc/ina2xx-adc.o After: dec hex filename 21370 4936 128 26434 6742 drivers/iio/adc/ina2xx-adc.o (gcc 8.2, x86-64) Detected by CoverityScan, CID#1462408 ("Missing break in switch") Reviewed-by: Stefan BrĂ¼ns --- V2: use returns instead of break statements to keep with the current style used in the switch statement. Signed-off-by: Colin Ian King --- drivers/iio/adc/ina2xx-adc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c index d1239624187d..bdd7cba6f6b0 100644 --- a/drivers/iio/adc/ina2xx-adc.c +++ b/drivers/iio/adc/ina2xx-adc.c @@ -250,6 +250,7 @@ static int ina2xx_read_raw(struct iio_dev *indio_dev, *val2 = chip->shunt_resistor_uohm; return IIO_VAL_FRACTIONAL; } + return -EINVAL; case IIO_CHAN_INFO_HARDWAREGAIN: switch (chan->address) { @@ -262,6 +263,7 @@ static int ina2xx_read_raw(struct iio_dev *indio_dev, *val = chip->range_vbus == 32 ? 1 : 2; return IIO_VAL_INT; } + return -EINVAL; } return -EINVAL;