Nico Huber has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/30369
Change subject: layout: Show a warning if no region is included ......................................................................
layout: Show a warning if no region is included
This seems better than a plain success message for a (probably accidental) no-op run.
Change-Id: I53b749ce42ecc6c267b6cbe71413d536ec3965c5 Signed-off-by: Nico Huber nico.h@gmx.de --- M cli_classic.c M layout.c M layout.h 3 files changed, 16 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/69/30369/1
diff --git a/cli_classic.c b/cli_classic.c index df9fa67..924445a 100644 --- a/cli_classic.c +++ b/cli_classic.c @@ -645,6 +645,9 @@ goto out_shutdown; }
+ if (layout && layout_num_regions_included(layout) == 0) + msg_gwarn("Warning: Layout specified but no region included!\n"); + flashrom_layout_set(fill_flash, layout); flashrom_flag_set(fill_flash, FLASHROM_FLAG_FORCE, !!force); #if CONFIG_INTERNAL == 1 diff --git a/layout.c b/layout.c index fa66238..f0fbad8 100644 --- a/layout.c +++ b/layout.c @@ -191,6 +191,18 @@ return 0; }
+unsigned int layout_num_regions_included(const struct flashrom_layout *const l) +{ + unsigned int i, count = 0; + + for (i = 0; i < l->num_entries; ++i) { + if (l->entries[i].included) + ++count; + } + + return count; +} + void layout_cleanup(void) { int i; diff --git a/layout.h b/layout.h index eb54a4f..5942038 100644 --- a/layout.h +++ b/layout.h @@ -58,5 +58,6 @@ const struct flashrom_layout *get_layout(const struct flashrom_flashctx *const flashctx);
int process_include_args(struct flashrom_layout *); +unsigned int layout_num_regions_included(const struct flashrom_layout *);
#endif /* !__LAYOUT_H__ */