summaryrefslogtreecommitdiff
path: root/apps/codecs
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2009-05-08 17:52:38 +0000
committerDave Chapman <dave@dchapman.com>2009-05-08 17:52:38 +0000
commit90f1e5caf225a2e73806ccb4fb0b3003dab8cfa9 (patch)
treec52a0c57580a63b00806e4ee4781f13019d32a8f /apps/codecs
parent7b81cd0caf85eef3086866ad3d09fec10cf8eceb (diff)
Check some previously unchecked return values in the standalone FLAC test program - fixes some warnings spotted by Mohamed Tarek El Haddad (mt).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20875 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs')
-rw-r--r--apps/codecs/libffmpegFLAC/main.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/apps/codecs/libffmpegFLAC/main.c b/apps/codecs/libffmpegFLAC/main.c
index 4a989a4dd0..058c581aea 100644
--- a/apps/codecs/libffmpegFLAC/main.c
+++ b/apps/codecs/libffmpegFLAC/main.c
@@ -33,6 +33,7 @@
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
#include <inttypes.h>
#include <stdbool.h>
#include <fcntl.h>
@@ -63,7 +64,10 @@ int open_wav(char* filename) {
fd=open(filename,O_CREAT|O_WRONLY|O_TRUNC,S_IRUSR|S_IWUSR);
if (fd >= 0) {
- write(fd,wav_header,sizeof(wav_header));
+ if (write(fd,wav_header,sizeof(wav_header)) < sizeof(wav_header)) {
+ fprintf(stderr,"[ERR} Failed to write wav header\n");
+ exit(1);
+ }
}
return(fd);
}
@@ -114,7 +118,10 @@ void close_wav(int fd, FLACContext* fc) {
wav_header[43]=(x&0xff000000)>>24;
lseek(fd,0,SEEK_SET);
- write(fd,wav_header,sizeof(wav_header));
+ if (write(fd,wav_header,sizeof(wav_header)) < sizeof(wav_header)) {
+ fprintf(stderr,"[ERR} Failed to write wav header\n");
+ exit(1);
+ }
close(fd);
}
@@ -295,7 +302,11 @@ int main(int argc, char* argv[]) {
if (fc.bps==24) *(p++)=(decoded1[i]&0xff0000)>>16;
}
}
- write(fdout,wavbuf,fc.blocksize*fc.channels*(fc.bps/8));
+ n = fc.blocksize*fc.channels*(fc.bps/8);
+ if (write(fdout,wavbuf,n) < n) {
+ fprintf(stderr,"[ERR] Write failed\n");
+ exit(1);
+ }
memmove(buf,&buf[consumed],bytesleft-consumed);
bytesleft-=consumed;