From 297b613604ef59e09d6a8603a5a46ce3b2f12460 Mon Sep 17 00:00:00 2001 From: Laurent Morichetti Date: Thu, 15 Apr 2021 23:08:00 -0700 Subject: [PATCH] Fix random bugs discovered while reading the code In HsaTimer::correlated_pair_ns, the time ID should be used to select the clock ID passed to clock_gettime. In MemoryPool::allocator_default, pass the correct value to realloc. Change-Id: I5d10c0994c07fdeadd99c81deba4e71a4f579523 --- src/core/memory_pool.h | 2 +- src/util/hsa_rsrc_factory.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/memory_pool.h b/src/core/memory_pool.h index fe2f1a6d3a..5b036d0fd4 100644 --- a/src/core/memory_pool.h +++ b/src/core/memory_pool.h @@ -52,7 +52,7 @@ class MemoryPool { if (*ptr == NULL) { *ptr = reinterpret_cast(malloc(size)); } else if (size != 0) { - *ptr = reinterpret_cast(realloc(ptr, size)); + *ptr = reinterpret_cast(realloc(*ptr, size)); } else { free(*ptr); *ptr = NULL; diff --git a/src/util/hsa_rsrc_factory.h b/src/util/hsa_rsrc_factory.h index 3bfeda68c1..21e25082ab 100644 --- a/src/util/hsa_rsrc_factory.h +++ b/src/util/hsa_rsrc_factory.h @@ -223,7 +223,7 @@ class HsaTimer { void correlated_pair_ns(time_id_t time_id, uint32_t iters, timestamp_t* timestamp_v, timestamp_t* time_v, timestamp_t* error_v) const { clockid_t clock_id = 0; - switch (clock_id) { + switch (time_id) { case TIME_ID_CLOCK_REALTIME: clock_id = CLOCK_REALTIME; break;