diff options
author | Daniel Stenberg <daniel@haxx.se> | 2009-05-25 21:42:44 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2009-05-25 21:42:44 +0000 |
commit | 5bbf89e89af7b09c01fb3017a12253743f5e91aa (patch) | |
tree | 96398a2fde56ac019fdab931508831d3cad84b24 /tools/gigabeats.c | |
parent | 758bb3bc628705ff8e5c677b3b2d87720c726c13 (diff) | |
download | rockbox-5bbf89e89af7b09c01fb3017a12253743f5e91aa.tar.gz rockbox-5bbf89e89af7b09c01fb3017a12253743f5e91aa.zip |
fix yellow by acknowledging the fread() return code and also allow
gigabeat_s_code() to actually return an error code if it fails
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21084 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools/gigabeats.c')
-rw-r--r-- | tools/gigabeats.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/tools/gigabeats.c b/tools/gigabeats.c index 49670a7dc3..2d2d489865 100644 --- a/tools/gigabeats.c +++ b/tools/gigabeats.c | |||
@@ -74,6 +74,7 @@ int gigabeat_s_code(char *infile, char *outfile) | |||
74 | unsigned int size; | 74 | unsigned int size; |
75 | unsigned int newsize; | 75 | unsigned int newsize; |
76 | unsigned char* buf; | 76 | unsigned char* buf; |
77 | size_t rc; | ||
77 | 78 | ||
78 | in = openinfile(infile); | 79 | in = openinfile(infile); |
79 | out = openoutfile(outfile); | 80 | out = openoutfile(outfile); |
@@ -87,13 +88,19 @@ int gigabeat_s_code(char *infile, char *outfile) | |||
87 | newsize = 15 + 16 + 12 + size + 12; | 88 | newsize = 15 + 16 + 12 + size + 12; |
88 | buf = malloc(newsize); | 89 | buf = malloc(newsize); |
89 | if(buf == NULL) { | 90 | if(buf == NULL) { |
90 | fprintf(stderr, "Not enough memory to perform the requested operation. Aborting.\n" ); | 91 | fprintf(stderr, |
91 | return 0; | 92 | "Not enough memory to perform the operation. Aborting.\n" ); |
93 | return 1; | ||
92 | } | 94 | } |
93 | fseek(in, 0, SEEK_SET); | 95 | fseek(in, 0, SEEK_SET); |
94 | fread(buf + 43, size, 1, in); | 96 | rc = fread(buf + 43, 1, size, in); |
95 | fclose(in); | 97 | fclose(in); |
96 | 98 | ||
99 | if(rc != size) { | ||
100 | /* failed to read the wanted amount */ | ||
101 | fprintf(stderr, "Failed reading from %s.\n", infile); | ||
102 | return 2; | ||
103 | } | ||
97 | /* Step 2: Create the file header */ | 104 | /* Step 2: Create the file header */ |
98 | sprintf((char *)buf, "B000FF\n"); | 105 | sprintf((char *)buf, "B000FF\n"); |
99 | put_uint32le(0x88200000, buf+7); | 106 | put_uint32le(0x88200000, buf+7); |