summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEdward O'Callaghan <quasisec@google.com>2023-01-15 12:49:58 +1100
committerAnastasia Klimchuk <aklm@chromium.org>2023-01-22 05:54:50 +0000
commit46856234b3b6dea93e38c499eecbb432cb1e455e (patch)
tree3383373cf05f9eb1405e66711e4545b943c6fb43 /tests
parent20400d665675292f56f466e0bae7f925fd9ed6aa (diff)
downloadflashrom-46856234b3b6dea93e38c499eecbb432cb1e455e.tar.gz
flashrom-46856234b3b6dea93e38c499eecbb432cb1e455e.tar.bz2
flashrom-46856234b3b6dea93e38c499eecbb432cb1e455e.zip
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>
Diffstat (limited to 'tests')
-rw-r--r--tests/lifecycle.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/tests/lifecycle.c b/tests/lifecycle.c
index 0c7969920..95c424969 100644
--- a/tests/lifecycle.c
+++ b/tests/lifecycle.c
@@ -40,10 +40,8 @@ static void run_lifecycle(void **state, const struct io_mock *io, const struct p
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 @@ static void run_lifecycle(void **state, const struct io_mock *io, const struct p
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 @@ void run_init_error_path(void **state, const struct io_mock *io, const struct pr
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 @@ void run_init_error_path(void **state, const struct io_mock *io, const struct pr
assert_int_equal(0, flashrom_programmer_shutdown(flashprog));
printf("... completed\n");
- free(param_dup);
-
io_mock_register(NULL);
}