diff mbox series

[-,JACK,plugin,1/2] jack: Refactoring: Lower indentation

Message ID 1548340975-32610-2-git-send-email-twischer@de.adit-jv.com (mailing list archive)
State New, archived
Headers show
Series jack: Support to connect multiple ports | expand

Commit Message

Timo Wischer Jan. 24, 2019, 2:42 p.m. UTC
From: Timo Wischer <twischer@de.adit-jv.com>

to full fill 80 character limit of next commit.

Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
diff mbox series

Patch

diff --git a/jack/pcm_jack.c b/jack/pcm_jack.c
index b2bc213..724cbc2 100644
--- a/jack/pcm_jack.c
+++ b/jack/pcm_jack.c
@@ -105,23 +105,25 @@  static int pcm_poll_unblock_check(snd_pcm_ioplug_t *io)
 
 static void snd_pcm_jack_free(snd_pcm_jack_t *jack)
 {
-	if (jack) {
+	if (jack == NULL)
+		return;
+
+	if (jack->client)
+		jack_client_close(jack->client);
+	if (jack->port_names) {
 		unsigned int i;
-		if (jack->client)
-			jack_client_close(jack->client);
-		if (jack->port_names) {
-			for (i = 0; i < jack->num_ports; i++)
-				free(jack->port_names[i]);
-			free(jack->port_names);
-		}
-		if (jack->fd >= 0)
-			close(jack->fd);
-		if (jack->io.poll_fd >= 0)
-			close(jack->io.poll_fd);
-		free(jack->areas);
-		free(jack->ports);
-		free(jack);
+
+		for (i = 0; i < jack->num_ports; i++)
+			free(jack->port_names[i]);
+		free(jack->port_names);
 	}
+	if (jack->fd >= 0)
+		close(jack->fd);
+	if (jack->io.poll_fd >= 0)
+		close(jack->io.poll_fd);
+	free(jack->areas);
+	free(jack->ports);
+	free(jack);
 }
 
 static int snd_pcm_jack_close(snd_pcm_ioplug_t *io)
@@ -418,31 +420,34 @@  static int parse_ports(snd_pcm_jack_t *jack, snd_config_t *conf)
 	unsigned int cnt = 0;
 	unsigned int channel;
 
-	if (conf) {
-		snd_config_for_each(i, next, conf) {
-			snd_config_t *n = snd_config_iterator_entry(i);
-			const char *id;
-			if (snd_config_get_id(n, &id) < 0)
-				continue;
-			cnt++;
-		}
-		jack->port_names = ports = calloc(cnt, sizeof(char*));
-		if (ports == NULL)
-			return -ENOMEM;
-		jack->num_ports = cnt;
-		snd_config_for_each(i, next, conf) {
-			snd_config_t *n = snd_config_iterator_entry(i);
-			const char *id;
-			const char *port;
-
-			if (snd_config_get_id(n, &id) < 0)
-				continue;
-			channel = atoi(id);
-			if (snd_config_get_string(n, &port) < 0)
-				continue;
-			ports[channel] = port ? strdup(port) : NULL;
-		}
+	if (conf == NULL)
+		return 0;
+
+	snd_config_for_each(i, next, conf) {
+		snd_config_t *n = snd_config_iterator_entry(i);
+		const char *id;
+
+		if (snd_config_get_id(n, &id) < 0)
+			continue;
+		cnt++;
 	}
+	jack->port_names = ports = calloc(cnt, sizeof(char*));
+	if (ports == NULL)
+		return -ENOMEM;
+	jack->num_ports = cnt;
+	snd_config_for_each(i, next, conf) {
+		snd_config_t *n = snd_config_iterator_entry(i);
+		const char *id;
+		const char *port;
+
+		if (snd_config_get_id(n, &id) < 0)
+			continue;
+		channel = atoi(id);
+		if (snd_config_get_string(n, &port) < 0)
+			continue;
+		ports[channel] = port ? strdup(port) : NULL;
+	}
+
 	return 0;
 }