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 | |
| parent | 758bb3bc628705ff8e5c677b3b2d87720c726c13 (diff) | |
| download | rockbox-5bbf89e89af7b09c01fb3017a12253743f5e91aa.zip rockbox-5bbf89e89af7b09c01fb3017a12253743f5e91aa.tar.gz rockbox-5bbf89e89af7b09c01fb3017a12253743f5e91aa.tar.bz2 rockbox-5bbf89e89af7b09c01fb3017a12253743f5e91aa.tar.xz | |
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
| -rw-r--r-- | tools/gigabeats.c | 13 | ||||
| -rw-r--r-- | tools/scramble.c | 3 |
2 files changed, 11 insertions, 5 deletions
diff --git a/tools/gigabeats.c b/tools/gigabeats.c index 49670a7..2d2d489 100644 --- a/tools/gigabeats.c +++ b/tools/gigabeats.c @@ -74,6 +74,7 @@ int gigabeat_s_code(char *infile, char *outfile) unsigned int size; unsigned int newsize; unsigned char* buf; + size_t rc; in = openinfile(infile); out = openoutfile(outfile); @@ -87,13 +88,19 @@ int gigabeat_s_code(char *infile, char *outfile) newsize = 15 + 16 + 12 + size + 12; buf = malloc(newsize); if(buf == NULL) { - fprintf(stderr, "Not enough memory to perform the requested operation. Aborting.\n" ); - return 0; + fprintf(stderr, + "Not enough memory to perform the operation. Aborting.\n" ); + return 1; } fseek(in, 0, SEEK_SET); - fread(buf + 43, size, 1, in); + rc = fread(buf + 43, 1, size, in); fclose(in); + if(rc != size) { + /* failed to read the wanted amount */ + fprintf(stderr, "Failed reading from %s.\n", infile); + return 2; + } /* Step 2: Create the file header */ sprintf((char *)buf, "B000FF\n"); put_uint32le(0x88200000, buf+7); diff --git a/tools/scramble.c b/tools/scramble.c index a11a5d5..a8bb9a9 100644 --- a/tools/scramble.c +++ b/tools/scramble.c @@ -329,8 +329,7 @@ int main (int argc, char** argv) else if(!strcmp(argv[1], "-gigabeats")) { iname = argv[2]; oname = argv[3]; - gigabeat_s_code(iname, oname); - return 0; + return gigabeat_s_code(iname, oname); } else if(!strcmp(argv[1], "-iaudiox5")) { iname = argv[2]; |