fix return value checks of cbfstool's writerom
Signed-off-by: Stefan Reinauer <stepan@coresystems.de> Acked-by: Stefan Reinauer <stepan@coresystems.de> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5644 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
parent
980a69b8c2
commit
9bb0438535
|
@ -83,7 +83,8 @@ static int cbfs_add(int argc, char **argv)
|
|||
cbfsfile = create_cbfs_file(cbfsname, filedata, &filesize, type, &base);
|
||||
if (add_file_to_cbfs(cbfsfile, filesize, base))
|
||||
return 1;
|
||||
writerom(romname, rom, romsize);
|
||||
if (writerom(romname, rom, romsize))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -131,7 +132,8 @@ static int cbfs_add_payload(int argc, char **argv)
|
|||
CBFS_COMPONENT_PAYLOAD, &base);
|
||||
if (add_file_to_cbfs(cbfsfile, filesize, base))
|
||||
return 1;
|
||||
writerom(romname, rom, romsize);
|
||||
if (writerom(romname, rom, romsize))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -180,7 +182,8 @@ static int cbfs_add_stage(int argc, char **argv)
|
|||
|
||||
if (add_file_to_cbfs(cbfsfile, filesize, base))
|
||||
return 1;
|
||||
writerom(romname, rom, romsize);
|
||||
if (writerom(romname, rom, romsize))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -90,11 +90,23 @@ void *loadrom(const char *filename)
|
|||
return romarea;
|
||||
}
|
||||
|
||||
void writerom(const char *filename, void *start, uint32_t size)
|
||||
int writerom(const char *filename, void *start, uint32_t size)
|
||||
{
|
||||
FILE *file = fopen(filename, "wb");
|
||||
fwrite(start, size, 1, file);
|
||||
if (!file) {
|
||||
fprintf(stderr, "Could not open '%s' for writing: ", filename);
|
||||
perror("");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fwrite(start, size, 1, file) != 1) {
|
||||
fprintf(stderr, "Could not write to '%s': ", filename);
|
||||
perror("");
|
||||
return 1;
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cbfs_file_header(uint32_t physaddr)
|
||||
|
|
|
@ -44,7 +44,7 @@ uint32_t getfilesize(const char *filename);
|
|||
void *loadfile(const char *filename, uint32_t * romsize_p, void *content,
|
||||
int place);
|
||||
void *loadrom(const char *filename);
|
||||
void writerom(const char *filename, void *start, uint32_t size);
|
||||
int writerom(const char *filename, void *start, uint32_t size);
|
||||
|
||||
int iself(unsigned char *input);
|
||||
|
||||
|
|
Loading…
Reference in New Issue