summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Czapiga <jacz@semihalf.com>2021-04-12 11:25:44 +0200
committerPatrick Georgi <pgeorgi@google.com>2021-04-13 16:03:27 +0000
commitec8eef0a6b4d29d5a9bf60476b77ffd05eb32860 (patch)
tree8d8cf3d291c367e4d20927861a0b40a7b65d569a
parent64d31f48d276aa491976fa7b0a8b1eddf9347ca9 (diff)
tests/lib/bootmem-test: Add initialization of lb_mem fields
Add missing initialization of tag and size fields. Include initial size value in assertion in test_bootmem_write_mem_table(). Found-by: Coverity CID 1452250 Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: I27678a4eb01a0e6bedd0ba8c4b22a1b01afeaf12 Reviewed-on: https://review.coreboot.org/c/coreboot/+/52263 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
-rw-r--r--tests/lib/bootmem-test.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/tests/lib/bootmem-test.c b/tests/lib/bootmem-test.c
index 85a01364e5..b571ccbb51 100644
--- a/tests/lib/bootmem-test.c
+++ b/tests/lib/bootmem-test.c
@@ -162,13 +162,15 @@ static void test_bootmem_write_mem_table(void **state)
memset(sentinel_value_buffer, 0x77, required_unused_space_size);
lb_mem = malloc(lb_mem_max_size);
+ lb_mem->tag = LB_TAG_MEMORY;
+ lb_mem->size = sizeof(*lb_mem);
/* Fill rest of buffer with sentinel value */
memset(((u8 *)lb_mem) + expected_allocation_size, 0x77, required_unused_space_size);
bootmem_write_memory_table(lb_mem);
/* There should be only `os_ranges_mock` entries visible in coreboot table */
- assert_int_equal(lb_mem->size,
+ assert_int_equal(lb_mem->size, sizeof(*lb_mem) +
ARRAY_SIZE(os_ranges_mock) * sizeof(struct lb_memory_range));
assert_memory_equal(sentinel_value_buffer,
((u8 *)lb_mem) + expected_allocation_size,
@@ -230,9 +232,12 @@ static void init_memory_table_library(void)
/* Allocate space for 10 lb_mem entries to be safe */
lb_mem = malloc(sizeof(*lb_mem) + 10 * sizeof(struct lb_memory_range));
+ lb_mem->tag = LB_TAG_MEMORY;
+ lb_mem->size = sizeof(*lb_mem);
/* We need to call this only to initialize library */
bootmem_write_memory_table(lb_mem);
+
free(lb_mem);
}