Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1565773

[PATCH 4/7] ALSA: seq: Delete unnecessary checks in snd_seq_ioctl_subscribe_port()

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 4/7] ALSA: seq: Delete unnecessary checks in snd_seq_ioctl_subscribe_port()
Date 2017-01-24 11:30 +0100
Message-ID <t36ws-34u-59@gated-at.bofh.it> (permalink)
References <t36wq-34u-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 24 Jan 2017 09:06:38 +0100

Four checks were repeated by the snd_seq_ioctl_subscribe_port() function
despite of pointer determinations for the used variables at the beginning.

* Adjust jump targets according to the Linux coding style convention.

* Delete extra variable initialisations and the repeated checks
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/core/seq/seq_clientmgr.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
index ba26d622cb71..b9518e7cb623 100644
--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -1423,36 +1423,36 @@ static int snd_seq_ioctl_subscribe_port(struct snd_seq_client *client,
 {
 	struct snd_seq_port_subscribe *subs = arg;
 	int result = -EINVAL;
-	struct snd_seq_client *receiver = NULL, *sender = NULL;
-	struct snd_seq_client_port *sport = NULL, *dport = NULL;
+	struct snd_seq_client *receiver, *sender;
+	struct snd_seq_client_port *sport, *dport;
 
 	if ((receiver = snd_seq_client_use_ptr(subs->dest.client)) == NULL)
-		goto __end;
+		goto exit;
 	if ((sender = snd_seq_client_use_ptr(subs->sender.client)) == NULL)
-		goto __end;
+		goto unlock_receiver;
 	if ((sport = snd_seq_port_use_ptr(sender, subs->sender.port)) == NULL)
-		goto __end;
+		goto unlock_sender;
 	if ((dport = snd_seq_port_use_ptr(receiver, subs->dest.port)) == NULL)
-		goto __end;
+		goto unlock_sport;
 
 	result = check_subscription_permission(client, sport, dport, subs);
 	if (result < 0)
-		goto __end;
+		goto unlock_dport;
 
 	/* connect them */
 	result = snd_seq_port_connect(client, sender, sport, receiver, dport, subs);
 	if (! result) /* broadcast announce */
 		snd_seq_client_notify_subscription(SNDRV_SEQ_ADDRESS_SUBSCRIBERS, 0,
 						   subs, SNDRV_SEQ_EVENT_PORT_SUBSCRIBED);
-      __end:
-      	if (sport)
-		snd_seq_port_unlock(sport);
-	if (dport)
-		snd_seq_port_unlock(dport);
-	if (sender)
-		snd_seq_client_unlock(sender);
-	if (receiver)
-		snd_seq_client_unlock(receiver);
+unlock_dport:
+	snd_seq_port_unlock(dport);
+unlock_sport:
+	snd_seq_port_unlock(sport);
+unlock_sender:
+	snd_seq_client_unlock(sender);
+unlock_receiver:
+	snd_seq_client_unlock(receiver);
+exit:
 	return result;
 }
 
-- 
2.11.0

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 0/7] ALSA: Fine-tuning for several function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-24 11:30 +0100
  [PATCH 7/7] dmasound_core: Adjust six function calls together with a  variable assignment SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-24 11:30 +0100
  [PATCH 2/7] ALSA: seq: Delete unnecessary checks in  snd_seq_ioctl_get_subscription() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-24 11:30 +0100
  [PATCH 1/7] ALSA: seq: Delete unnecessary checks in  snd_seq_ioctl_query_subs() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-24 11:30 +0100
  [PATCH 6/7] dmasound_core: Move two assignments for the variable  "ret" in state_open() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-24 11:30 +0100
    Re: [alsa-devel] [PATCH 6/7] dmasound_core: Move two assignments for  the variable "ret" in state_open() Clemens Ladisch <clemens@ladisch.de> - 2017-01-25 08:50 +0100
  [PATCH 5/7] ALSA: seq: Adjust 16 function calls together with a  variable assignment SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-24 11:30 +0100
  [PATCH 4/7] ALSA: seq: Delete unnecessary checks in  snd_seq_ioctl_subscribe_port() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-24 11:30 +0100

csiph-web