[flashrom] [PATCH 5/5] (not for merge) Fix the "Use layout for verify operations too" patch in a hacky way

Stefan Tauner stefan.tauner at student.tuwien.ac.at
Sat Dec 24 01:35:20 CET 2011


if you look at the second half of doit with this patch applied, it
is quite clear, that most of it should be guarded by a huge
if(write_it) clause. maybe move this into a function?

Signed-off-by: Stefan Tauner <stefan.tauner at student.tuwien.ac.at>
---
 flashrom.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/flashrom.c b/flashrom.c
index 6aec3f2..95e5c67 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -1800,7 +1800,7 @@ int doit(struct flashctx *flash, int force, const char *filename, int read_it,
 		goto out;
 	}
 
-	if (write_it || verify_it) {
+	if (write_it || verify_it) { /* always true: erase and read already goto'ed */
 		if (read_buf_from_file(newcontents, size, filename)) {
 			ret = 1;
 			goto out;
@@ -1818,7 +1818,7 @@ int doit(struct flashctx *flash, int force, const char *filename, int read_it,
 	 * preserved, but in that case we might perform unneeded erase which
 	 * takes time as well.
 	 */
-	if (read_all_first) {
+	if (read_all_first && write_it) {
 		msg_cinfo("Reading old flash chip contents... ");
 		if (flash->read(flash, oldcontents, 0, size)) {
 			ret = 1;
@@ -1829,7 +1829,8 @@ int doit(struct flashctx *flash, int force, const char *filename, int read_it,
 	msg_cinfo("done.\n");
 
 	/* Build a new image from the given layout. */
-	build_new_image(flash, read_all_first, oldcontents, newcontents);
+	if (write_it)
+		build_new_image(flash, read_all_first, oldcontents, newcontents);
 
 	if (write_it && erase_and_write_flash(flash, oldcontents, newcontents)) {
 		msg_cerr("Uh oh. Erase/write failed.");
-- 
1.7.1





More information about the flashrom mailing list