mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 15:12:36 +02:00
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>
This commit is contained in:
parent
20400d6656
commit
46856234b3
@ -40,10 +40,8 @@ static void run_lifecycle(void **state, const struct io_mock *io, const struct p
|
|||||||
|
|
||||||
struct flashrom_programmer *flashprog;
|
struct flashrom_programmer *flashprog;
|
||||||
|
|
||||||
char *param_dup = param ? strdup(param) : NULL;
|
|
||||||
|
|
||||||
printf("Testing flashrom_programmer_init for programmer=%s ...\n", prog->name);
|
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);
|
printf("... flashrom_programmer_init for programmer=%s successful\n", prog->name);
|
||||||
|
|
||||||
if (action)
|
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));
|
assert_int_equal(0, flashrom_programmer_shutdown(flashprog));
|
||||||
printf("... flashrom_programmer_shutdown for programmer=%s successful\n", prog->name);
|
printf("... flashrom_programmer_shutdown for programmer=%s successful\n", prog->name);
|
||||||
|
|
||||||
free(param_dup);
|
|
||||||
|
|
||||||
io_mock_register(NULL);
|
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);
|
io_mock_register(io);
|
||||||
|
|
||||||
struct flashrom_programmer *flashprog;
|
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);
|
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_dup));
|
assert_int_equal(error_code, flashrom_programmer_init(&flashprog, prog->name, param));
|
||||||
printf("... init failed with error code %i as expected\n", error_code);
|
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));
|
assert_int_equal(0, flashrom_programmer_shutdown(flashprog));
|
||||||
printf("... completed\n");
|
printf("... completed\n");
|
||||||
|
|
||||||
free(param_dup);
|
|
||||||
|
|
||||||
io_mock_register(NULL);
|
io_mock_register(NULL);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user