Skip to content

Commit 5bbf89e

Browse files
committed
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
1 parent 758bb3b commit 5bbf89e

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

tools/gigabeats.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ int gigabeat_s_code(char *infile, char *outfile)
7474
unsigned int size;
7575
unsigned int newsize;
7676
unsigned char* buf;
77+
size_t rc;
7778

7879
in = openinfile(infile);
7980
out = openoutfile(outfile);
@@ -87,13 +88,19 @@ int gigabeat_s_code(char *infile, char *outfile)
8788
newsize = 15 + 16 + 12 + size + 12;
8889
buf = malloc(newsize);
8990
if(buf == NULL) {
90-
fprintf(stderr, "Not enough memory to perform the requested operation. Aborting.\n" );
91-
return 0;
91+
fprintf(stderr,
92+
"Not enough memory to perform the operation. Aborting.\n" );
93+
return 1;
9294
}
9395
fseek(in, 0, SEEK_SET);
94-
fread(buf + 43, size, 1, in);
96+
rc = fread(buf + 43, 1, size, in);
9597
fclose(in);
9698

99+
if(rc != size) {
100+
/* failed to read the wanted amount */
101+
fprintf(stderr, "Failed reading from %s.\n", infile);
102+
return 2;
103+
}
97104
/* Step 2: Create the file header */
98105
sprintf((char *)buf, "B000FF\n");
99106
put_uint32le(0x88200000, buf+7);

tools/scramble.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,7 @@ int main (int argc, char** argv)
329329
else if(!strcmp(argv[1], "-gigabeats")) {
330330
iname = argv[2];
331331
oname = argv[3];
332-
gigabeat_s_code(iname, oname);
333-
return 0;
332+
return gigabeat_s_code(iname, oname);
334333
}
335334
else if(!strcmp(argv[1], "-iaudiox5")) {
336335
iname = argv[2];

0 commit comments

Comments
 (0)