* [PATCH] ALSA: ak4531_codec: Use common error handling code in snd_ak4531_mixer()
@ 2017-11-12 10:08 SF Markus Elfring
2017-11-12 11:29 ` Julia Lawall
0 siblings, 1 reply; 2+ messages in thread
From: SF Markus Elfring @ 2017-11-12 10:08 UTC (permalink / raw)
To: alsa-devel, Jaroslav Kysela, Takashi Iwai; +Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 12 Nov 2017 10:56:19 +0100
* Add a jump target so that a bit of exception handling can be better
reused at the end of this function.
This issue was detected by using the Coccinelle software.
* The script "checkpatch.pl" pointed information out like the following.
ERROR: do not use assignment in if condition
Thus fix three affected source code places.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
sound/pci/ak4531_codec.c | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/sound/pci/ak4531_codec.c b/sound/pci/ak4531_codec.c
index 2fb1fbba3e5e..208c96d6ae0f 100644
--- a/sound/pci/ak4531_codec.c
+++ b/sound/pci/ak4531_codec.c
@@ -399,10 +399,10 @@ int snd_ak4531_mixer(struct snd_card *card,
return -ENOMEM;
*ak4531 = *_ak4531;
mutex_init(&ak4531->reg_mutex);
- if ((err = snd_component_add(card, "AK4531")) < 0) {
- snd_ak4531_free(ak4531);
- return err;
- }
+ err = snd_component_add(card, "AK4531");
+ if (err < 0)
+ goto free_ac;
+
strcpy(card->mixername, "Asahi Kasei AK4531");
ak4531->write(ak4531, AK4531_RESET, 0x03); /* no RST, PD */
udelay(100);
@@ -413,16 +413,16 @@ int snd_ak4531_mixer(struct snd_card *card,
ak4531->write(ak4531, idx, ak4531->regs[idx] = snd_ak4531_initial_map[idx]); /* recording source is mixer */
}
for (idx = 0; idx < ARRAY_SIZE(snd_ak4531_controls); idx++) {
- if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_ak4531_controls[idx], ak4531))) < 0) {
- snd_ak4531_free(ak4531);
- return err;
- }
+ err = snd_ctl_add(card,
+ snd_ctl_new1(&snd_ak4531_controls[idx],
+ ak4531));
+ if (err < 0)
+ goto free_ac;
}
snd_ak4531_proc_init(card, ak4531);
- if ((err = snd_device_new(card, SNDRV_DEV_CODEC, ak4531, &ops)) < 0) {
- snd_ak4531_free(ak4531);
- return err;
- }
+ err = snd_device_new(card, SNDRV_DEV_CODEC, ak4531, &ops);
+ if (err < 0)
+ goto free_ac;
#if 0
snd_ak4531_dump(ak4531);
@@ -430,6 +430,10 @@ int snd_ak4531_mixer(struct snd_card *card,
if (rak4531)
*rak4531 = ak4531;
return 0;
+
+free_ac:
+ snd_ak4531_free(ak4531);
+ return err;
}
/*
--
2.15.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] ALSA: ak4531_codec: Use common error handling code in snd_ak4531_mixer()
2017-11-12 10:08 [PATCH] ALSA: ak4531_codec: Use common error handling code in snd_ak4531_mixer() SF Markus Elfring
@ 2017-11-12 11:29 ` Julia Lawall
0 siblings, 0 replies; 2+ messages in thread
From: Julia Lawall @ 2017-11-12 11:29 UTC (permalink / raw)
To: SF Markus Elfring
Cc: alsa-devel, Jaroslav Kysela, Takashi Iwai, LKML, kernel-janitors
On Sun, 12 Nov 2017, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 12 Nov 2017 10:56:19 +0100
>
> * Add a jump target so that a bit of exception handling can be better
> reused at the end of this function.
>
> This issue was detected by using the Coccinelle software.
>
> * The script "checkpatch.pl" pointed information out like the following.
>
> ERROR: do not use assignment in if condition
These don't seem to belong in the same patch.
julia
>
> Thus fix three affected source code places.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> sound/pci/ak4531_codec.c | 28 ++++++++++++++++------------
> 1 file changed, 16 insertions(+), 12 deletions(-)
>
> diff --git a/sound/pci/ak4531_codec.c b/sound/pci/ak4531_codec.c
> index 2fb1fbba3e5e..208c96d6ae0f 100644
> --- a/sound/pci/ak4531_codec.c
> +++ b/sound/pci/ak4531_codec.c
> @@ -399,10 +399,10 @@ int snd_ak4531_mixer(struct snd_card *card,
> return -ENOMEM;
> *ak4531 = *_ak4531;
> mutex_init(&ak4531->reg_mutex);
> - if ((err = snd_component_add(card, "AK4531")) < 0) {
> - snd_ak4531_free(ak4531);
> - return err;
> - }
> + err = snd_component_add(card, "AK4531");
> + if (err < 0)
> + goto free_ac;
> +
> strcpy(card->mixername, "Asahi Kasei AK4531");
> ak4531->write(ak4531, AK4531_RESET, 0x03); /* no RST, PD */
> udelay(100);
> @@ -413,16 +413,16 @@ int snd_ak4531_mixer(struct snd_card *card,
> ak4531->write(ak4531, idx, ak4531->regs[idx] = snd_ak4531_initial_map[idx]); /* recording source is mixer */
> }
> for (idx = 0; idx < ARRAY_SIZE(snd_ak4531_controls); idx++) {
> - if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_ak4531_controls[idx], ak4531))) < 0) {
> - snd_ak4531_free(ak4531);
> - return err;
> - }
> + err = snd_ctl_add(card,
> + snd_ctl_new1(&snd_ak4531_controls[idx],
> + ak4531));
> + if (err < 0)
> + goto free_ac;
> }
> snd_ak4531_proc_init(card, ak4531);
> - if ((err = snd_device_new(card, SNDRV_DEV_CODEC, ak4531, &ops)) < 0) {
> - snd_ak4531_free(ak4531);
> - return err;
> - }
> + err = snd_device_new(card, SNDRV_DEV_CODEC, ak4531, &ops);
> + if (err < 0)
> + goto free_ac;
>
> #if 0
> snd_ak4531_dump(ak4531);
> @@ -430,6 +430,10 @@ int snd_ak4531_mixer(struct snd_card *card,
> if (rak4531)
> *rak4531 = ak4531;
> return 0;
> +
> +free_ac:
> + snd_ak4531_free(ak4531);
> + return err;
> }
>
> /*
> --
> 2.15.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-11-12 11:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-12 10:08 [PATCH] ALSA: ak4531_codec: Use common error handling code in snd_ak4531_mixer() SF Markus Elfring
2017-11-12 11:29 ` Julia Lawall
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®