diff options
author | Mary Ruthven <mruthven@chromium.org> | 2021-11-09 16:04:35 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-11-18 04:49:34 +0000 |
commit | 69fa572f82506adbc6ac83a9e497226ccf6a67ce (patch) | |
tree | 695fb84341fc7be75050af622be97b55804d1dc4 | |
parent | 9422094698f42d9aa8657617f2dc0b04bfa7e336 (diff) | |
download | chrome-ec-69fa572f82506adbc6ac83a9e497226ccf6a67ce.tar.gz |
Revert "util: Add macro to swap two variables"
This reverts commit eb3ac28cb5a634cf15770e1f79558cdfa4a6923b.
BUG=b:200823466
TEST=make buildall -j
Change-Id: I7b7863a2c19967915d92f5c22b0abc2fb86a2dea
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3273405
Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org>
-rw-r--r-- | include/util.h | 15 | ||||
-rw-r--r-- | test/utils.c | 20 |
2 files changed, 0 insertions, 35 deletions
diff --git a/include/util.h b/include/util.h index a98673bdf3..7a1e6bc077 100644 --- a/include/util.h +++ b/include/util.h @@ -64,22 +64,7 @@ extern "C" { /* Convert number of bits to number of 32-bit words */ #define BITS_TO_WORDS(x) (((x) + 31) / 32) -/* - * Swap two variables (requires c99) - * - * Swapping composites (e.g. a+b, x++) doesn't make sense. So, <a> and <b> - * can only be a variable (x) or a pointer reference (*x) without operator. - */ -#define swap(a, b) \ - do { \ - typeof(a) __t__; \ - __t__ = a; \ - a = b; \ - b = __t__; \ - } while (0) - #ifndef HIDE_EC_STDLIB - /* Standard library functions */ int atoi(const char *nptr); int isdigit(int c); diff --git a/test/utils.c b/test/utils.c index 201f607f0c..28d88764ca 100644 --- a/test/utils.c +++ b/test/utils.c @@ -386,25 +386,6 @@ static int test_mula32(void) return EC_SUCCESS; } -#define SWAP_TEST_HARNESS(t, x, y) \ - do { \ - t a = x, b = y; \ - swap(a, b); \ - TEST_ASSERT(a == y); \ - TEST_ASSERT(b == x); \ - } while (0) - - -static int test_swap(void) -{ - SWAP_TEST_HARNESS(uint8_t, UINT8_MAX, 0); - SWAP_TEST_HARNESS(uint16_t, UINT16_MAX, 0); - SWAP_TEST_HARNESS(uint32_t, UINT32_MAX, 0); - SWAP_TEST_HARNESS(float, 1, 0); - SWAP_TEST_HARNESS(double, 1, 0); - return EC_SUCCESS; -} - static int test_bytes_are_trivial(void) { static const uint8_t all0x00[] = { 0x00, 0x00, 0x00 }; @@ -440,7 +421,6 @@ void run_test(void) RUN_TEST(test_scratchpad); RUN_TEST(test_cond_t); RUN_TEST(test_mula32); - RUN_TEST(test_swap); RUN_TEST(test_bytes_are_trivial); test_print_result(); |