From 5bbf89e89af7b09c01fb3017a12253743f5e91aa Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 25 May 2009 21:42:44 +0000 Subject: 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 --- tools/gigabeats.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'tools/gigabeats.c') 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) 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); -- cgit v1.2.3