diff options
Diffstat (limited to 'test/core/gpr/spinlock_test.cc')
-rw-r--r-- | test/core/gpr/spinlock_test.cc | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/test/core/gpr/spinlock_test.cc b/test/core/gpr/spinlock_test.cc index 77e3dfbede..cd6de69126 100644 --- a/test/core/gpr/spinlock_test.cc +++ b/test/core/gpr/spinlock_test.cc @@ -46,7 +46,7 @@ static struct test* test_new(int threads, int64_t iterations, int incr_step) { struct test* m = static_cast<struct test*>(gpr_malloc(sizeof(*m))); m->thread_count = threads; m->threads = static_cast<gpr_thd_id*>( - gpr_malloc(sizeof(*m->threads) * (size_t)threads)); + gpr_malloc(sizeof(*m->threads) * static_cast<size_t>(threads))); m->iterations = iterations; m->counter = 0; m->thread_count = 0; @@ -93,27 +93,30 @@ static void test(const char* name, void (*body)(void* m), int timeout_s, gpr_timespec start = gpr_now(GPR_CLOCK_REALTIME); gpr_timespec time_taken; gpr_timespec deadline = gpr_time_add( - start, gpr_time_from_micros((int64_t)timeout_s * 1000000, GPR_TIMESPAN)); + start, gpr_time_from_micros(static_cast<int64_t>(timeout_s) * 1000000, + GPR_TIMESPAN)); fprintf(stderr, "%s:", name); fflush(stderr); while (gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0) { if (iterations < INT64_MAX / 2) iterations <<= 1; - fprintf(stderr, " %ld", (long)iterations); + fprintf(stderr, " %ld", static_cast<long>(iterations)); fflush(stderr); m = test_new(10, iterations, incr_step); test_create_threads(m, body); test_wait(m); if (m->counter != m->thread_count * m->iterations * m->incr_step) { fprintf(stderr, "counter %ld threads %d iterations %ld\n", - (long)m->counter, m->thread_count, (long)m->iterations); + static_cast<long>(m->counter), m->thread_count, + static_cast<long>(m->iterations)); fflush(stderr); GPR_ASSERT(0); } test_destroy(m); } time_taken = gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), start); - fprintf(stderr, " done %lld.%09d s\n", (long long)time_taken.tv_sec, - (int)time_taken.tv_nsec); + fprintf(stderr, " done %lld.%09d s\n", + static_cast<long long>(time_taken.tv_sec), + static_cast<int>(time_taken.tv_nsec)); fflush(stderr); } |