Elyes Haouas has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/84912?usp=email )
Change subject: commonlib/fsp_relocate: Use boolean instead of int ......................................................................
commonlib/fsp_relocate: Use boolean instead of int
Moderne C provides boolean, use it instead of old style 0, -1.
Change-Id: I3a9cda6148566bca326cb0258611664fb2ca0ee7 Signed-off-by: Elyes Haouas ehaouas@noos.fr --- M src/commonlib/fsp_relocate.c 1 file changed, 15 insertions(+), 14 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/12/84912/1
diff --git a/src/commonlib/fsp_relocate.c b/src/commonlib/fsp_relocate.c index 0bf50b4..dad5985 100644 --- a/src/commonlib/fsp_relocate.c +++ b/src/commonlib/fsp_relocate.c @@ -5,6 +5,7 @@ #include <commonlib/fsp.h> #include <inttypes.h> #include <commonlib/helpers.h> +#include <stdbool.h> #include <stddef.h> #include <stdint.h> #include <string.h> @@ -158,7 +159,7 @@ return fih; }
-static int pe_relocate(uintptr_t new_addr, void *pe, void *fsp, size_t fih_off) +static bool pe_relocate(uintptr_t new_addr, void *pe, void *fsp, size_t fih_off) { EFI_IMAGE_OPTIONAL_HEADER_UNION *peih; EFI_IMAGE_DOS_HEADER *doshdr; @@ -175,14 +176,14 @@ doshdr = pe; if (read_le16(&doshdr->e_magic) != EFI_IMAGE_DOS_SIGNATURE) { printk(BIOS_ERR, "Invalid DOS Header/magic\n"); - return -1; + return false; }
peih = relative_offset(pe, doshdr->e_lfanew);
if (read_le32(&peih->Pe32.Signature) != EFI_IMAGE_NT_SIGNATURE) { printk(BIOS_ERR, "Invalid PE32 header\n"); - return -1; + return false; }
ophdr = &peih->Pe32.OptionalHeader; @@ -194,13 +195,13 @@ ophdr = NULL; } else { printk(BIOS_ERR, "No support for non-PE32/PE32+ images\n"); - return -1; + return false; }
fih = fsp_get_info_hdr(fsp, fih_off); if (fih == NULL) { printk(BIOS_ERR, "No Image base found for FSP PE32\n"); - return -1; + return false; } image_base = read_le32(&fih->ImageBase); printk(FSP_DBG_LVL, "FSP InfoHdr Image Base is %" PRIX64"\n", image_base); @@ -266,7 +267,7 @@ default: printk(BIOS_ERR, "Unsupported relocation type %d\n", rtype); - return -1; + return false; } } offset += sizeof(*rdata) * rnum; @@ -279,10 +280,10 @@ else write_le64(&ophdr64->ImageBase, img_base_off);
- return 0; + return true; }
-static int te_relocate(uintptr_t new_addr, void *te) +static bool te_relocate(uintptr_t new_addr, void *te) { EFI_TE_IMAGE_HEADER *teih; EFI_IMAGE_DATA_DIRECTORY *relocd; @@ -301,7 +302,7 @@ printk(BIOS_ERR, "TE Signature mismatch: %x vs %x\n", read_le16(&teih->Signature), EFI_TE_IMAGE_HEADER_SIGNATURE); - return -1; + return false; }
/* @@ -367,7 +368,7 @@ } else if (type != EFI_IMAGE_REL_BASED_ABSOLUTE) { printk(BIOS_ERR, "Unknown reloc type: %x\n", type); - return -1; + return false; } num_relocs--; reloc++; @@ -380,7 +381,7 @@ read_le32(&relocb->SizeOfBlock)); }
- return 0; + return true; }
static size_t section_data_size(const EFI_COMMON_SECTION_HEADER *csh) @@ -415,7 +416,7 @@ return size; }
-static int relocate_patch_table(void *fsp, size_t size, size_t offset, +static bool relocate_patch_table(void *fsp, size_t size, size_t offset, ssize_t adjustment) { struct fsp_patch_table *table; @@ -427,7 +428,7 @@ if ((offset + sizeof(*table) > size) || (read_le16(&table->header_length) + offset) > size) { printk(BIOS_ERR, "FSPP not entirely contained in region.\n"); - return -1; + return false; }
num_entries = read_le32(&table->patch_entry_num); @@ -454,7 +455,7 @@ write_le32(reloc, reloc_val + adjustment); }
- return 0; + return true; }
static ssize_t relocate_remaining_items(void *fsp, size_t size,