changeset 2680:ab2ca2770d2e

[gaim-migrate @ 2693] no goto!!!! committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 06 Nov 2001 21:30:31 +0000
parents 94aa499ecd39
children 37d80035e77f
files src/sound.c
diffstat 1 files changed, 23 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/sound.c	Tue Nov 06 04:40:21 2001 +0000
+++ b/src/sound.c	Tue Nov 06 21:30:31 2001 +0000
@@ -247,33 +247,39 @@
 	int result = 0;
 	int fd = -1;
 
+	if (!can_play_artsc())
+		return 0;
+
 	fd = open(file, O_RDONLY);
 	if (fd < 0)
-		goto out;
-
-	if (!can_play_artsc())
-		goto out;
+		return 0;
 
-	if (fstat(fd, &stat_buf))
-		goto out;
+	if (fstat(fd, &stat_buf)) {
+		close(fd);
+		return 0;
+	}
 
-	if (!stat_buf.st_size)
-		goto out;
+	if (!stat_buf.st_size) {
+		close(fd);
+		return 0;
+	}
 
 	buf = g_malloc(stat_buf.st_size);
-	if (!buf)
-		goto out;
+	if (!buf) {
+		close(fd);
+		return 0;
+	}
 
-	if (read(fd, buf, stat_buf.st_size) < 0)
-		goto out;
+	if (read(fd, buf, stat_buf.st_size) < 0) {
+		g_free(buf);
+		close(fd);
+		return 0;
+	}
 
 	result = play_artsc(buf, stat_buf.st_size);
 
-      out:
-	if (buf)
-		g_free(buf);
-	if (fd != -1)
-		close(fd);
+	g_free(buf);
+	close(fd);
 	return result;
 }