From 71c65023785571074c4dc8fa93e393db8eed022d Mon Sep 17 00:00:00 2001 From: Edward O'Callaghan Date: Tue, 11 Oct 2022 14:24:17 +1100 Subject: layout.c: Use calloc() to ensure a zeroed layout No need to malloc() and then do a DIY memset to zero of the heap. Just use calloc(1, ..) to get a zeroed heap. Change-Id: Id6cf2c4591aec0620f15d8a39495d2bff6597f96 Signed-off-by: Edward O'Callaghan Reviewed-on: https://review.coreboot.org/c/flashrom/+/68279 Tested-by: build bot (Jenkins) Reviewed-by: Angel Pons Reviewed-by: Felix Singer --- layout.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'layout.c') diff --git a/layout.c b/layout.c index 0212699ab..be88428f7 100644 --- a/layout.c +++ b/layout.c @@ -355,14 +355,12 @@ const struct romentry *layout_next( int flashrom_layout_new(struct flashrom_layout **const layout) { - *layout = malloc(sizeof(**layout)); + *layout = calloc(1, sizeof(**layout)); if (!*layout) { msg_gerr("Error creating layout: %s\n", strerror(errno)); return 1; } - const struct flashrom_layout tmp = { 0 }; - **layout = tmp; return 0; } -- cgit v1.2.3