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
This commit is contained in:
parent
758bb3bc62
commit
5bbf89e89a
2 changed files with 11 additions and 5 deletions
|
@ -74,6 +74,7 @@ int gigabeat_s_code(char *infile, char *outfile)
|
||||||
unsigned int size;
|
unsigned int size;
|
||||||
unsigned int newsize;
|
unsigned int newsize;
|
||||||
unsigned char* buf;
|
unsigned char* buf;
|
||||||
|
size_t rc;
|
||||||
|
|
||||||
in = openinfile(infile);
|
in = openinfile(infile);
|
||||||
out = openoutfile(outfile);
|
out = openoutfile(outfile);
|
||||||
|
@ -87,13 +88,19 @@ int gigabeat_s_code(char *infile, char *outfile)
|
||||||
newsize = 15 + 16 + 12 + size + 12;
|
newsize = 15 + 16 + 12 + size + 12;
|
||||||
buf = malloc(newsize);
|
buf = malloc(newsize);
|
||||||
if(buf == NULL) {
|
if(buf == NULL) {
|
||||||
fprintf(stderr, "Not enough memory to perform the requested operation. Aborting.\n" );
|
fprintf(stderr,
|
||||||
return 0;
|
"Not enough memory to perform the operation. Aborting.\n" );
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
fseek(in, 0, SEEK_SET);
|
fseek(in, 0, SEEK_SET);
|
||||||
fread(buf + 43, size, 1, in);
|
rc = fread(buf + 43, 1, size, in);
|
||||||
fclose(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 */
|
/* Step 2: Create the file header */
|
||||||
sprintf((char *)buf, "B000FF\n");
|
sprintf((char *)buf, "B000FF\n");
|
||||||
put_uint32le(0x88200000, buf+7);
|
put_uint32le(0x88200000, buf+7);
|
||||||
|
|
|
@ -329,8 +329,7 @@ int main (int argc, char** argv)
|
||||||
else if(!strcmp(argv[1], "-gigabeats")) {
|
else if(!strcmp(argv[1], "-gigabeats")) {
|
||||||
iname = argv[2];
|
iname = argv[2];
|
||||||
oname = argv[3];
|
oname = argv[3];
|
||||||
gigabeat_s_code(iname, oname);
|
return gigabeat_s_code(iname, oname);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
else if(!strcmp(argv[1], "-iaudiox5")) {
|
else if(!strcmp(argv[1], "-iaudiox5")) {
|
||||||
iname = argv[2];
|
iname = argv[2];
|
||||||
|
|
Loading…
Reference in a new issue