summaryrefslogtreecommitdiff
path: root/util/cbfstool/cbfs_image.c
diff options
context:
space:
mode:
authorPatrick Georgi <pgeorgi@chromium.org>2015-07-17 22:07:26 +0200
committerPatrick Georgi <pgeorgi@google.com>2015-07-18 15:28:33 +0200
commit4d1c5aa9f7f61fcc7969391f53a66026cb657a3f (patch)
tree1804969ed43054d33a6837343d15fa50ce141feb /util/cbfstool/cbfs_image.c
parent0d618afc84db49e2248f9dff6ba21055830bc202 (diff)
cbfstool: Deduplicate code to merge empty files
The code for removing a file had its own merge routine. Use the generic one instead. Change-Id: I90ed007ab86f78a2728f529fa0143c5c1dfbbdc3 Signed-off-by: Patrick Georgi <patrick@georgi-clan.de> Reviewed-on: http://review.coreboot.org/10967 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'util/cbfstool/cbfs_image.c')
-rw-r--r--util/cbfstool/cbfs_image.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c
index 6e040bf847..e095187979 100644
--- a/util/cbfstool/cbfs_image.c
+++ b/util/cbfstool/cbfs_image.c
@@ -691,25 +691,16 @@ int cbfs_export_entry(struct cbfs_image *image, const char *entry_name,
int cbfs_remove_entry(struct cbfs_image *image, const char *name)
{
- struct cbfs_file *entry, *next;
- size_t len;
+ struct cbfs_file *entry;
entry = cbfs_get_entry(image, name);
if (!entry) {
ERROR("CBFS file %s not found.\n", name);
return -1;
}
- next = cbfs_find_next_entry(image, entry);
- assert(next);
DEBUG("cbfs_remove_entry: Removed %s @ 0x%x\n",
entry->filename, cbfs_get_entry_addr(image, entry));
entry->type = htonl(CBFS_COMPONENT_DELETED);
- len = (cbfs_get_entry_addr(image, next) -
- cbfs_get_entry_addr(image, entry));
- entry->offset = htonl(cbfs_calculate_file_header_size(""));
- entry->len = htonl(len - ntohl(entry->offset));
- memset(entry->filename, 0, ntohl(entry->offset) - sizeof(*entry));
- memset(CBFS_SUBHEADER(entry), CBFS_CONTENT_DEFAULT_VALUE,
- ntohl(entry->len));
+ cbfs_walk(image, cbfs_merge_empty_entry, NULL);
return 0;
}