From 0e53931fee0178c4f4ac4e2e6b355b103b5e8c42 Mon Sep 17 00:00:00 2001 From: Sol Boucher Date: Thu, 5 Mar 2015 15:38:03 -0800 Subject: cbfstool: Clean up in preparation for adding new files This enables more warnings on the cbfstool codebase and fixes the issues that surface as a result. A memory leak that used to occur when compressing files with lzma is also found and fixed. Finally, there are several fixes for the Makefile: - Its autodependencies used to be broken because the target for the .dependencies file was misnamed; this meant that Make didn't know how to rebuild the file, and so would silently skip the step of updating it before including it. - The ability to build to a custom output directory by defining the obj variable had bitrotted. - The default value of the obj variable was causing implicit rules not to apply when specifying a file as a target without providing a custom value for obj. - Add a distclean target for removing the .dependencies file. BUG=chromium:461875 TEST=Build an image with cbfstool both before and after. BRANCH=None Change-Id: I951919d63443f2b053c2e67c1ac9872abc0a43ca Signed-off-by: Sol Boucher Original-Commit-Id: 49293443b4e565ca48d284e9a66f80c9c213975d Original-Change-Id: Ia7350c2c3306905984cfa711d5fc4631f0b43d5b Original-Signed-off-by: Sol Boucher Original-Reviewed-on: https://chromium-review.googlesource.com/257340 Original-Reviewed-by: Julius Werner Original-Reviewed-by: Stefan Reinauer Reviewed-on: http://review.coreboot.org/9937 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi --- util/cbfstool/cbfs-mkpayload.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'util/cbfstool/cbfs-mkpayload.c') diff --git a/util/cbfstool/cbfs-mkpayload.c b/util/cbfstool/cbfs-mkpayload.c index d5bcca011eb4..6eebbef9d0f6 100644 --- a/util/cbfstool/cbfs-mkpayload.c +++ b/util/cbfstool/cbfs-mkpayload.c @@ -67,8 +67,8 @@ void xdr_get_seg(struct cbfs_payload_segment *out, out->mem_len = xdr_be.get32(&inheader); } -int parse_elf_to_payload(const struct buffer *input, - struct buffer *output, uint32_t arch, comp_algo algo) +int parse_elf_to_payload(const struct buffer *input, struct buffer *output, + comp_algo algo) { Elf64_Phdr *phdr; Elf64_Ehdr ehdr; @@ -87,7 +87,7 @@ int parse_elf_to_payload(const struct buffer *input, if (!compress) return -1; - if (elf_headers(input, arch, &ehdr, &phdr, &shdr) < 0) + if (elf_headers(input, &ehdr, &phdr, &shdr) < 0) return -1; DEBUG("start: parse_elf_to_payload\n"); @@ -325,7 +325,7 @@ int parse_fv_to_payload(const struct buffer *input, while (fh->file_type == FILETYPE_PAD) { unsigned long offset = (fh->size[2] << 16) | (fh->size[1] << 8) | fh->size[0]; ERROR("skipping %lu bytes of FV padding\n", offset); - fh = (ffs_file_header_t *)(((void*)fh) + offset); + fh = (ffs_file_header_t *)(((uintptr_t)fh) + offset); } if (fh->file_type != FILETYPE_SEC) { ERROR("Not a usable UEFI firmware volume.\n"); @@ -337,7 +337,7 @@ int parse_fv_to_payload(const struct buffer *input, while (cs->section_type == SECTION_RAW) { unsigned long offset = (cs->size[2] << 16) | (cs->size[1] << 8) | cs->size[0]; ERROR("skipping %lu bytes of section padding\n", offset); - cs = (common_section_header_t *)(((void*)cs) + offset); + cs = (common_section_header_t *)(((uintptr_t)cs) + offset); } if (cs->section_type != SECTION_PE32) { ERROR("Not a usable UEFI firmware volume.\n"); @@ -355,7 +355,7 @@ int parse_fv_to_payload(const struct buffer *input, dh_offset = (unsigned long)dh - (unsigned long)input->data; DEBUG("dos header offset = %x\n", dh_offset); - ch = (coff_header_t *)(((void *)dh)+dh->e_lfanew); + ch = (coff_header_t *)(((uintptr_t)dh)+dh->e_lfanew); if (ch->machine == MACHINE_TYPE_X86) { pe_opt_header_32_t *ph; -- cgit v1.2.3