From 4bde8982f146f9866b4b78f7be5945c82c19d403 Mon Sep 17 00:00:00 2001 From: Brandon Low Date: Thu, 25 Oct 2007 18:58:44 +0000 Subject: Fix a fixme in flac and make the usage of the read_filebuf codec api more consistent with its actual contract. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15303 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/flac.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'apps/codecs/flac.c') diff --git a/apps/codecs/flac.c b/apps/codecs/flac.c index 2eb0deb9f5..d1c52833a6 100644 --- a/apps/codecs/flac.c +++ b/apps/codecs/flac.c @@ -77,8 +77,7 @@ static bool flac_init(FLACContext* fc, int first_frame_offset) uint32_t offset_hi,offset_lo; uint16_t blocksize; int endofmetadata=0; - int blocklength; - int n; + uint32_t blocklength; ci->memset(fc,0,sizeof(FLACContext)); nseekpoints=0; @@ -113,9 +112,7 @@ static bool flac_init(FLACContext* fc, int first_frame_offset) if ((buf[0] & 0x7f) == 0) /* 0 is the STREAMINFO block */ { - /* FIXME: Don't trust the value of blocklength, use actual return - * value in bytes instead */ - ci->read_filebuf(buf, blocklength); + if (ci->read_filebuf(buf, blocklength) < blocklength) return false; fc->filesize = ci->filesize; fc->min_blocksize = (buf[0] << 8) | buf[1]; @@ -140,9 +137,8 @@ static bool flac_init(FLACContext* fc, int first_frame_offset) } else if ((buf[0] & 0x7f) == 3) { /* 3 is the SEEKTABLE block */ while ((nseekpoints < MAX_SUPPORTED_SEEKTABLE_SIZE) && (blocklength >= 18)) { - n=ci->read_filebuf(buf,18); - if (n < 18) return false; - blocklength-=n; + if (ci->read_filebuf(buf,18) < 18) return false; + blocklength-=18; seekpoint_hi=(buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; -- cgit v1.2.3