From 4d1c5aa9f7f61fcc7969391f53a66026cb657a3f Mon Sep 17 00:00:00 2001 From: Patrick Georgi Date: Fri, 17 Jul 2015 22:07:26 +0200 Subject: 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 Reviewed-on: http://review.coreboot.org/10967 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin --- util/cbfstool/cbfs_image.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'util') 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; } -- cgit v1.2.3