Anastasia Klimchuk has submitted this change. ( https://review.coreboot.org/c/flashrom/+/71918 )
Change subject: tests/lifecycle.c: Avoid unnecessary heap allocations ......................................................................
tests/lifecycle.c: Avoid unnecessary heap allocations
Just use a static string on the stack.
Change-Id: I0414ab9a63867fc58b04ad62ed3ec4f221448a58 Signed-off-by: Edward O'Callaghan quasisec@google.com Reviewed-on: https://review.coreboot.org/c/flashrom/+/71918 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Anastasia Klimchuk aklm@chromium.org --- M tests/lifecycle.c 1 file changed, 18 insertions(+), 10 deletions(-)
Approvals: build bot (Jenkins): Verified Anastasia Klimchuk: Looks good to me, approved
diff --git a/tests/lifecycle.c b/tests/lifecycle.c index 0c79699..95c4249 100644 --- a/tests/lifecycle.c +++ b/tests/lifecycle.c @@ -40,10 +40,8 @@
struct flashrom_programmer *flashprog;
- char *param_dup = param ? strdup(param) : NULL; - printf("Testing flashrom_programmer_init for programmer=%s ...\n", prog->name); - assert_int_equal(0, flashrom_programmer_init(&flashprog, prog->name, param_dup)); + assert_int_equal(0, flashrom_programmer_init(&flashprog, prog->name, param)); printf("... flashrom_programmer_init for programmer=%s successful\n", prog->name);
if (action) @@ -53,8 +51,6 @@ assert_int_equal(0, flashrom_programmer_shutdown(flashprog)); printf("... flashrom_programmer_shutdown for programmer=%s successful\n", prog->name);
- free(param_dup); - io_mock_register(NULL); }
@@ -82,10 +78,9 @@ io_mock_register(io);
struct flashrom_programmer *flashprog; - char *param_dup = strdup(param);
- printf("Testing init error path for programmer=%s with params: %s ...\n", prog->name, param_dup); - assert_int_equal(error_code, flashrom_programmer_init(&flashprog, prog->name, param_dup)); + printf("Testing init error path for programmer=%s with params: %s ...\n", prog->name, param); + assert_int_equal(error_code, flashrom_programmer_init(&flashprog, prog->name, param)); printf("... init failed with error code %i as expected\n", error_code);
/* @@ -99,7 +94,5 @@ assert_int_equal(0, flashrom_programmer_shutdown(flashprog)); printf("... completed\n");
- free(param_dup); - io_mock_register(NULL); }