aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-07-22 13:31:46 +0200
committerMax Kellermann <max@duempel.org>2009-07-22 13:31:46 +0200
commitcf1fd2b0da4be4675ddb16c5421d949a0e923b20 (patch)
tree81af74cdd614b2889d141a691c296b499dfaa8de
parent8e2d9879962775bb29aa4d7556666b2216353bbe (diff)
downloadmpd-cf1fd2b0da4be4675ddb16c5421d949a0e923b20.tar.gz
mpd-cf1fd2b0da4be4675ddb16c5421d949a0e923b20.tar.xz
mpd-cf1fd2b0da4be4675ddb16c5421d949a0e923b20.zip
decoder/flac: return early from flac_find_float_comment()
When one metadata check fails, return quickly. This removes 2 levels of indent.
-rw-r--r--src/decoder/_flac_common.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/src/decoder/_flac_common.c b/src/decoder/_flac_common.c
index a6c3a2134..a450b6886 100644
--- a/src/decoder/_flac_common.c
+++ b/src/decoder/_flac_common.c
@@ -44,27 +44,28 @@ static bool
flac_find_float_comment(const FLAC__StreamMetadata *block,
const char *cmnt, float *fl)
{
- int offset =
- FLAC__metadata_object_vorbiscomment_find_entry_from(block, 0, cmnt);
-
- if (offset >= 0) {
- size_t pos = strlen(cmnt) + 1; /* 1 is for '=' */
- int len = block->data.vorbis_comment.comments[offset].length
- - pos;
- if (len > 0) {
- unsigned char tmp;
- unsigned char *p = &(block->data.vorbis_comment.
- comments[offset].entry[pos]);
- tmp = p[len];
- p[len] = '\0';
- *fl = (float)atof((char *)p);
- p[len] = tmp;
-
- return true;
- }
- }
-
- return false;
+ int offset;
+ size_t pos;
+ int len;
+ unsigned char tmp, *p;
+
+ offset = FLAC__metadata_object_vorbiscomment_find_entry_from(block, 0,
+ cmnt);
+ if (offset < 0)
+ return false;
+
+ pos = strlen(cmnt) + 1; /* 1 is for '=' */
+ len = block->data.vorbis_comment.comments[offset].length - pos;
+ if (len <= 0)
+ return false;
+
+ p = &block->data.vorbis_comment.comments[offset].entry[pos];
+ tmp = p[len];
+ p[len] = '\0';
+ *fl = (float)atof((char *)p);
+ p[len] = tmp;
+
+ return true;
}
static void