Update by review

reviewable/pr24841/r2
Esun Kim 4 years ago
parent e0d8c498a6
commit 7d7c3cc711
  1. 11
      src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc
  2. 3
      src/core/lib/iomgr/ev_epollex_linux.cc
  3. 5
      src/core/lib/iomgr/lockfree_event.cc
  4. 2
      src/core/lib/iomgr/python_util.h
  5. 6
      src/core/lib/iomgr/sockaddr_utils.cc
  6. 2
      src/core/lib/iomgr/sockaddr_utils.h
  7. 4
      src/core/lib/iomgr/tcp_custom.cc
  8. 3
      src/core/lib/iomgr/udp_server.cc
  9. 3
      src/core/lib/iomgr/udp_server.h
  10. 9
      src/core/lib/iomgr/unix_sockets_posix.cc
  11. 4
      src/core/lib/security/security_connector/tls/tls_security_connector.cc
  12. 16
      src/core/lib/surface/call.cc
  13. 6
      src/core/lib/surface/completion_queue.cc
  14. 6
      src/core/tsi/alts/frame_protector/frame_handler.cc
  15. 6
      src/core/tsi/alts/zero_copy_frame_protector/alts_iovec_record_protocol.cc
  16. 6
      src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc
  17. 2
      test/core/end2end/cq_verifier.cc
  18. 3
      test/core/end2end/tests/cancel_with_status.cc
  19. 8
      test/core/iomgr/parse_address_with_named_scope_id_test.cc
  20. 8
      test/core/iomgr/resolve_address_posix_test.cc
  21. 3
      test/core/util/passthru_endpoint.cc
  22. 3
      test/cpp/interop/interop_server.cc
  23. 2
      tools/codegen/core/gen_static_metadata.py

@ -533,17 +533,18 @@ bool IsServerValid(const GrpcLbServer& server, size_t idx, bool log) {
if (GPR_UNLIKELY(server.port >> 16 != 0)) {
if (log) {
gpr_log(GPR_ERROR,
"Invalid port '%d' at index %lu of serverlist. Ignoring.",
server.port, static_cast<unsigned long>(idx));
"Invalid port '%d' at index %" PRIuPTR
" of serverlist. Ignoring.",
server.port, idx);
}
return false;
}
if (GPR_UNLIKELY(server.ip_size != 4 && server.ip_size != 16)) {
if (log) {
gpr_log(GPR_ERROR,
"Expected IP to be 4 or 16 bytes, got %d at index %lu of "
"serverlist. Ignoring",
server.ip_size, static_cast<unsigned long>(idx));
"Expected IP to be 4 or 16 bytes, got %d at index %" PRIuPTR
" of serverlist. Ignoring",
server.ip_size, idx);
}
return false;
}

