More error checking when trying to open files in

cbfstool. (trivial)

Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de>
Acked-by: Patrick Georgi <patrick.georgi@coresystems.de>


git-svn-id: svn://svn.coreboot.org/coreboot/trunk@4634 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
Patrick Georgi
2009-09-15 08:21:46 +00:00
parent fd9c9b8ff8
commit 45d8a83b29
2 changed files with 14 additions and 2 deletions

View File

@ -31,6 +31,8 @@ void *loadfile(const char *filename, uint32_t * romsize_p, void *content,
int place)
{
FILE *file = fopen(filename, "rb");
if (file == NULL)
return NULL;
fseek(file, 0, SEEK_END);
*romsize_p = ftell(file);
fseek(file, 0, SEEK_SET);
@ -65,6 +67,8 @@ void recalculate_rom_geometry(void *romarea)
void *loadrom(const char *filename)
{
void *romarea = loadfile(filename, &romsize, 0, SEEK_SET);
if (romarea == NULL)
return NULL;
recalculate_rom_geometry(romarea);
return romarea;
}