aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/util/trickle_endpoint.cc
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/util/trickle_endpoint.cc
parent194436342137924b4fb7429bede037a4b5ec7edb (diff)
Autofix c casts to c++ casts
Diffstat (limited to 'test/core/util/trickle_endpoint.cc')
-rw-r--r--test/core/util/trickle_endpoint.cc32
1 files changed, 16 insertions, 16 deletions
diff --git a/test/core/util/trickle_endpoint.cc b/test/core/util/trickle_endpoint.cc
index 54e1cf19c9..87a8d9c216 100644
--- a/test/core/util/trickle_endpoint.cc
+++ b/test/core/util/trickle_endpoint.cc
@@ -48,7 +48,7 @@ typedef struct {
static void te_read(grpc_endpoint* ep, grpc_slice_buffer* slices,
grpc_closure* cb) {
- trickle_endpoint* te = (trickle_endpoint*)ep;
+ trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
grpc_endpoint_read(te->wrapped, slices, cb);
}
@@ -63,7 +63,7 @@ static void maybe_call_write_cb_locked(trickle_endpoint* te) {
static void te_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
grpc_closure* cb) {
- trickle_endpoint* te = (trickle_endpoint*)ep;
+ trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
gpr_mu_lock(&te->mu);
GPR_ASSERT(te->write_cb == nullptr);
if (te->write_buffer.length == 0) {
@@ -79,24 +79,24 @@ static void te_write(grpc_endpoint* ep, grpc_slice_buffer* slices,
}
static void te_add_to_pollset(grpc_endpoint* ep, grpc_pollset* pollset) {
- trickle_endpoint* te = (trickle_endpoint*)ep;
+ trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
grpc_endpoint_add_to_pollset(te->wrapped, pollset);
}
static void te_add_to_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset_set) {
- trickle_endpoint* te = (trickle_endpoint*)ep;
+ trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
grpc_endpoint_add_to_pollset_set(te->wrapped, pollset_set);
}
static void te_delete_from_pollset_set(grpc_endpoint* ep,
grpc_pollset_set* pollset_set) {
- trickle_endpoint* te = (trickle_endpoint*)ep;
+ trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
grpc_endpoint_delete_from_pollset_set(te->wrapped, pollset_set);
}
static void te_shutdown(grpc_endpoint* ep, grpc_error* why) {
- trickle_endpoint* te = (trickle_endpoint*)ep;
+ trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
gpr_mu_lock(&te->mu);
if (te->error == GRPC_ERROR_NONE) {
te->error = GRPC_ERROR_REF(why);
@@ -107,7 +107,7 @@ static void te_shutdown(grpc_endpoint* ep, grpc_error* why) {
}
static void te_destroy(grpc_endpoint* ep) {
- trickle_endpoint* te = (trickle_endpoint*)ep;
+ trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
grpc_endpoint_destroy(te->wrapped);
gpr_mu_destroy(&te->mu);
grpc_slice_buffer_destroy_internal(&te->write_buffer);
@@ -117,22 +117,22 @@ static void te_destroy(grpc_endpoint* ep) {
}
static grpc_resource_user* te_get_resource_user(grpc_endpoint* ep) {
- trickle_endpoint* te = (trickle_endpoint*)ep;
+ trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
return grpc_endpoint_get_resource_user(te->wrapped);
}
static char* te_get_peer(grpc_endpoint* ep) {
- trickle_endpoint* te = (trickle_endpoint*)ep;
+ trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
return grpc_endpoint_get_peer(te->wrapped);
}
static int te_get_fd(grpc_endpoint* ep) {
- trickle_endpoint* te = (trickle_endpoint*)ep;
+ trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
return grpc_endpoint_get_fd(te->wrapped);
}
static void te_finish_write(void* arg, grpc_error* error) {
- trickle_endpoint* te = (trickle_endpoint*)arg;
+ trickle_endpoint* te = static_cast<trickle_endpoint*>(arg);
gpr_mu_lock(&te->mu);
te->writing = false;
grpc_slice_buffer_reset_and_unref(&te->writing_buffer);
@@ -152,7 +152,7 @@ static const grpc_endpoint_vtable vtable = {te_read,
grpc_endpoint* grpc_trickle_endpoint_create(grpc_endpoint* wrap,
double bytes_per_second) {
- trickle_endpoint* te = (trickle_endpoint*)gpr_malloc(sizeof(*te));
+ trickle_endpoint* te = static_cast<trickle_endpoint*>(gpr_malloc(sizeof(*te)));
te->base.vtable = &vtable;
te->wrapped = wrap;
te->bytes_per_second = bytes_per_second;
@@ -166,16 +166,16 @@ grpc_endpoint* grpc_trickle_endpoint_create(grpc_endpoint* wrap,
}
static double ts2dbl(gpr_timespec s) {
- return (double)s.tv_sec + 1e-9 * (double)s.tv_nsec;
+ return static_cast<double>(s.tv_sec) + 1e-9 * static_cast<double>(s.tv_nsec);
}
size_t grpc_trickle_endpoint_trickle(grpc_endpoint* ep) {
- trickle_endpoint* te = (trickle_endpoint*)ep;
+ trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
gpr_mu_lock(&te->mu);
if (!te->writing && te->write_buffer.length > 0) {
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC);
double elapsed = ts2dbl(gpr_time_sub(now, te->last_write));
- size_t bytes = (size_t)(te->bytes_per_second * elapsed);
+ size_t bytes = static_cast<size_t>(te->bytes_per_second * elapsed);
// gpr_log(GPR_DEBUG, "%lf elapsed --> %" PRIdPTR " bytes", elapsed, bytes);
if (bytes > 0) {
grpc_slice_buffer_move_first(&te->write_buffer,
@@ -195,7 +195,7 @@ size_t grpc_trickle_endpoint_trickle(grpc_endpoint* ep) {
}
size_t grpc_trickle_get_backlog(grpc_endpoint* ep) {
- trickle_endpoint* te = (trickle_endpoint*)ep;
+ trickle_endpoint* te = reinterpret_cast<trickle_endpoint*>(ep);
gpr_mu_lock(&te->mu);
size_t backlog = te->write_buffer.length;
gpr_mu_unlock(&te->mu);