summaryrefslogtreecommitdiffstats
path: root/util/ifdtool
diff options
context:
space:
mode:
authorPatrick Rudolph <patrick.rudolph@9elements.com>2022-10-22 11:19:02 +0200
committerLean Sheng Tan <sheng.tan@9elements.com>2023-02-02 13:22:00 +0000
commitef5ebdb5bb6de81b703cc13d95e9a634ba311b8c (patch)
tree7d87f020597c9168abb765a1243501ced23aec7b /util/ifdtool
parent1920900baaeeff474030b6ad30c7f7a8af8adba1 (diff)
downloadcoreboot-ef5ebdb5bb6de81b703cc13d95e9a634ba311b8c.tar.gz
coreboot-ef5ebdb5bb6de81b703cc13d95e9a634ba311b8c.tar.bz2
coreboot-ef5ebdb5bb6de81b703cc13d95e9a634ba311b8c.zip
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>
Diffstat (limited to 'util/ifdtool')
-rw-r--r--util/ifdtool/ifdtool.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/util/ifdtool/ifdtool.c b/util/ifdtool/ifdtool.c
index 61aedf53ef3e..98afa4bbcfda 100644
--- a/util/ifdtool/ifdtool.c
+++ b/util/ifdtool/ifdtool.c
@@ -361,6 +361,16 @@ static const char *region_name(unsigned int region_type)
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 @@ static void validate_layout(char *image, int size)
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 @@ static void validate_layout(char *image, int size)
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;