public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] ALSA: usx2y: Fine-tuning for two function implementations
@ 2017-09-06 13:15 SF Markus Elfring
  2017-09-06 13:16 ` [PATCH 1/2] ALSA: us122l: Use common error handling code in us122l_create_card() SF Markus Elfring
  2017-09-06 13:17 ` [PATCH 2/2] ALSA: usx2y: Use common error handling code in submit_urbs() SF Markus Elfring
  0 siblings, 2 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-09-06 13:15 UTC (permalink / raw)
  To: alsa-devel, Andrew Morton, Arvind Yadav, Dave Jiang,
	Jaroslav Kysela, Johan Hovold, Mauro Carvalho Chehab,
	Takashi Iwai
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 6 Sep 2017 15:10:12 +0200

Two update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
  Use common error handling code in us122l_create_card()
  Use common error handling code in submit_urbs()

 sound/usb/usx2y/us122l.c     | 10 ++++++----
 sound/usb/usx2y/usb_stream.c | 18 ++++++++++--------
 2 files changed, 16 insertions(+), 12 deletions(-)

-- 
2.14.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] ALSA: us122l: Use common error handling code in us122l_create_card()
  2017-09-06 13:15 [PATCH 0/2] ALSA: usx2y: Fine-tuning for two function implementations SF Markus Elfring
@ 2017-09-06 13:16 ` SF Markus Elfring
  2017-09-07  8:28   ` Takashi Iwai
  2017-09-06 13:17 ` [PATCH 2/2] ALSA: usx2y: Use common error handling code in submit_urbs() SF Markus Elfring
  1 sibling, 1 reply; 5+ messages in thread
From: SF Markus Elfring @ 2017-09-06 13:16 UTC (permalink / raw)
  To: alsa-devel, Andrew Morton, Arvind Yadav, Dave Jiang,
	Jaroslav Kysela, Johan Hovold, Mauro Carvalho Chehab,
	Takashi Iwai
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 6 Sep 2017 14:45:09 +0200

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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/usb/usx2y/us122l.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c
index b49d6e953d52..159da1f3924e 100644
--- a/sound/usb/usx2y/us122l.c
+++ b/sound/usb/usx2y/us122l.c
@@ -508,8 +508,7 @@ static bool us122l_create_card(struct snd_card *card)
 		err = us122l_create_usbmidi(card);
 	if (err < 0) {
 		snd_printk(KERN_ERR "us122l_create_usbmidi error %i \n", err);
-		us122l_stop(us122l);
-		return false;
+		goto stop;
 	}
 	err = usb_stream_hwdep_new(card);
 	if (err < 0) {
@@ -518,10 +517,13 @@ static bool us122l_create_card(struct snd_card *card)
 		list_for_each(p, &us122l->midi_list)
 			snd_usbmidi_disconnect(p);
 
-		us122l_stop(us122l);
-		return false;
+		goto stop;
 	}
 	return true;
+
+stop:
+	us122l_stop(us122l);
+	return false;
 }
 
 static void snd_us122l_free(struct snd_card *card)
-- 
2.14.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] ALSA: usx2y: Use common error handling code in submit_urbs()
  2017-09-06 13:15 [PATCH 0/2] ALSA: usx2y: Fine-tuning for two function implementations SF Markus Elfring
  2017-09-06 13:16 ` [PATCH 1/2] ALSA: us122l: Use common error handling code in us122l_create_card() SF Markus Elfring
@ 2017-09-06 13:17 ` SF Markus Elfring
  2017-09-07  8:28   ` Takashi Iwai
  1 sibling, 1 reply; 5+ messages in thread
From: SF Markus Elfring @ 2017-09-06 13:17 UTC (permalink / raw)
  To: alsa-devel, Andrew Morton, Arvind Yadav, Dave Jiang,
	Jaroslav Kysela, Johan Hovold, Mauro Carvalho Chehab,
	Takashi Iwai
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 6 Sep 2017 15:00:08 +0200

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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/usb/usx2y/usb_stream.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/sound/usb/usx2y/usb_stream.c b/sound/usb/usx2y/usb_stream.c
index fe926cb9192e..4dab49080700 100644
--- a/sound/usb/usx2y/usb_stream.c
+++ b/sound/usb/usx2y/usb_stream.c
@@ -352,20 +352,22 @@ static int submit_urbs(struct usb_stream_kernel *sk,
 	int err;
 	prepare_inurb(sk->idle_outurb->number_of_packets, sk->idle_inurb);
 	err = usb_submit_urb(sk->idle_inurb, GFP_ATOMIC);
-	if (err < 0) {
-		snd_printk(KERN_ERR "%i\n", err);
-		return err;
-	}
+	if (err < 0)
+		goto report_failure;
+
 	sk->idle_inurb = sk->completed_inurb;
 	sk->completed_inurb = inurb;
 	err = usb_submit_urb(sk->idle_outurb, GFP_ATOMIC);
-	if (err < 0) {
-		snd_printk(KERN_ERR "%i\n", err);
-		return err;
-	}
+	if (err < 0)
+		goto report_failure;
+
 	sk->idle_outurb = sk->completed_outurb;
 	sk->completed_outurb = outurb;
 	return 0;
+
+report_failure:
+	snd_printk(KERN_ERR "%i\n", err);
+	return err;
 }
 
 #ifdef DEBUG_LOOP_BACK
-- 
2.14.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] ALSA: us122l: Use common error handling code in us122l_create_card()
  2017-09-06 13:16 ` [PATCH 1/2] ALSA: us122l: Use common error handling code in us122l_create_card() SF Markus Elfring
@ 2017-09-07  8:28   ` Takashi Iwai
  0 siblings, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2017-09-07  8:28 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: alsa-devel, Dave Jiang, LKML, kernel-janitors, Johan Hovold,
	Arvind Yadav, Andrew Morton, Mauro Carvalho Chehab

On Wed, 06 Sep 2017 15:16:29 +0200,
SF Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 6 Sep 2017 14:45:09 +0200
> 
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.


Takashi

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] ALSA: usx2y: Use common error handling code in submit_urbs()
  2017-09-06 13:17 ` [PATCH 2/2] ALSA: usx2y: Use common error handling code in submit_urbs() SF Markus Elfring
@ 2017-09-07  8:28   ` Takashi Iwai
  0 siblings, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2017-09-07  8:28 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: alsa-devel, Arvind Yadav, Dave Jiang, Johan Hovold,
	Mauro Carvalho Chehab, Andrew Morton, Jaroslav Kysela,
	kernel-janitors, LKML

On Wed, 06 Sep 2017 15:17:38 +0200,
SF Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 6 Sep 2017 15:00:08 +0200
> 
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.


Takashi

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-09-07  8:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-06 13:15 [PATCH 0/2] ALSA: usx2y: Fine-tuning for two function implementations SF Markus Elfring
2017-09-06 13:16 ` [PATCH 1/2] ALSA: us122l: Use common error handling code in us122l_create_card() SF Markus Elfring
2017-09-07  8:28   ` Takashi Iwai
2017-09-06 13:17 ` [PATCH 2/2] ALSA: usx2y: Use common error handling code in submit_urbs() SF Markus Elfring
2017-09-07  8:28   ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox