summaryrefslogtreecommitdiffstats
path: root/layout.c
diff options
context:
space:
mode:
authorNico Huber <nico.h@gmx.de>2019-06-15 15:44:39 +0200
committerNico Huber <nico.h@gmx.de>2021-06-26 15:53:31 +0000
commit7ebd578100e6526ef46c98cb9978d692160d8179 (patch)
treef87dc8068f97aa101ae4151dba40a9fd7dc77273 /layout.c
parent06a89d713951a2e08ef8fb698a7688357baa83d1 (diff)
downloadflashrom-7ebd578100e6526ef46c98cb9978d692160d8179.tar.gz
flashrom-7ebd578100e6526ef46c98cb9978d692160d8179.tar.bz2
flashrom-7ebd578100e6526ef46c98cb9978d692160d8179.zip
layout: Add `capacity` field
Use it to keep track of the size of the `entries` array. An interim solution until we have dynamic allocation. Change-Id: Ib5f431bc0a72a79a53fa1376c3417942b19dd3a0 Signed-off-by: Nico Huber <nico.h@gmx.de> Reviewed-on: https://review.coreboot.org/c/flashrom/+/33516 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>
Diffstat (limited to 'layout.c')
-rw-r--r--layout.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/layout.c b/layout.c
index 2446e8f02..0771d42f6 100644
--- a/layout.c
+++ b/layout.c
@@ -26,7 +26,7 @@
#include "layout.h"
static struct romentry entries[MAX_ROMLAYOUT];
-static struct flashrom_layout global_layout = { entries, 0 };
+static struct flashrom_layout global_layout = { entries, MAX_ROMLAYOUT, 0 };
struct flashrom_layout *get_global_layout(void)
{
@@ -87,9 +87,9 @@ int read_romlayout(const char *name)
while (!feof(romlayout)) {
char *tstr1, *tstr2;
- if (layout->num_entries >= MAX_ROMLAYOUT) {
- msg_gerr("Maximum number of ROM images (%i) in layout "
- "file reached.\n", MAX_ROMLAYOUT);
+ if (layout->num_entries >= layout->capacity) {
+ msg_gerr("Maximum number of ROM images (%zu) in layout "
+ "file reached.\n", layout->capacity);
goto _close_ret;
}
if (2 != fscanf(romlayout, "%255s %255s\n", tempstr, tempname))