Lean Sheng Tan has submitted this change. ( https://review.coreboot.org/c/coreboot/+/68694 )
Change subject: ifdtool: Introduce region_name_fmap ......................................................................
ifdtool: Introduce region_name_fmap
Instead of directly accessing the region_name array use a helper function. This allows to move the region name array to a separate file.
Change-Id: Ifc810da1628cebd2728d0185502c462ff9428597 Signed-off-by: Patrick Rudolph patrick.rudolph@9elements.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/68694 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Lean Sheng Tan sheng.tan@9elements.com --- M util/ifdtool/ifdtool.c 1 file changed, 29 insertions(+), 2 deletions(-)
Approvals: build bot (Jenkins): Verified Lean Sheng Tan: Looks good to me, approved
diff --git a/util/ifdtool/ifdtool.c b/util/ifdtool/ifdtool.c index 61aedf5..98afa4b 100644 --- a/util/ifdtool/ifdtool.c +++ b/util/ifdtool/ifdtool.c @@ -361,6 +361,16 @@ return region_names[region_type].pretty; }
+static const char *region_name_fmap(unsigned int region_type) +{ + if (region_type >= max_regions) { + fprintf(stderr, "Invalid region type.\n"); + exit(EXIT_FAILURE); + } + + return region_names[region_type].fmapname; +} + static const char *region_name_short(unsigned int region_type) { if (region_type >= max_regions) { @@ -1073,7 +1083,7 @@ fmap = (struct fmap *)(image + fmap_loc);
for (i = 0; i < max_regions; i++) { - if (region_names[i].fmapname == NULL) + if (region_name_fmap(i) == NULL) continue;
region_t region = get_region(frba, i); @@ -1082,7 +1092,7 @@ continue;
const struct fmap_area *area = - fmap_find_area(fmap, region_names[i].fmapname); + fmap_find_area(fmap, region_name_fmap(i));
if (!area) continue;