From 14f4e927ca10e89fb54b789040943c1bd0138e5c Mon Sep 17 00:00:00 2001 From: Dmitry Muhomor Date: Sun, 29 Oct 2023 13:23:40 +0200 Subject: [PATCH] memtag_test: remove usages of rand() It didn't work correctly due to not being seeded and its usage wasn't necessary. --- androidtest/memtag/memtag_test.cc | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/androidtest/memtag/memtag_test.cc b/androidtest/memtag/memtag_test.cc index 16c379d..097f1fa 100644 --- a/androidtest/memtag/memtag_test.cc +++ b/androidtest/memtag/memtag_test.cc @@ -36,21 +36,6 @@ void *untag_pointer(void *ptr) { } void tag_distinctness() { - if (rand() & 1) { - // make allocations in all of used size classes and free half of them - - const int max = 21000; - void *ptrs[max]; - - for (int i = 0; i < max; ++i) { - ptrs[i] = malloc(max); - } - - for (int i = 1; i < max; i += 2) { - free(ptrs[i]); - } - } - const size_t cnt = 3000; const size_t iter_cnt = 5; const size_t alloc_cnt = cnt * iter_cnt; @@ -114,13 +99,9 @@ void tag_distinctness() { } u8* alloc_default() { - if (rand() & 1) { - int cnt = rand() & 0x3f; - for (int i = 0; i < cnt; ++i) { - (void) malloc(DEFAULT_ALLOC_SIZE); - } - } - return (u8 *) malloc(DEFAULT_ALLOC_SIZE); + u8 *p = (u8 *) malloc(DEFAULT_ALLOC_SIZE); + assert(p); + return p; } volatile u8 u8_var;