1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-07-02 14:33:18 +02:00

layout: Introduce layout_next()

Also, a `layout.c` internal version mutable_layout_next() that
allows to modify layout entries and a shorthand to look up an
entry by name, _layout_entry_by_name().

Use the new functions where applicable and the code is not
dropped later in this train, and also to compare the layouts
in flashrom_layout_read_from_ifd() in depth.

Change-Id: I284958471c61344d29d92c95d88475065a9ca9aa
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/33542
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Nico Huber
2019-06-16 19:28:35 +02:00
parent 4abb62c4ac
commit 06a89d7139
3 changed files with 88 additions and 66 deletions

View File

@ -470,8 +470,13 @@ int flashrom_layout_read_from_ifd(struct flashrom_layout **const layout, struct
goto _finalize_ret;
}
if (chip_layout->base.num_entries != dump_layout.base.num_entries ||
memcmp(chip_layout->entries, dump_layout.entries, sizeof(dump_layout.entries))) {
const struct romentry *chip_entry = layout_next(&chip_layout->base, NULL);
const struct romentry *dump_entry = layout_next(&dump_layout.base, NULL);
while (chip_entry && dump_entry && !memcmp(chip_entry, dump_entry, sizeof(*chip_entry))) {
chip_entry = layout_next(&chip_layout->base, chip_entry);
dump_entry = layout_next(&dump_layout.base, dump_entry);
}
if (chip_entry || dump_entry) {
msg_cerr("Descriptors don't match!\n");
ret = 5;
goto _finalize_ret;