flashrom.c: Use a simpler for-loop in init_eraseblock()

Change-Id: I3b0b51a48e9de8522e0d39c2781e980405af84ba
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/72554
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
diff --git a/flashrom.c b/flashrom.c
index 02e47e1..50e0a86 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -963,13 +963,12 @@
 
 	if (!idx)
 		return;
+	const struct erase_layout *const sub_layout = &layout[idx - 1];
 
 	edata->first_sub_block_index = *sub_block_index;
-	struct eraseblock_data *subedata = &layout[idx - 1].layout_list[*sub_block_index];
-	while (subedata->start_addr >= start_addr && subedata->end_addr <= end_addr &&
-		*sub_block_index < layout[idx-1].block_count) {
-		(*sub_block_index)++;
-		subedata++;
+	for (; *sub_block_index < sub_layout->block_count; ++*sub_block_index) {
+		if (sub_layout->layout_list[*sub_block_index].end_addr > end_addr)
+			break;
 	}
 	edata->last_sub_block_index = *sub_block_index - 1;
 }