@ -732,8 +732,7 @@ static grpc_error* pollset_kick(grpc_pollset* pollset,
if (GRPC_TRACE_FLAG_ENABLED(grpc_polling_trace)) {
gpr_log(GPR_INFO,
"PS:%p kick %p tls_pollset=%p tls_worker=%p pollset.root_worker=%p",
static_cast<void*>(pollset), specific_worker,
gpr_tls_get(&g_current_thread_pollset),
pollset, specific_worker, gpr_tls_get(&g_current_thread_pollset),
gpr_tls_get(&g_current_thread_worker), pollset->root_worker);
}
if (specific_worker == nullptr) {

@ -97,7 +97,7 @@ void LockfreeEvent::NotifyOn(grpc_closure* closure) {
gpr_atm curr = gpr_atm_acq_load(&state_);
if (GRPC_TRACE_FLAG_ENABLED(grpc_polling_trace)) {
gpr_log(GPR_DEBUG, "LockfreeEvent::NotifyOn: %p curr=%p closure=%p", this,
reinterpret_cast<void*>(curr), closure);
curr, closure);
}
switch (curr) {
case kClosureNotReady: {
@ -165,8 +165,7 @@ bool LockfreeEvent::SetShutdown(grpc_error* shutdown_error) {
gpr_atm curr = gpr_atm_no_barrier_load(&state_);
if (GRPC_TRACE_FLAG_ENABLED(grpc_polling_trace)) {
gpr_log(GPR_DEBUG, "LockfreeEvent::SetShutdown: %p curr=%p err=%s",
&state_, reinterpret_cast<void*>(curr),
grpc_error_string(shutdown_error));
&state_, curr, grpc_error_string(shutdown_error));
}
switch (curr) {
case kClosureReady:

@ -36,7 +36,7 @@ inline grpc_error* grpc_socket_error(char* error) {
}
inline char* grpc_slice_buffer_start(grpc_slice_buffer* buffer, int i) {
return reinterpret_cast<char*> GRPC_SLICE_START_PTR(buffer->slices[i]);
return reinterpret_cast<char*>(GRPC_SLICE_START_PTR(buffer->slices[i]));
}
inline int grpc_slice_buffer_length(grpc_slice_buffer* buffer, int i) {

@ -275,10 +275,8 @@ int grpc_sockaddr_get_port(const grpc_resolved_address* resolved_addr) {
}
}
int grpc_sockaddr_set_port(const grpc_resolved_address* resolved_addr,
int port) {
grpc_sockaddr* addr = const_cast<grpc_sockaddr*>(
reinterpret_cast<const grpc_sockaddr*>(resolved_addr->addr));
int grpc_sockaddr_set_port(grpc_resolved_address* resolved_addr, int port) {
grpc_sockaddr* addr = reinterpret_cast<grpc_sockaddr*>(resolved_addr->addr);
switch (addr->sa_family) {
case GRPC_AF_INET:
GPR_ASSERT(port >= 0 && port < 65536);

@ -56,7 +56,7 @@ void grpc_sockaddr_make_wildcard6(int port, grpc_resolved_address* wild_out);
int grpc_sockaddr_get_port(const grpc_resolved_address* addr);
/* Set IP port number of a sockaddr */
int grpc_sockaddr_set_port(const grpc_resolved_address* addr, int port);
int grpc_sockaddr_set_port(grpc_resolved_address* addr, int port);
// Converts a sockaddr into a newly-allocated human-readable string.
//

@ -181,8 +181,8 @@ static void tcp_read_allocation_done(void* tcpp, grpc_error* error) {
/* Before calling read, we allocate a buffer with exactly one slice
* to tcp->read_slices and wait for the callback indicating that the
* allocation was successful. So slices[0] should always exist here */
char* buffer = reinterpret_cast<char*> GRPC_SLICE_START_PTR(
tcp->read_slices->slices[0]);
char* buffer = reinterpret_cast<char*>(
GRPC_SLICE_START_PTR(tcp->read_slices->slices[0]));
size_t len = GRPC_SLICE_LENGTH(tcp->read_slices->slices[0]);
grpc_custom_socket_vtable->read(tcp->socket, buffer, len,
custom_read_callback);

@ -570,8 +570,7 @@ static int add_socket_to_server(grpc_udp_server* s, int fd,
return port;
}
int grpc_udp_server_add_port(grpc_udp_server* s,
const grpc_resolved_address* addr,
int grpc_udp_server_add_port(grpc_udp_server* s, grpc_resolved_address* addr,
int rcv_buf_size, int snd_buf_size,
GrpcUdpHandlerFactory* handler_factory,
size_t num_listeners) {

@ -93,8 +93,7 @@ int grpc_udp_server_get_fd(grpc_udp_server* s, unsigned port_index);
/* TODO(ctiller): deprecate this, and make grpc_udp_server_add_ports to handle
all of the multiple socket port matching logic in one place */
int grpc_udp_server_add_port(grpc_udp_server* s,
const grpc_resolved_address* addr,
int grpc_udp_server_add_port(grpc_udp_server* s, grpc_resolved_address* addr,
int rcv_buf_size, int snd_buf_size,
GrpcUdpHandlerFactory* handler_factory,
size_t num_listeners);

@ -96,10 +96,8 @@ std::string grpc_sockaddr_to_uri_unix_if_possible(
if (addr->sa_family != AF_UNIX) {
return "";
}
if ((reinterpret_cast<const struct sockaddr_un*>(addr))->sun_path[0] ==
'\0' &&
(reinterpret_cast<const struct sockaddr_un*>(addr))->sun_path[1] !=
'\0') {
const auto* unix_addr = reinterpret_cast<const struct sockaddr_un*>(addr);
if (unix_addr->sun_path[0] == '\0' && unix_addr->sun_path[1] != '\0') {
const struct sockaddr_un* un =
reinterpret_cast<const struct sockaddr_un*>(resolved_addr->addr);
return absl::StrCat(
@ -107,8 +105,7 @@ std::string grpc_sockaddr_to_uri_unix_if_possible(
absl::string_view(un->sun_path + 1,
resolved_addr->len - sizeof(un->sun_family) - 1));
}
return absl::StrCat(
"unix:", (reinterpret_cast<const struct sockaddr_un*>(addr))->sun_path);
return absl::StrCat("unix:", unix_addr->sun_path);
}
#endif

@ -421,9 +421,7 @@ void TlsChannelSecurityConnector::ServerAuthorizationCheckArgDestroy(
}
gpr_free(const_cast<char*>(arg->target_name));
gpr_free(const_cast<char*>(arg->peer_cert));
if (arg->peer_cert_full_chain) {
gpr_free(const_cast<char*>(arg->peer_cert_full_chain));
}
gpr_free(const_cast<char*>(arg->peer_cert_full_chain));
delete arg->error_details;
if (arg->destroy_context != nullptr) {
arg->destroy_context(arg->context);

@ -834,7 +834,7 @@ static void set_encodings_accepted_by_peer(grpc_call* /*call*/,
grpc_mdelem_get_user_data(mdel, destroy_encodings_accepted_by_peer);
if (accepted_user_data != nullptr) {
*encodings_accepted_by_peer = static_cast<uint32_t>(
(reinterpret_cast<uintptr_t>(accepted_user_data)) - 1);
reinterpret_cast<uintptr_t>(accepted_user_data) - 1);
return;
}
@ -875,7 +875,7 @@ static void set_encodings_accepted_by_peer(grpc_call* /*call*/,
grpc_mdelem_set_user_data(
mdel, destroy_encodings_accepted_by_peer,
reinterpret_cast<void*>(
(static_cast<uintptr_t>(*encodings_accepted_by_peer)) + 1));
static_cast<uintptr_t>(*encodings_accepted_by_peer) + 1));
}
uint32_t grpc_call_test_only_get_encodings_accepted_by_peer(grpc_call* call) {
@ -889,9 +889,8 @@ grpc_call_test_only_get_incoming_stream_encodings(grpc_call* call) {
return call->incoming_stream_compression_algorithm;
}
static grpc_linked_mdelem* linked_from_md(const grpc_metadata* md) {
return reinterpret_cast<grpc_linked_mdelem*>(
&const_cast<grpc_metadata*>(md)->internal_data);
static const grpc_linked_mdelem* linked_from_md(const grpc_metadata* md) {
return reinterpret_cast<const grpc_linked_mdelem*>(&md->internal_data);
}
static grpc_metadata* get_md_elem(grpc_metadata* metadata,
@ -916,7 +915,7 @@ static int prepare_application_metadata(grpc_call* call, int count,
for (i = 0; i < total_count; i++) {
const grpc_metadata* md =
get_md_elem(metadata, additional_metadata, i, count);
grpc_linked_mdelem* l = linked_from_md(md);
grpc_linked_mdelem* l = const_cast<grpc_linked_mdelem*>(linked_from_md(md));
GPR_ASSERT(sizeof(grpc_linked_mdelem) == sizeof(md->internal_data));
if (!GRPC_LOG_IF_ERROR("validate_metadata",
grpc_validate_header_key_is_legal(md->key))) {
@ -936,7 +935,8 @@ static int prepare_application_metadata(grpc_call* call, int count,
for (int j = 0; j < i; j++) {
const grpc_metadata* md =
get_md_elem(metadata, additional_metadata, j, count);
grpc_linked_mdelem* l = linked_from_md(md);
grpc_linked_mdelem* l =
const_cast<grpc_linked_mdelem*>(linked_from_md(md));
GRPC_MDELEM_UNREF(l->md);
}
return 0;
@ -954,7 +954,7 @@ static int prepare_application_metadata(grpc_call* call, int count,
}
for (i = 0; i < total_count; i++) {
grpc_metadata* md = get_md_elem(metadata, additional_metadata, i, count);
grpc_linked_mdelem* l = linked_from_md(md);
grpc_linked_mdelem* l = const_cast<grpc_linked_mdelem*>(linked_from_md(md));
grpc_error* error = grpc_metadata_batch_link_tail(batch, l);
if (error != GRPC_ERROR_NONE) {
GRPC_MDELEM_UNREF(l->md);

@ -796,8 +796,8 @@ static void cq_end_op_for_pluck(
storage->tag = tag;
storage->done = done;
storage->done_arg = done_arg;
storage->next = (reinterpret_cast<uintptr_t>(&cqd->completed_head)) |
(static_cast<uintptr_t>(is_success));
storage->next = reinterpret_cast<uintptr_t>(&cqd->completed_head) |
static_cast<uintptr_t>(is_success);
gpr_mu_lock(cq->mu);
cq_check_tag(cq, tag, false); /* Used in debug builds only */
@ -805,7 +805,7 @@ static void cq_end_op_for_pluck(
/* Add to the list of completions */
cqd->things_queued_ever.FetchAdd(1, grpc_core::MemoryOrder::RELAXED);
cqd->completed_tail->next =
(reinterpret_cast<uintptr_t>(storage)) | (1u & cqd->completed_tail->next);
reinterpret_cast<uintptr_t>(storage) | (1u & cqd->completed_tail->next);
cqd->completed_tail = storage;
if (cqd->pending_events.FetchSub(1, grpc_core::MemoryOrder::ACQ_REL) == 1) {

@ -31,9 +31,9 @@
/* Use little endian to interpret a string of bytes as uint32_t. */
static uint32_t load_32_le(const unsigned char* buffer) {
return ((static_cast<uint32_t>(buffer[3])) << 24) |
((static_cast<uint32_t>(buffer[2])) << 16) |
((static_cast<uint32_t>(buffer[1])) << 8) |
return (static_cast<uint32_t>(buffer[3]) << 24) |
(static_cast<uint32_t>(buffer[2]) << 16) |
(static_cast<uint32_t>(buffer[1]) << 8) |
(static_cast<uint32_t>(buffer[0]));
}

@ -56,9 +56,9 @@ static void maybe_append_error_msg(const char* appendix, char** dst) {
/* Use little endian to interpret a string of bytes as uint32_t. */
static uint32_t load_32_le(const unsigned char* buffer) {
return ((static_cast<uint32_t>(buffer[3])) << 24) |
((static_cast<uint32_t>(buffer[2])) << 16) |
((static_cast<uint32_t>(buffer[1])) << 8) |
return (static_cast<uint32_t>(buffer[3]) << 24) |
(static_cast<uint32_t>(buffer[2]) << 16) |
(static_cast<uint32_t>(buffer[1]) << 8) |
(static_cast<uint32_t>(buffer[0]));
}

@ -87,9 +87,9 @@ static bool read_frame_size(const grpc_slice_buffer* sb,
}
GPR_ASSERT(remaining == 0);
/* Gets little-endian frame size. */
uint32_t frame_size = ((static_cast<uint32_t>(frame_size_buffer[3])) << 24) |
((static_cast<uint32_t>(frame_size_buffer[2])) << 16) |
((static_cast<uint32_t>(frame_size_buffer[1])) << 8) |
uint32_t frame_size = (static_cast<uint32_t>(frame_size_buffer[3]) << 24) |
(static_cast<uint32_t>(frame_size_buffer[2]) << 16) |
(static_cast<uint32_t>(frame_size_buffer[1]) << 8) |
(static_cast<uint32_t>(frame_size_buffer[0]));
if (frame_size > kMaxFrameLength) {
gpr_log(GPR_ERROR, "Frame size is larger than maximum frame size");

@ -187,7 +187,7 @@ int byte_buffer_eq_string(grpc_byte_buffer* bb, const char* str) {
}
static bool is_probably_integer(void* p) {
return (reinterpret_cast<uintptr_t>(p)) < 1000000;
return reinterpret_cast<uintptr_t>(p) < 1000000;
}
namespace {

@ -140,8 +140,7 @@ static void simple_request_body(grpc_end2end_test_config /*config*/,
GPR_ASSERT(GRPC_CALL_OK == error);
char* dynamic_string = gpr_strdup("xyz");
grpc_call_cancel_with_status(c, GRPC_STATUS_UNIMPLEMENTED,
reinterpret_cast<const char*>(dynamic_string),
grpc_call_cancel_with_status(c, GRPC_STATUS_UNIMPLEMENTED, dynamic_string,
nullptr);
// The API of \a description allows for it to be a dynamic/non-const
// string, test this guarantee.

@ -101,10 +101,10 @@ int main(int argc, char** argv) {
// system recognizes, and then use that for the test.
for (size_t i = 1; i < 65536; i++) {
if (if_indextoname(i, arbitrary_interface_name) != nullptr) {
gpr_log(
GPR_DEBUG,
"Found interface at index %d named %s. Will use this for the test",
static_cast<int>(i), arbitrary_interface_name);
gpr_log(GPR_DEBUG,
"Found interface at index %" PRIuPTR
" named %s. Will use this for the test",
i, arbitrary_interface_name);
break;
}
}

@ -158,10 +158,10 @@ static void test_named_and_numeric_scope_ids(void) {
// system recognizes, and then use that for the test.
for (size_t i = 1; i < 65536; i++) {
if (if_indextoname(i, arbitrary_interface_name) != nullptr) {
gpr_log(
GPR_DEBUG,
"Found interface at index %d named %s. Will use this for the test",
static_cast<int>(i), arbitrary_interface_name);
gpr_log(GPR_DEBUG,
"Found interface at index %" PRIuPTR
" named %s. Will use this for the test",
i, arbitrary_interface_name);
interface_index = static_cast<int>(i);
break;
}

@ -198,8 +198,7 @@ static void half_init(half* m, passthru_endpoint* parent,
grpc_slice_buffer_init(&m->read_buffer);
m->on_read = nullptr;
std::string name =
absl::StrFormat("passthru_endpoint_%s_%" PRIxPTR, half_name,
reinterpret_cast<intptr_t>(parent));
absl::StrFormat("passthru_endpoint_%s_%p", half_name, parent);
m->resource_user = grpc_resource_user_create(resource_quota, name.c_str());
}

@ -149,8 +149,7 @@ class TestServiceImpl : public TestService::Service {
const SimpleRequest* /*request*/,
SimpleResponse* response) override {
gpr_timespec ts = gpr_now(GPR_CLOCK_PRECISE);
std::string timestamp =
std::to_string(static_cast<long long unsigned>(ts.tv_nsec));
std::string timestamp = std::to_string(ts.tv_nsec);
response->mutable_payload()->set_body(timestamp.c_str(), timestamp.size());
context->AddInitialMetadata("cache-control", "max-age=60, public");
return Status::OK;

@ -637,7 +637,7 @@ static uint32_t %(name)s_phash(uint32_t i) {
uint32_t y = i / %(t)d;
uint32_t h = x;
if (y < GPR_ARRAY_SIZE(%(name)s_r)) {
uint32_t delta = (uint32_t)%(name)s_r[y];
uint32_t delta = static_cast<uint32_t>(%(name)s_r[y]);
h += delta;
}
return h;

Loading…
Cancel
Save