[PATCH] [media] airspy: Better exception handling in two functions

From: SF Markus Elfring
Date: Mon Dec 28 2015 - 16:16:08 EST


From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
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 <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
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;
}

--
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/