diff options
author | Noah Eisen <ncteisen@google.com> | 2018-02-09 09:16:55 -0800 |
---|---|---|
committer | Noah Eisen <ncteisen@google.com> | 2018-02-09 09:16:55 -0800 |
commit | be82e64b3debcdb1d9ec6a149fc85af0d46bfb7e (patch) | |
tree | cc5e1234073eb250a2c319b5a4db2919fce060ea /src/core/lib/iomgr/tcp_posix.cc | |
parent | 194436342137924b4fb7429bede037a4b5ec7edb (diff) |
Autofix c casts to c++ casts
Diffstat (limited to 'src/core/lib/iomgr/tcp_posix.cc')
-rw-r--r-- | src/core/lib/iomgr/tcp_posix.cc | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index e78e19761a..71819adaba 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -116,7 +116,7 @@ static void tcp_drop_uncovered_then_handle_write(void* arg /* grpc_tcp */, grpc_error* error); static void done_poller(void* bp, grpc_error* error_ignored) { - backup_poller* p = (backup_poller*)bp; + backup_poller* p = static_cast<backup_poller*>(bp); if (grpc_tcp_trace.enabled()) { gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p destroy", p); } @@ -125,7 +125,7 @@ static void done_poller(void* bp, grpc_error* error_ignored) { } static void run_poller(void* bp, grpc_error* error_ignored) { - backup_poller* p = (backup_poller*)bp; + backup_poller* p = static_cast<backup_poller*>(bp); if (grpc_tcp_trace.enabled()) { gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p run", p); } @@ -165,8 +165,8 @@ static void drop_uncovered(grpc_tcp* tcp) { gpr_atm old_count = gpr_atm_no_barrier_fetch_add(&g_uncovered_notifications_pending, -1); if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p uncover cnt %d->%d", p, (int)old_count, - (int)old_count - 1); + gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p uncover cnt %d->%d", p, static_cast<int>(old_count), + static_cast<int>(old_count) - 1); } GPR_ASSERT(old_count != 1); } @@ -176,12 +176,12 @@ static void cover_self(grpc_tcp* tcp) { gpr_atm old_count = gpr_atm_no_barrier_fetch_add(&g_uncovered_notifications_pending, 2); if (grpc_tcp_trace.enabled()) { - gpr_log(GPR_DEBUG, "BACKUP_POLLER: cover cnt %d->%d", (int)old_count, - 2 + (int)old_count); + gpr_log(GPR_DEBUG, "BACKUP_POLLER: cover cnt %d->%d", static_cast<int>(old_count), + 2 + static_cast<int>(old_count)); } if (old_count == 0) { GRPC_STATS_INC_TCP_BACKUP_POLLERS_CREATED(); - p = (backup_poller*)gpr_zalloc(sizeof(*p) + grpc_pollset_size()); + p = static_cast<backup_poller*>(gpr_zalloc(sizeof(*p) + grpc_pollset_size())); if (grpc_tcp_trace.enabled()) { gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p create", p); } @@ -230,12 +230,12 @@ static void tcp_drop_uncovered_then_handle_write(void* arg, grpc_error* error) { if (grpc_tcp_trace.enabled()) { gpr_log(GPR_DEBUG, "TCP:%p got_write: %s", arg, grpc_error_string(error)); } - drop_uncovered((grpc_tcp*)arg); + drop_uncovered(static_cast<grpc_tcp*>(arg)); tcp_handle_write(arg, error); } static void add_to_estimate(grpc_tcp* tcp, size_t bytes) { - tcp->bytes_read_this_round += (double)bytes; + tcp->bytes_read_this_round += static_cast<double>(bytes); } static void finish_estimate(grpc_tcp* tcp) { @@ -257,10 +257,10 @@ static size_t get_target_read_size(grpc_tcp* tcp) { double pressure = grpc_resource_quota_get_memory_pressure(rq); double target = tcp->target_length * (pressure > 0.8 ? (1.0 - pressure) / 0.2 : 1.0); - size_t sz = (((size_t)GPR_CLAMP(target, tcp->min_read_chunk_size, + size_t sz = ((static_cast<size_t>GPR_CLAMP(target, tcp->min_read_chunk_size, tcp->max_read_chunk_size)) + 255) & - ~(size_t)255; + ~static_cast<size_t>(255); /* don't use more than 1/16th of the overall resource quota for a single read * alloc */ size_t rqmax = grpc_resource_quota_peek_size(rq); @@ -285,7 +285,7 @@ static void tcp_handle_read(void* arg /* grpc_tcp */, grpc_error* error); static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error); static void tcp_shutdown(grpc_endpoint* ep, grpc_error* why) { - grpc_tcp* tcp = (grpc_tcp*)ep; + grpc_tcp* tcp = reinterpret_cast<grpc_tcp*>(ep); grpc_fd_shutdown(tcp->em_fd, why); grpc_resource_user_shutdown(tcp->resource_user); } @@ -339,7 +339,7 @@ static void tcp_ref(grpc_tcp* tcp) { gpr_ref(&tcp->refcount); } static void tcp_destroy(grpc_endpoint* ep) { grpc_network_status_unregister_endpoint(ep); - grpc_tcp* tcp = (grpc_tcp*)ep; + grpc_tcp* tcp = reinterpret_cast<grpc_tcp*>(ep); grpc_slice_buffer_reset_and_unref_internal(&tcp->last_read_buffer); TCP_UNREF(tcp, "destroy"); } @@ -385,7 +385,7 @@ static void tcp_do_read(grpc_tcp* tcp) { msg.msg_name = nullptr; msg.msg_namelen = 0; msg.msg_iov = iov; - msg.msg_iovlen = (msg_iovlen_type)tcp->incoming_buffer->count; + msg.msg_iovlen = static_cast<msg_iovlen_type>(tcp->incoming_buffer->count); msg.msg_control = nullptr; msg.msg_controllen = 0; msg.msg_flags = 0; @@ -421,12 +421,12 @@ static void tcp_do_read(grpc_tcp* tcp) { TCP_UNREF(tcp, "read"); } else { GRPC_STATS_INC_TCP_READ_SIZE(read_bytes); - add_to_estimate(tcp, (size_t)read_bytes); + add_to_estimate(tcp, static_cast<size_t>(read_bytes)); GPR_ASSERT((size_t)read_bytes <= tcp->incoming_buffer->length); - if ((size_t)read_bytes < tcp->incoming_buffer->length) { + if (static_cast<size_t>(read_bytes) < tcp->incoming_buffer->length) { grpc_slice_buffer_trim_end( tcp->incoming_buffer, - tcp->incoming_buffer->length - (size_t)read_bytes, + tcp->incoming_buffer->length - static_cast<size_t>(read_bytes), &tcp->last_read_buffer); } GPR_ASSERT((size_t)read_bytes == tcp->incoming_buffer->length); @@ -436,7 +436,7 @@ static void tcp_do_read(grpc_tcp* tcp) { } static void tcp_read_allocation_done(void* tcpp, grpc_error* error) { - grpc_tcp* tcp = (grpc_tcp*)tcpp; + grpc_tcp* tcp = static_cast<grpc_tcp*>(tcpp); if (grpc_tcp_trace.enabled()) { gpr_log(GPR_DEBUG, "TCP:%p read_allocation_done: %s", tcp, grpc_error_string(error)); @@ -469,7 +469,7 @@ static void tcp_continue_read(grpc_tcp* tcp) { } static void tcp_handle_read(void* arg /* grpc_tcp */, grpc_error* error) { - grpc_tcp* tcp = (grpc_tcp*)arg; + grpc_tcp* tcp = static_cast<grpc_tcp*>(arg); GPR_ASSERT(!tcp->finished_edge); if (grpc_tcp_trace.enabled()) { gpr_log(GPR_DEBUG, "TCP:%p got_read: %s", tcp, grpc_error_string(error)); @@ -487,7 +487,7 @@ static void tcp_handle_read(void* arg /* grpc_tcp */, grpc_error* error) { static void tcp_read(grpc_endpoint* ep, grpc_slice_buffer* incoming_buffer, grpc_closure* cb) { - grpc_tcp* tcp = (grpc_tcp*)ep; + grpc_tcp* tcp = reinterpret_cast<grpc_tcp*>(ep); GPR_ASSERT(tcp->read_cb == nullptr); tcp->read_cb = cb; tcp->incoming_buffer = incoming_buffer; @@ -578,7 +578,7 @@ static bool tcp_flush(grpc_tcp* tcp, grpc_error** error) { } GPR_ASSERT(tcp->outgoing_byte_idx == 0); - trailing = sending_length - (size_t)sent_length; + trailing = sending_length - static_cast<size_t>(sent_length); while (trailing > 0) { size_t slice_length; @@ -602,7 +602,7 @@ static bool tcp_flush(grpc_tcp* tcp, grpc_error** error) { } static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error) { - grpc_tcp* tcp = (grpc_tcp*)arg; + grpc_tcp* tcp = static_cast<grpc_tcp*>(arg); grpc_closure* cb; if (error != GRPC_ERROR_NONE) { @@ -634,7 +634,7 @@ static void tcp_handle_write(void* arg /* grpc_tcp */, grpc_error* error) { static void tcp_write(grpc_endpoint* ep, grpc_slice_buffer* buf, grpc_closure* cb) { GPR_TIMER_SCOPE("tcp_write", 0); - grpc_tcp* tcp = (grpc_tcp*)ep; + grpc_tcp* tcp = reinterpret_cast<grpc_tcp*>(ep); grpc_error* error = GRPC_ERROR_NONE; if (grpc_tcp_trace.enabled()) { @@ -678,34 +678,34 @@ static void tcp_write(grpc_endpoint* ep, grpc_slice_buffer* buf, } static void tcp_add_to_pollset(grpc_endpoint* ep, grpc_pollset* pollset) { - grpc_tcp* tcp = (grpc_tcp*)ep; + grpc_tcp* tcp = reinterpret_cast<grpc_tcp*>(ep); grpc_pollset_add_fd(pollset, tcp->em_fd); } static void tcp_add_to_pollset_set(grpc_endpoint* ep, grpc_pollset_set* pollset_set) { - grpc_tcp* tcp = (grpc_tcp*)ep; + grpc_tcp* tcp = reinterpret_cast<grpc_tcp*>(ep); grpc_pollset_set_add_fd(pollset_set, tcp->em_fd); } static void tcp_delete_from_pollset_set(grpc_endpoint* ep, grpc_pollset_set* pollset_set) { - grpc_tcp* tcp = (grpc_tcp*)ep; + grpc_tcp* tcp = reinterpret_cast<grpc_tcp*>(ep); grpc_pollset_set_del_fd(pollset_set, tcp->em_fd); } static char* tcp_get_peer(grpc_endpoint* ep) { - grpc_tcp* tcp = (grpc_tcp*)ep; + grpc_tcp* tcp = reinterpret_cast<grpc_tcp*>(ep); return gpr_strdup(tcp->peer_string); } static int tcp_get_fd(grpc_endpoint* ep) { - grpc_tcp* tcp = (grpc_tcp*)ep; + grpc_tcp* tcp = reinterpret_cast<grpc_tcp*>(ep); return tcp->fd; } static grpc_resource_user* tcp_get_resource_user(grpc_endpoint* ep) { - grpc_tcp* tcp = (grpc_tcp*)ep; + grpc_tcp* tcp = reinterpret_cast<grpc_tcp*>(ep); return tcp->resource_user; } @@ -733,19 +733,19 @@ grpc_endpoint* grpc_tcp_create(grpc_fd* em_fd, for (size_t i = 0; i < channel_args->num_args; i++) { if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_TCP_READ_CHUNK_SIZE)) { - grpc_integer_options options = {(int)tcp_read_chunk_size, 1, + grpc_integer_options options = {tcp_read_chunk_size, 1, MAX_CHUNK_SIZE}; tcp_read_chunk_size = grpc_channel_arg_get_integer(&channel_args->args[i], options); } else if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_TCP_MIN_READ_CHUNK_SIZE)) { - grpc_integer_options options = {(int)tcp_read_chunk_size, 1, + grpc_integer_options options = {tcp_read_chunk_size, 1, MAX_CHUNK_SIZE}; tcp_min_read_chunk_size = grpc_channel_arg_get_integer(&channel_args->args[i], options); } else if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_TCP_MAX_READ_CHUNK_SIZE)) { - grpc_integer_options options = {(int)tcp_read_chunk_size, 1, + grpc_integer_options options = {tcp_read_chunk_size, 1, MAX_CHUNK_SIZE}; tcp_max_read_chunk_size = grpc_channel_arg_get_integer(&channel_args->args[i], options); @@ -753,7 +753,7 @@ grpc_endpoint* grpc_tcp_create(grpc_fd* em_fd, strcmp(channel_args->args[i].key, GRPC_ARG_RESOURCE_QUOTA)) { grpc_resource_quota_unref_internal(resource_quota); resource_quota = grpc_resource_quota_ref_internal( - (grpc_resource_quota*)channel_args->args[i].value.pointer.p); + static_cast<grpc_resource_quota*>(channel_args->args[i].value.pointer.p)); } } } @@ -764,7 +764,7 @@ grpc_endpoint* grpc_tcp_create(grpc_fd* em_fd, tcp_read_chunk_size = GPR_CLAMP(tcp_read_chunk_size, tcp_min_read_chunk_size, tcp_max_read_chunk_size); - grpc_tcp* tcp = (grpc_tcp*)gpr_malloc(sizeof(grpc_tcp)); + grpc_tcp* tcp = static_cast<grpc_tcp*>(gpr_malloc(sizeof(grpc_tcp))); tcp->base.vtable = &vtable; tcp->peer_string = gpr_strdup(peer_string); tcp->fd = grpc_fd_wrapped_fd(em_fd); @@ -773,7 +773,7 @@ grpc_endpoint* grpc_tcp_create(grpc_fd* em_fd, tcp->release_fd_cb = nullptr; tcp->release_fd = nullptr; tcp->incoming_buffer = nullptr; - tcp->target_length = (double)tcp_read_chunk_size; + tcp->target_length = static_cast<double>(tcp_read_chunk_size); tcp->min_read_chunk_size = tcp_min_read_chunk_size; tcp->max_read_chunk_size = tcp_max_read_chunk_size; tcp->bytes_read_this_round = 0; @@ -794,7 +794,7 @@ grpc_endpoint* grpc_tcp_create(grpc_fd* em_fd, } int grpc_tcp_fd(grpc_endpoint* ep) { - grpc_tcp* tcp = (grpc_tcp*)ep; + grpc_tcp* tcp = reinterpret_cast<grpc_tcp*>(ep); GPR_ASSERT(ep->vtable == &vtable); return grpc_fd_wrapped_fd(tcp->em_fd); } @@ -802,7 +802,7 @@ int grpc_tcp_fd(grpc_endpoint* ep) { void grpc_tcp_destroy_and_release_fd(grpc_endpoint* ep, int* fd, grpc_closure* done) { grpc_network_status_unregister_endpoint(ep); - grpc_tcp* tcp = (grpc_tcp*)ep; + grpc_tcp* tcp = reinterpret_cast<grpc_tcp*>(ep); GPR_ASSERT(ep->vtable == &vtable); tcp->release_fd = fd; tcp->release_fd_cb = done; |