Nico Huber has uploaded this change for review.

View Change

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__ */

To view, visit change 30369. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I53b749ce42ecc6c267b6cbe71413d536ec3965c5
Gerrit-Change-Number: 30369
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h@gmx.de>
Gerrit-MessageType: newchange