summaryrefslogtreecommitdiff
path: root/util/cbfstool
diff options
context:
space:
mode:
authorPatrick Georgi <pgeorgi@google.com>2015-08-11 14:35:39 +0200
committerPatrick Georgi <pgeorgi@google.com>2015-08-13 16:08:02 +0200
commit4e54bf93345332fc866b6b8b798a99248edb0698 (patch)
tree76b0b801fb129e8a2a199c6e92d1b76cb5cd9d06 /util/cbfstool
parentc6a8da7f93160b5c853619e203dcfc9d5ba4a553 (diff)
cbfstool: test for duplicate files earlier
No need to read the file before bailing out. Change-Id: Ida7226c6ec227e1105724cdb1e5a0927217a69c7 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: http://review.coreboot.org/11212 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'util/cbfstool')
-rw-r--r--util/cbfstool/cbfstool.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c
index b6a486fd37..6a89476da7 100644
--- a/util/cbfstool/cbfstool.c
+++ b/util/cbfstool/cbfstool.c
@@ -190,6 +190,11 @@ static int cbfs_add_component(const char *filename,
if (cbfs_image_from_buffer(&image, param.image_region, headeroffset))
return 1;
+ if (cbfs_get_entry(&image, name)) {
+ ERROR("'%s' already in ROM image.\n", name);
+ return 1;
+ }
+
struct buffer buffer;
if (buffer_from_file(&buffer, filename) != 0) {
ERROR("Could not load file '%s'.\n", filename);
@@ -202,12 +207,6 @@ static int cbfs_add_component(const char *filename,
return 1;
}
- if (cbfs_get_entry(&image, name)) {
- ERROR("'%s' already in ROM image.\n", name);
- buffer_delete(&buffer);
- return 1;
- }
-
if (IS_TOP_ALIGNED_ADDRESS(offset))
offset = convert_to_from_top_aligned(param.image_region,
-offset);