Attention is currently required from: Anastasia Klimchuk.
Edward O'Callaghan has uploaded this change for review.
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>
---
M tests/lifecycle.c
1 file changed, 15 insertions(+), 10 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/18/71918/1
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);
}
To view, visit change 71918. To unsubscribe, or for help writing mail filters, visit settings.