Nico Huber submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Angel Pons: Looks good to me, approved Edward O'Callaghan: Looks good to me, approved Anastasia Klimchuk: Looks good to me, approved
libflashrom: Avoid using the global layout

We used to borrow the global layout from the CLI here. Create
a dynamically allocated one instead that doesn't need special
treatment.

Change-Id: Ic48c9e73a3d00782f638f6ff41b620910b24ab6f
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/54284
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
---
M libflashrom.c
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libflashrom.c b/libflashrom.c
index d0f94a9..1ecf650 100644
--- a/libflashrom.c
+++ b/libflashrom.c
@@ -502,15 +502,17 @@
int i;
char name[FMAP_STRLEN + 1];
const struct fmap_area *area;
- struct flashrom_layout *l = get_global_layout();
+ struct flashrom_layout *l;

- if (!fmap || !l)
+ if (!fmap || flashrom_layout_new(&l))
return 1;

for (i = 0, area = fmap->areas; i < fmap->nareas; i++, area++) {
snprintf(name, sizeof(name), "%s", area->name);
- if (flashrom_layout_add_region(l, area->offset, area->offset + area->size - 1, name))
+ if (flashrom_layout_add_region(l, area->offset, area->offset + area->size - 1, name)) {
+ flashrom_layout_release(l);
return 1;
+ }
}

*layout = l;

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

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ic48c9e73a3d00782f638f6ff41b620910b24ab6f
Gerrit-Change-Number: 54284
Gerrit-PatchSet: 8
Gerrit-Owner: Nico Huber <nico.h@gmx.de>
Gerrit-Reviewer: Anastasia Klimchuk <aklm@chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus@gmail.com>
Gerrit-Reviewer: Daniel Campello <campello@chromium.org>
Gerrit-Reviewer: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-Reviewer: Nico Huber <nico.h@gmx.de>
Gerrit-Reviewer: Peter Marheine <pmarheine@chromium.org>
Gerrit-Reviewer: Thomas Heijligen <src@posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter@mailbox.org>
Gerrit-MessageType: merged