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>
This commit is contained in:
Patrick Georgi 2015-07-17 22:07:26 +02:00 committed by Patrick Georgi
parent 0d618afc84
commit 4d1c5aa9f7
1 changed files with 2 additions and 11 deletions

View File

@ -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;
}