From patchwork Mon Dec 28 21:15:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 7927321 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4A4E2BEEE5 for ; Mon, 28 Dec 2015 21:16:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6EFE6201E4 for ; Mon, 28 Dec 2015 21:16:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 80808201CE for ; Mon, 28 Dec 2015 21:16:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752763AbbL1VQB (ORCPT ); Mon, 28 Dec 2015 16:16:01 -0500 Received: from mout.web.de ([212.227.17.11]:54265 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752483AbbL1VP7 (ORCPT ); Mon, 28 Dec 2015 16:15:59 -0500 Received: from [192.168.1.2] ([78.48.234.128]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0MTy9d-1adoxW3C1B-00Qkts; Mon, 28 Dec 2015 22:15:39 +0100 Subject: [PATCH] [media] airspy: Better exception handling in two functions References: <566ABCD9.1060404@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall To: linux-media@vger.kernel.org, Antti Palosaari , Mauro Carvalho Chehab From: SF Markus Elfring Message-ID: <5681A675.80504@users.sourceforge.net> Date: Mon, 28 Dec 2015 22:15:33 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <566ABCD9.1060404@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KGsBs3HOOtV8eNjJOtS99jZ2pHL3sOXwtdZpV 2oQ8ZYyqntntjhlGQW4kEKdtq/Hig== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Mon, 28 Dec 2015 22:10:28 +0100 This issue was detected by using the Coccinelle software. Move the jump label directly before the desired log statement so that the variable "ret" will not be checked once more after a function call. Use the identifier "report_failure" instead of "err". The error logging is performed in a separate section at the end now. Signed-off-by: Markus Elfring --- drivers/media/usb/airspy/airspy.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/media/usb/airspy/airspy.c b/drivers/media/usb/airspy/airspy.c index 0d4ac59..cf2444a 100644 --- a/drivers/media/usb/airspy/airspy.c +++ b/drivers/media/usb/airspy/airspy.c @@ -889,18 +889,17 @@ static int airspy_set_lna_gain(struct airspy *s) ret = airspy_ctrl_msg(s, CMD_SET_LNA_AGC, 0, s->lna_gain_auto->val, &u8tmp, 1); if (ret) - goto err; + goto report_failure; if (s->lna_gain_auto->val == false) { ret = airspy_ctrl_msg(s, CMD_SET_LNA_GAIN, 0, s->lna_gain->val, &u8tmp, 1); if (ret) - goto err; + goto report_failure; } -err: - if (ret) - dev_dbg(s->dev, "failed=%d\n", ret); - + return 0; +report_failure: + dev_dbg(s->dev, "failed=%d\n", ret); return ret; } @@ -916,18 +915,17 @@ static int airspy_set_mixer_gain(struct airspy *s) ret = airspy_ctrl_msg(s, CMD_SET_MIXER_AGC, 0, s->mixer_gain_auto->val, &u8tmp, 1); if (ret) - goto err; + goto report_failure; if (s->mixer_gain_auto->val == false) { ret = airspy_ctrl_msg(s, CMD_SET_MIXER_GAIN, 0, s->mixer_gain->val, &u8tmp, 1); if (ret) - goto err; + goto report_failure; } -err: - if (ret) - dev_dbg(s->dev, "failed=%d\n", ret); - + return 0; +report_failure: + dev_dbg(s->dev, "failed=%d\n", ret); return ret; }