diff options
author | Max Kellermann <max@duempel.org> | 2009-01-25 18:47:23 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-01-25 18:47:23 +0100 |
commit | c4bb227bdb99bf9157b53495bad2890a7f79529e (patch) | |
tree | 755509fd313a702d0d2b03846ee9287850be173e | |
parent | a45922cd66cf8a7a03905c020e50ab01dc05cfa9 (diff) | |
download | mpd-c4bb227bdb99bf9157b53495bad2890a7f79529e.tar.gz mpd-c4bb227bdb99bf9157b53495bad2890a7f79529e.tar.xz mpd-c4bb227bdb99bf9157b53495bad2890a7f79529e.zip |
database: eliminate "goto" usage
http://xkcd.com/292/
Diffstat (limited to '')
-rw-r--r-- | src/database.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/database.c b/src/database.c index 412163145..1fed8ddcf 100644 --- a/src/database.c +++ b/src/database.c @@ -96,7 +96,7 @@ db_get_directory(const char *name) struct song * db_get_song(const char *file) { - struct song *song = NULL; + struct song *song; struct directory *directory; char *duplicated, *shortname, *dir; @@ -118,13 +118,14 @@ db_get_song(const char *file) dir = duplicated; } - if (!(directory = db_get_directory(dir))) - goto out; - if (!(song = songvec_find(&directory->songs, shortname))) - goto out; - assert(song->parent == directory); + directory = db_get_directory(dir); + if (directory != NULL) + song = songvec_find(&directory->songs, shortname); + else + song = NULL; + + assert(song == NULL || song->parent == directory); -out: g_free(duplicated); return song; } |