diff options
author | Edward O'Callaghan <quasisec@google.com> | 2023-01-15 12:43:42 +1100 |
---|---|---|
committer | Anastasia Klimchuk <aklm@chromium.org> | 2023-01-22 05:32:22 +0000 |
commit | 20400d665675292f56f466e0bae7f925fd9ed6aa (patch) | |
tree | 76cf5aac887778ed871d3c3205869446f7477cfa /tests/chip.c | |
parent | 673cb357d411e6d95be7cbf31513b46615355e12 (diff) | |
download | flashrom-20400d665675292f56f466e0bae7f925fd9ed6aa.tar.gz flashrom-20400d665675292f56f466e0bae7f925fd9ed6aa.tar.bz2 flashrom-20400d665675292f56f466e0bae7f925fd9ed6aa.zip |
tests/chip{_wp}.c: Avoid unnecessary heap allocations
Just use a static string on the stack.
Change-Id: Ic6cb4f32094ae5868912ebcffc8ab21026c48d32
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/71917
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Diffstat (limited to 'tests/chip.c')
-rw-r--r-- | tests/chip.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/tests/chip.c b/tests/chip.c index e82719e1..dc2ca11b 100644 --- a/tests/chip.c +++ b/tests/chip.c @@ -243,7 +243,7 @@ void erase_chip_with_dummyflasher_test_success(void **state) * Dummyflasher is capable to emulate W25Q128.V, so we ask it to do this. * Nothing to mock, dummy is taking care of this already. */ - char *param_dup = strdup("bus=spi,emulate=W25Q128FV"); + const char *param_dup = "bus=spi,emulate=W25Q128FV"; setup_chip(&flashctx, &layout, &mock_chip, param_dup, &chip_io); @@ -252,8 +252,6 @@ void erase_chip_with_dummyflasher_test_success(void **state) printf("Erase chip operation done.\n"); teardown(&layout); - - free(param_dup); } void read_chip_test_success(void **state) @@ -311,7 +309,7 @@ void read_chip_with_dummyflasher_test_success(void **state) * Dummyflasher is capable to emulate W25Q128.V, so we ask it to do this. * Nothing to mock, dummy is taking care of this already. */ - char *param_dup = strdup("bus=spi,emulate=W25Q128FV"); + const char *param_dup = "bus=spi,emulate=W25Q128FV"; setup_chip(&flashctx, &layout, &mock_chip, param_dup, &chip_io); @@ -326,7 +324,6 @@ void read_chip_with_dummyflasher_test_success(void **state) teardown(&layout); - free(param_dup); free(buf); } @@ -398,7 +395,7 @@ void write_chip_with_dummyflasher_test_success(void **state) * Dummyflasher is capable to emulate W25Q128.V, so we ask it to do this. * Nothing to mock, dummy is taking care of this already. */ - char *param_dup = strdup("bus=spi,emulate=W25Q128FV"); + const char *param_dup = "bus=spi,emulate=W25Q128FV"; setup_chip(&flashctx, &layout, &mock_chip, param_dup, &chip_io); @@ -414,7 +411,6 @@ void write_chip_with_dummyflasher_test_success(void **state) teardown(&layout); - free(param_dup); free(newcontents); } @@ -438,7 +434,7 @@ void write_nonaligned_region_with_dummyflasher_test_success(void **state) * Dummyflasher is capable to emulate W25Q128.V, so we ask it to do this. * Nothing to mock, dummy is taking care of this already. */ - char *param_dup = strdup("bus=spi,emulate=W25Q128FV"); + const char *param_dup = "bus=spi,emulate=W25Q128FV"; /* FIXME: MOCK_CHIP_CONTENT is buggy within setup_chip, it should also * not be either 0x00 or 0xFF as those are specific values related to @@ -505,7 +501,6 @@ void write_nonaligned_region_with_dummyflasher_test_success(void **state) printf("Entire chip verify op done.\n"); teardown(&layout); - free(param_dup); free(newcontents); } @@ -578,7 +573,7 @@ void verify_chip_with_dummyflasher_test_success(void **state) * Dummyflasher is capable to emulate W25Q128.V, so we ask it to do this. * Nothing to mock, dummy is taking care of this already. */ - char *param_dup = strdup("bus=spi,emulate=W25Q128FV"); + const char *param_dup = "bus=spi,emulate=W25Q128FV"; setup_chip(&flashctx, &layout, &mock_chip, param_dup, &verify_chip_io); @@ -605,6 +600,5 @@ void verify_chip_with_dummyflasher_test_success(void **state) teardown(&layout); - free(param_dup); free(newcontents); } |