All of lore.kernel.org
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: alsa-devel@alsa-project.org, Clemens Ladisch <clemens@ladisch.de>,
	Jaroslav Kysela <perex@perex.cz>,
	Martin Koegler <martin.koegler@chello.at>,
	Takashi Iwai <tiwai@suse.com>,
	Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 1/7] ALSA: seq: Delete unnecessary checks in snd_seq_ioctl_query_subs()
Date: Tue, 24 Jan 2017 11:21:13 +0100	[thread overview]
Message-ID: <39bc00c0-ffe7-851c-f329-e7d499f561be@users.sourceforge.net> (raw)
In-Reply-To: <f2404d64-27c8-4afa-b893-fc72601c0136@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 24 Jan 2017 08:00:34 +0100

Two checks were repeated by the snd_seq_ioctl_query_subs() 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 | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
index 4c935202ce23..594c341a193e 100644
--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -1925,16 +1925,16 @@ static int snd_seq_ioctl_query_subs(struct snd_seq_client *client, void *arg)
 {
 	struct snd_seq_query_subs *subs = arg;
 	int result = -ENXIO;
-	struct snd_seq_client *cptr = NULL;
-	struct snd_seq_client_port *port = NULL;
+	struct snd_seq_client *cptr;
+	struct snd_seq_client_port *port;
 	struct snd_seq_port_subs_info *group;
 	struct list_head *p;
 	int i;
 
 	if ((cptr = snd_seq_client_use_ptr(subs->root.client)) == NULL)
-		goto __end;
+		goto exit;
 	if ((port = snd_seq_port_use_ptr(cptr, subs->root.port)) == NULL)
-		goto __end;
+		goto unlock_client;
 
 	switch (subs->type) {
 	case SNDRV_SEQ_QUERY_SUBS_READ:
@@ -1944,7 +1944,7 @@ static int snd_seq_ioctl_query_subs(struct snd_seq_client *client, void *arg)
 		group = &port->c_dest;
 		break;
 	default:
-		goto __end;
+		goto unlock_port;
 	}
 
 	down_read(&group->list_mutex);
@@ -1970,13 +1970,11 @@ static int snd_seq_ioctl_query_subs(struct snd_seq_client *client, void *arg)
 		}
 	}
 	up_read(&group->list_mutex);
-
-      __end:
-   	if (port)
-		snd_seq_port_unlock(port);
-	if (cptr)
-		snd_seq_client_unlock(cptr);
-
+unlock_port:
+	snd_seq_port_unlock(port);
+unlock_client:
+	snd_seq_client_unlock(cptr);
+exit:
 	return result;
 }
 
-- 
2.11.0

WARNING: multiple messages have this Message-ID (diff)
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: alsa-devel@alsa-project.org, Clemens Ladisch <clemens@ladisch.de>,
	Jaroslav Kysela <perex@perex.cz>,
	Martin Koegler <martin.koegler@chello.at>,
	Takashi Iwai <tiwai@suse.com>,
	Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 1/7] ALSA: seq: Delete unnecessary checks in snd_seq_ioctl_query_subs()
Date: Tue, 24 Jan 2017 10:21:13 +0000	[thread overview]
Message-ID: <39bc00c0-ffe7-851c-f329-e7d499f561be@users.sourceforge.net> (raw)
In-Reply-To: <f2404d64-27c8-4afa-b893-fc72601c0136@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 24 Jan 2017 08:00:34 +0100

Two checks were repeated by the snd_seq_ioctl_query_subs() 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 | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
index 4c935202ce23..594c341a193e 100644
--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -1925,16 +1925,16 @@ static int snd_seq_ioctl_query_subs(struct snd_seq_client *client, void *arg)
 {
 	struct snd_seq_query_subs *subs = arg;
 	int result = -ENXIO;
-	struct snd_seq_client *cptr = NULL;
-	struct snd_seq_client_port *port = NULL;
+	struct snd_seq_client *cptr;
+	struct snd_seq_client_port *port;
 	struct snd_seq_port_subs_info *group;
 	struct list_head *p;
 	int i;
 
 	if ((cptr = snd_seq_client_use_ptr(subs->root.client)) = NULL)
-		goto __end;
+		goto exit;
 	if ((port = snd_seq_port_use_ptr(cptr, subs->root.port)) = NULL)
-		goto __end;
+		goto unlock_client;
 
 	switch (subs->type) {
 	case SNDRV_SEQ_QUERY_SUBS_READ:
@@ -1944,7 +1944,7 @@ static int snd_seq_ioctl_query_subs(struct snd_seq_client *client, void *arg)
 		group = &port->c_dest;
 		break;
 	default:
-		goto __end;
+		goto unlock_port;
 	}
 
 	down_read(&group->list_mutex);
@@ -1970,13 +1970,11 @@ static int snd_seq_ioctl_query_subs(struct snd_seq_client *client, void *arg)
 		}
 	}
 	up_read(&group->list_mutex);
-
-      __end:
-   	if (port)
-		snd_seq_port_unlock(port);
-	if (cptr)
-		snd_seq_client_unlock(cptr);
-
+unlock_port:
+	snd_seq_port_unlock(port);
+unlock_client:
+	snd_seq_client_unlock(cptr);
+exit:
 	return result;
 }
 
-- 
2.11.0


  reply	other threads:[~2017-01-24 10:22 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-24 10:19 [PATCH 0/7] ALSA: Fine-tuning for several function implementations SF Markus Elfring
2017-01-24 10:19 ` SF Markus Elfring
2017-01-24 10:21 ` SF Markus Elfring [this message]
2017-01-24 10:21   ` [PATCH 1/7] ALSA: seq: Delete unnecessary checks in snd_seq_ioctl_query_subs() SF Markus Elfring
2017-01-24 10:22 ` [PATCH 2/7] ALSA: seq: Delete unnecessary checks in snd_seq_ioctl_get_subscription() SF Markus Elfring
2017-01-24 10:22   ` SF Markus Elfring
2017-01-24 10:23 ` [PATCH 3/7] ALSA: seq: Delete unnecessary checks in snd_seq_ioctl_unsubscribe_port() SF Markus Elfring
2017-01-24 10:23   ` SF Markus Elfring
2017-01-24 10:24 ` [PATCH 4/7] ALSA: seq: Delete unnecessary checks in snd_seq_ioctl_subscribe_port() SF Markus Elfring
2017-01-24 10:24   ` SF Markus Elfring
2017-01-24 10:25 ` [PATCH 5/7] ALSA: seq: Adjust 16 function calls together with a variable assignment SF Markus Elfring
2017-01-24 10:25   ` SF Markus Elfring
2017-01-24 10:26 ` [PATCH 6/7] dmasound_core: Move two assignments for the variable "ret" in state_open() SF Markus Elfring
2017-01-24 10:26   ` SF Markus Elfring
2017-01-25  7:40   ` [alsa-devel] " Clemens Ladisch
2017-01-25  7:40     ` [alsa-devel] [PATCH 6/7] dmasound_core: Move two assignments for the variable "ret" in state_ope Clemens Ladisch
2017-01-24 10:27 ` [PATCH 7/7] dmasound_core: Adjust six function calls together with a variable assignment SF Markus Elfring
2017-01-24 10:27   ` SF Markus Elfring
2017-11-14 11:48 ` [PATCH 0/7] ALSA: Fine-tuning for several function implementations SF Markus Elfring
2017-11-14 11:48   ` SF Markus Elfring
2017-11-14 11:48   ` SF Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=39bc00c0-ffe7-851c-f329-e7d499f561be@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.koegler@chello.at \
    --cc=o-takashi@sakamocchi.jp \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.