aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/gpr
diff options
context:
space:
mode:
authorGravatar Noah Eisen <ncteisen@google.com>2018-02-09 09:16:55 -0800
committerGravatar Noah Eisen <ncteisen@google.com>2018-02-09 09:16:55 -0800
commitbe82e64b3debcdb1d9ec6a149fc85af0d46bfb7e (patch)
treecc5e1234073eb250a2c319b5a4db2919fce060ea /test/core/gpr
parent194436342137924b4fb7429bede037a4b5ec7edb (diff)
Autofix c casts to c++ casts
Diffstat (limited to 'test/core/gpr')
-rw-r--r--test/core/gpr/alloc_test.cc2
-rw-r--r--test/core/gpr/arena_test.cc2
-rw-r--r--test/core/gpr/cpu_test.cc4
-rw-r--r--test/core/gpr/mpscq_test.cc6
-rw-r--r--test/core/gpr/murmur_hash_test.cc4
-rw-r--r--test/core/gpr/spinlock_test.cc12
-rw-r--r--test/core/gpr/sync_test.cc10
-rw-r--r--test/core/gpr/time_test.cc2
8 files changed, 21 insertions, 21 deletions
diff --git a/test/core/gpr/alloc_test.cc b/test/core/gpr/alloc_test.cc
index bf4471c36f..1f6d5962ba 100644
--- a/test/core/gpr/alloc_test.cc
+++ b/test/core/gpr/alloc_test.cc
@@ -27,7 +27,7 @@ static void* fake_malloc(size_t size) { return (void*)size; }
static void* fake_realloc(void* addr, size_t size) { return (void*)size; }
-static void fake_free(void* addr) { *((intptr_t*)addr) = (intptr_t)0xdeadd00d; }
+static void fake_free(void* addr) { *(static_cast<intptr_t*>(addr)) = static_cast<intptr_t>(0xdeadd00d); }
static void test_custom_allocs() {
const gpr_allocation_functions default_fns = gpr_get_allocation_functions();
diff --git a/test/core/gpr/arena_test.cc b/test/core/gpr/arena_test.cc
index 087a800462..c10d7eaff7 100644
--- a/test/core/gpr/arena_test.cc
+++ b/test/core/gpr/arena_test.cc
@@ -86,7 +86,7 @@ static void concurrent_test_body(void* arg) {
concurrent_test_args* a = static_cast<concurrent_test_args*>(arg);
gpr_event_wait(&a->ev_start, gpr_inf_future(GPR_CLOCK_REALTIME));
for (size_t i = 0; i < concurrent_test_iterations(); i++) {
- *(char*)gpr_arena_alloc(a->arena, 1) = (char)i;
+ *static_cast<char*>(gpr_arena_alloc(a->arena, 1)) = static_cast<char>(i);
}
}
diff --git a/test/core/gpr/cpu_test.cc b/test/core/gpr/cpu_test.cc
index 87cdc0fb50..46a168665c 100644
--- a/test/core/gpr/cpu_test.cc
+++ b/test/core/gpr/cpu_test.cc
@@ -62,7 +62,7 @@ struct cpu_test {
};
static void worker_thread(void* arg) {
- struct cpu_test* ct = (struct cpu_test*)arg;
+ struct cpu_test* ct = static_cast<struct cpu_test*>(arg);
uint32_t cpu;
unsigned r = 12345678;
unsigned i, j;
@@ -103,7 +103,7 @@ static void cpu_test(void) {
gpr_thd_id thd;
ct.ncores = gpr_cpu_num_cores();
GPR_ASSERT(ct.ncores > 0);
- ct.nthreads = (int)ct.ncores * 3;
+ ct.nthreads = static_cast<int>(ct.ncores) * 3;
ct.used = static_cast<int*>(gpr_malloc(ct.ncores * sizeof(int)));
memset(ct.used, 0, ct.ncores * sizeof(int));
gpr_mu_init(&ct.mu);
diff --git a/test/core/gpr/mpscq_test.cc b/test/core/gpr/mpscq_test.cc
index 58df2f14fc..333390e928 100644
--- a/test/core/gpr/mpscq_test.cc
+++ b/test/core/gpr/mpscq_test.cc
@@ -49,7 +49,7 @@ static void test_serial(void) {
gpr_mpscq_push(&q, &new_node(i, nullptr)->node);
}
for (size_t i = 0; i < 10000000; i++) {
- test_node* n = (test_node*)gpr_mpscq_pop(&q);
+ test_node* n = reinterpret_cast<test_node*>(gpr_mpscq_pop(&q));
GPR_ASSERT(n);
GPR_ASSERT(n->i == i);
gpr_free(n);
@@ -97,7 +97,7 @@ static void test_mt(void) {
while ((n = gpr_mpscq_pop(&q)) == nullptr) {
spins++;
}
- test_node* tn = (test_node*)n;
+ test_node* tn = reinterpret_cast<test_node*>(n);
GPR_ASSERT(*tn->ctr == tn->i - 1);
*tn->ctr = tn->i;
if (tn->i == THREAD_ITERATIONS) num_done++;
@@ -134,7 +134,7 @@ static void pull_thread(void* arg) {
while ((n = gpr_mpscq_pop(pa->q)) == nullptr) {
pa->spins++;
}
- test_node* tn = (test_node*)n;
+ test_node* tn = reinterpret_cast<test_node*>(n);
GPR_ASSERT(*tn->ctr == tn->i - 1);
*tn->ctr = tn->i;
if (tn->i == THREAD_ITERATIONS) pa->num_done++;
diff --git a/test/core/gpr/murmur_hash_test.cc b/test/core/gpr/murmur_hash_test.cc
index d920dd3f95..2d2fa72cfb 100644
--- a/test/core/gpr/murmur_hash_test.cc
+++ b/test/core/gpr/murmur_hash_test.cc
@@ -42,8 +42,8 @@ static void verification_test(hash_func hash, uint32_t expected) {
the seed */
for (i = 0; i < 256; i++) {
- key[i] = (uint8_t)i;
- hashes[i] = hash(key, i, (uint32_t)(256u - i));
+ key[i] = static_cast<uint8_t>(i);
+ hashes[i] = hash(key, i, static_cast<uint32_t>(256u - i));
}
/* Then hash the result array */
diff --git a/test/core/gpr/spinlock_test.cc b/test/core/gpr/spinlock_test.cc
index 77e3dfbede..d443684c92 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,27 @@ 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);
}
diff --git a/test/core/gpr/sync_test.cc b/test/core/gpr/sync_test.cc
index 768f96d093..abad930ce6 100644
--- a/test/core/gpr/sync_test.cc
+++ b/test/core/gpr/sync_test.cc
@@ -236,11 +236,11 @@ static void test(const char* name, void (*body)(void* m),
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) {
- fprintf(stderr, " %ld", (long)iterations);
+ fprintf(stderr, " %ld", static_cast<long>(iterations));
fflush(stderr);
m = test_new(10, iterations, incr_step);
if (extra != nullptr) {
@@ -252,7 +252,7 @@ static void test(const char* name, void (*body)(void* m),
test_wait(m);
if (m->counter != m->threads * m->iterations * m->incr_step) {
fprintf(stderr, "counter %ld threads %d iterations %ld\n",
- (long)m->counter, m->threads, (long)m->iterations);
+ static_cast<long>(m->counter), m->threads, static_cast<long>(m->iterations));
fflush(stderr);
GPR_ASSERT(0);
}
@@ -260,8 +260,8 @@ static void test(const char* name, void (*body)(void* m),
iterations <<= 1;
}
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);
}
diff --git a/test/core/gpr/time_test.cc b/test/core/gpr/time_test.cc
index b2b4dce58e..ef7a961d0a 100644
--- a/test/core/gpr/time_test.cc
+++ b/test/core/gpr/time_test.cc
@@ -29,7 +29,7 @@
#include "test/core/util/test_config.h"
static void to_fp(void* arg, const char* buf, size_t len) {
- fwrite(buf, 1, len, (FILE*)arg);
+ fwrite(buf, 1, len, static_cast<FILE*>(arg));
}
/* Convert gpr_intmax x to ascii base b (2..16), and write with