Revert "[ObjC]fix 64 to 32 bit clang conversion warning in src/core/lib (#29877)" (#31843)

This reverts commit eb0a591811.
pull/31846/head
Eryu Xia 2 years ago committed by GitHub
parent eb0a591811
commit a8ac4e7265
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      include/grpcpp/test/channel_test_peer.h
  2. 6
      src/core/ext/filters/client_channel/lb_policy/priority/priority.cc
  3. 2
      src/core/ext/transport/chttp2/transport/chttp2_transport.cc
  4. 2
      src/core/ext/transport/chttp2/transport/flow_control.cc
  5. 2
      src/core/ext/transport/chttp2/transport/flow_control.h
  6. 3
      src/core/ext/transport/chttp2/transport/hpack_parser.cc
  7. 3
      src/core/ext/transport/chttp2/transport/hpack_parser_table.cc
  8. 6
      src/core/lib/compression/compression_internal.cc
  9. 2
      src/core/lib/event_engine/posix_engine/timer.cc
  10. 4
      src/core/lib/event_engine/posix_engine/timer_heap.cc
  11. 2
      src/core/lib/gpr/time_precise.cc
  12. 2
      src/core/lib/gprpp/bitset.h
  13. 2
      src/core/lib/gprpp/status_helper.cc
  14. 6
      src/core/lib/iomgr/tcp_client_posix.cc
  15. 17
      src/core/lib/iomgr/tcp_posix.cc
  16. 2
      src/core/lib/security/security_connector/load_system_roots_supported.cc
  17. 2
      src/core/lib/slice/slice.h
  18. 2
      src/core/lib/slice/slice_internal.h
  19. 2
      src/core/lib/surface/call.cc
  20. 2
      src/core/lib/surface/channel.h
  21. 4
      src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc
  22. 3
      src/core/tsi/fake_transport_security.cc
  23. 4
      src/cpp/client/channel_test_peer.cc
  24. 2
      test/cpp/end2end/end2end_test.cc

@ -31,7 +31,7 @@ class ChannelTestPeer {
/// Provide the gRPC Core channel /// Provide the gRPC Core channel
grpc_channel* channel() const { return channel_->c_channel_; } grpc_channel* channel() const { return channel_->c_channel_; }
size_t registered_calls() const; int registered_calls() const;
int registration_attempts() const; int registration_attempts() const;
private: private:

@ -471,9 +471,9 @@ void PriorityLb::ChoosePriorityLocked() {
} }
} }
// Did not find any child in CONNECTING, delegate to last child. // Did not find any child in CONNECTING, delegate to last child.
SetCurrentPriorityLocked( SetCurrentPriorityLocked(config_->priorities().size() - 1,
static_cast<int32_t>(config_->priorities().size() - 1), /*deactivate_lower_priorities=*/false,
/*deactivate_lower_priorities=*/false, "no usable children"); "no usable children");
} }
void PriorityLb::SetCurrentPriorityLocked(int32_t priority, void PriorityLb::SetCurrentPriorityLocked(int32_t priority,

@ -1304,7 +1304,7 @@ static void perform_stream_op_locked(void* stream_op,
if (op->send_message) { if (op->send_message) {
t->num_messages_in_next_write++; t->num_messages_in_next_write++;
grpc_core::global_stats().IncrementHttp2SendMessageSize( grpc_core::global_stats().IncrementHttp2SendMessageSize(
static_cast<int>(op->payload->send_message.send_message->Length())); op->payload->send_message.send_message->Length());
on_complete->next_data.scratch |= CLOSURE_BARRIER_MAY_COVER_WRITE; on_complete->next_data.scratch |= CLOSURE_BARRIER_MAY_COVER_WRITE;
s->send_message_finished = add_closure_barrier(op->on_complete); s->send_message_finished = add_closure_barrier(op->on_complete);
const uint32_t flags = op_payload->send_message.flags; const uint32_t flags = op_payload->send_message.flags;

@ -294,7 +294,7 @@ void TransportFlowControl::UpdateSetting(
urgency = FlowControlAction::Urgency::UPDATE_IMMEDIATELY; urgency = FlowControlAction::Urgency::UPDATE_IMMEDIATELY;
} }
*desired_value = new_desired_value; *desired_value = new_desired_value;
(action->*set)(urgency, static_cast<uint32_t>(*desired_value)); (action->*set)(urgency, *desired_value);
} }
} else { } else {
int64_t delta = new_desired_value - *desired_value; int64_t delta = new_desired_value - *desired_value;

@ -259,7 +259,7 @@ class TransportFlowControl final {
BdpEstimator* bdp_estimator() { return &bdp_estimator_; } BdpEstimator* bdp_estimator() { return &bdp_estimator_; }
uint32_t acked_init_window() const { return acked_init_window_; } uint32_t acked_init_window() const { return acked_init_window_; }
int64_t sent_init_window() const { return target_initial_window_size_; } uint32_t sent_init_window() const { return target_initial_window_size_; }
FlowControlAction SetAckedInitialWindow(uint32_t value); FlowControlAction SetAckedInitialWindow(uint32_t value);

@ -1104,8 +1104,7 @@ class HPackParser::Parser {
const auto transport_size = key_string.size() + value_slice.size() + const auto transport_size = key_string.size() + value_slice.size() +
hpack_constants::kEntryOverhead; hpack_constants::kEntryOverhead;
return grpc_metadata_batch::Parse( return grpc_metadata_batch::Parse(
key->string_view(), std::move(value_slice), key->string_view(), std::move(value_slice), transport_size,
static_cast<uint32_t>(transport_size),
[key_string](absl::string_view error, const Slice& value) { [key_string](absl::string_view error, const Slice& value) {
ReportMetadataParseError(key_string, error, value.as_string_view()); ReportMetadataParseError(key_string, error, value.as_string_view());
}); });

@ -229,8 +229,7 @@ HPackTable::Memento MakeMemento(size_t i) {
auto sm = kStaticTable[i]; auto sm = kStaticTable[i];
return grpc_metadata_batch::Parse( return grpc_metadata_batch::Parse(
sm.key, Slice::FromStaticString(sm.value), sm.key, Slice::FromStaticString(sm.value),
static_cast<uint32_t>(strlen(sm.key) + strlen(sm.value) + strlen(sm.key) + strlen(sm.value) + hpack_constants::kEntryOverhead,
hpack_constants::kEntryOverhead),
[](absl::string_view, const Slice&) { [](absl::string_view, const Slice&) {
abort(); // not expecting to see this abort(); // not expecting to see this
}); });

@ -156,7 +156,7 @@ CompressionAlgorithmSet::CompressionAlgorithmForLevel(
CompressionAlgorithmSet CompressionAlgorithmSet::FromUint32(uint32_t value) { CompressionAlgorithmSet CompressionAlgorithmSet::FromUint32(uint32_t value) {
CompressionAlgorithmSet set; CompressionAlgorithmSet set;
for (int i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) { for (size_t i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) {
if (value & (1u << i)) { if (value & (1u << i)) {
set.set_.set(i); set.set_.set(i);
} }
@ -185,7 +185,7 @@ CompressionAlgorithmSet::CompressionAlgorithmSet(
bool CompressionAlgorithmSet::IsSet( bool CompressionAlgorithmSet::IsSet(
grpc_compression_algorithm algorithm) const { grpc_compression_algorithm algorithm) const {
int i = algorithm; size_t i = static_cast<size_t>(algorithm);
if (i < GRPC_COMPRESS_ALGORITHMS_COUNT) { if (i < GRPC_COMPRESS_ALGORITHMS_COUNT) {
return set_.is_set(i); return set_.is_set(i);
} else { } else {
@ -194,7 +194,7 @@ bool CompressionAlgorithmSet::IsSet(
} }
void CompressionAlgorithmSet::Set(grpc_compression_algorithm algorithm) { void CompressionAlgorithmSet::Set(grpc_compression_algorithm algorithm) {
int i = algorithm; size_t i = static_cast<size_t>(algorithm);
if (i < GRPC_COMPRESS_ALGORITHMS_COUNT) { if (i < GRPC_COMPRESS_ALGORITHMS_COUNT) {
set_.set(i); set_.set(i);
} }

@ -59,7 +59,7 @@ TimerList::TimerList(TimerListHost* host)
shard.queue_deadline_cap = shard.queue_deadline_cap =
grpc_core::Timestamp::FromMillisecondsAfterProcessEpoch( grpc_core::Timestamp::FromMillisecondsAfterProcessEpoch(
min_timer_.load(std::memory_order_relaxed)); min_timer_.load(std::memory_order_relaxed));
shard.shard_queue_index = static_cast<uint32_t>(i); shard.shard_queue_index = i;
shard.list.next = shard.list.prev = &shard.list; shard.list.next = shard.list.prev = &shard.list;
shard.min_deadline = shard.ComputeMinDeadline(); shard.min_deadline = shard.ComputeMinDeadline();
shard_queue_[i] = &shard; shard_queue_[i] = &shard;

@ -69,7 +69,7 @@ void TimerHeap::AdjustDownwards(size_t i, Timer* t) {
} }
void TimerHeap::NoteChangedPriority(Timer* timer) { void TimerHeap::NoteChangedPriority(Timer* timer) {
uint32_t i = static_cast<uint32_t>(timer->heap_index); uint32_t i = timer->heap_index;
uint32_t parent = static_cast<uint32_t>((static_cast<int>(i) - 1) / 2); uint32_t parent = static_cast<uint32_t>((static_cast<int>(i) - 1) / 2);
if (timers_[parent]->deadline > timer->deadline) { if (timers_[parent]->deadline > timer->deadline) {
AdjustUpwards(i, timer); AdjustUpwards(i, timer);
@ -86,7 +86,7 @@ bool TimerHeap::Add(Timer* timer) {
} }
void TimerHeap::Remove(Timer* timer) { void TimerHeap::Remove(Timer* timer) {
size_t i = timer->heap_index; uint32_t i = timer->heap_index;
if (i == timers_.size() - 1) { if (i == timers_.size() - 1) {
timers_.pop_back(); timers_.pop_back();
return; return;

@ -149,7 +149,7 @@ gpr_cycle_counter gpr_get_cycle_counter() {
gpr_timespec gpr_cycle_counter_to_time(gpr_cycle_counter cycles) { gpr_timespec gpr_cycle_counter_to_time(gpr_cycle_counter cycles) {
gpr_timespec ts; gpr_timespec ts;
ts.tv_sec = static_cast<int64_t>(cycles / GPR_US_PER_SEC); ts.tv_sec = static_cast<int64_t>(cycles / GPR_US_PER_SEC);
ts.tv_nsec = static_cast<int32_t>((cycles - ts.tv_sec * GPR_US_PER_SEC) * ts.tv_nsec = static_cast<int64_t>((cycles - ts.tv_sec * GPR_US_PER_SEC) *
GPR_NS_PER_US); GPR_NS_PER_US);
ts.clock_type = GPR_CLOCK_PRECISE; ts.clock_type = GPR_CLOCK_PRECISE;
return ts; return ts;

@ -157,7 +157,7 @@ class BitSet {
ToInt() const { ToInt() const {
Int result = 0; Int result = 0;
for (size_t i = 0; i < kTotalBits; i++) { for (size_t i = 0; i < kTotalBits; i++) {
if (is_set(static_cast<int>(i))) result |= (Int(1) << i); if (is_set(i)) result |= (Int(1) << i);
} }
return result; return result;
} }

@ -269,7 +269,7 @@ void StatusAddChild(absl::Status* status, absl::Status child) {
children = *old_children; children = *old_children;
} }
char head_buf[sizeof(uint32_t)]; char head_buf[sizeof(uint32_t)];
EncodeUInt32ToBytes(static_cast<uint32_t>(buf_len), head_buf); EncodeUInt32ToBytes(buf_len, head_buf);
children.Append(absl::string_view(head_buf, sizeof(uint32_t))); children.Append(absl::string_view(head_buf, sizeof(uint32_t)));
children.Append(absl::string_view(buf, buf_len)); children.Append(absl::string_view(buf, buf_len));
status->SetPayload(kChildrenPropertyUrl, std::move(children)); status->SetPayload(kChildrenPropertyUrl, std::move(children));

@ -244,7 +244,7 @@ static void on_writable(void* acp, grpc_error_handle error) {
finish: finish:
if (!connect_cancelled) { if (!connect_cancelled) {
size_t shard_number = ac->connection_handle % (*g_connection_shards).size(); int shard_number = ac->connection_handle % (*g_connection_shards).size();
struct ConnectionShard* shard = &(*g_connection_shards)[shard_number]; struct ConnectionShard* shard = &(*g_connection_shards)[shard_number];
{ {
grpc_core::MutexLock lock(&shard->mu); grpc_core::MutexLock lock(&shard->mu);
@ -379,7 +379,7 @@ int64_t grpc_tcp_client_create_from_prepared_fd(
ac->addr_str.c_str(), fdobj); ac->addr_str.c_str(), fdobj);
} }
size_t shard_number = connection_id % (*g_connection_shards).size(); int shard_number = connection_id % (*g_connection_shards).size();
struct ConnectionShard* shard = &(*g_connection_shards)[shard_number]; struct ConnectionShard* shard = &(*g_connection_shards)[shard_number];
{ {
grpc_core::MutexLock lock(&shard->mu); grpc_core::MutexLock lock(&shard->mu);
@ -417,7 +417,7 @@ static bool tcp_cancel_connect(int64_t connection_handle) {
if (connection_handle <= 0) { if (connection_handle <= 0) {
return false; return false;
} }
size_t shard_number = connection_handle % (*g_connection_shards).size(); int shard_number = connection_handle % (*g_connection_shards).size();
struct ConnectionShard* shard = &(*g_connection_shards)[shard_number]; struct ConnectionShard* shard = &(*g_connection_shards)[shard_number];
async_connect* ac = nullptr; async_connect* ac = nullptr;
{ {

@ -914,9 +914,9 @@ static bool tcp_do_read(grpc_tcp* tcp, grpc_error_handle* error)
msg.msg_flags = 0; msg.msg_flags = 0;
grpc_core::global_stats().IncrementTcpReadOffer( grpc_core::global_stats().IncrementTcpReadOffer(
static_cast<int>(tcp->incoming_buffer->length)); tcp->incoming_buffer->length);
grpc_core::global_stats().IncrementTcpReadOfferIovSize( grpc_core::global_stats().IncrementTcpReadOfferIovSize(
static_cast<int>(tcp->incoming_buffer->count)); tcp->incoming_buffer->count);
do { do {
grpc_core::global_stats().IncrementSyscallRead(); grpc_core::global_stats().IncrementSyscallRead();
@ -955,8 +955,7 @@ static bool tcp_do_read(grpc_tcp* tcp, grpc_error_handle* error)
return true; return true;
} }
grpc_core::global_stats().IncrementTcpReadSize( grpc_core::global_stats().IncrementTcpReadSize(read_bytes);
static_cast<int>(read_bytes));
add_to_estimate(tcp, static_cast<size_t>(read_bytes)); add_to_estimate(tcp, static_cast<size_t>(read_bytes));
GPR_DEBUG_ASSERT((size_t)read_bytes <= GPR_DEBUG_ASSERT((size_t)read_bytes <=
tcp->incoming_buffer->length - total_read_bytes); tcp->incoming_buffer->length - total_read_bytes);
@ -1058,8 +1057,8 @@ static void maybe_make_read_slices(grpc_tcp* tcp)
if (low_memory_pressure && target_length > allocate_length) { if (low_memory_pressure && target_length > allocate_length) {
allocate_length = target_length; allocate_length = target_length;
} }
int extra_wanted = static_cast<int>(allocate_length) - int extra_wanted =
static_cast<int>(tcp->incoming_buffer->length); allocate_length - static_cast<int>(tcp->incoming_buffer->length);
if (extra_wanted >= if (extra_wanted >=
(low_memory_pressure ? kSmallAlloc * 3 / 2 : kBigAlloc)) { (low_memory_pressure ? kSmallAlloc * 3 / 2 : kBigAlloc)) {
while (extra_wanted > 0) { while (extra_wanted > 0) {
@ -1603,8 +1602,7 @@ static bool do_tcp_flush_zerocopy(grpc_tcp* tcp, TcpZerocopySendRecord* record,
if (!tried_sending_message) { if (!tried_sending_message) {
msg.msg_control = nullptr; msg.msg_control = nullptr;
msg.msg_controllen = 0; msg.msg_controllen = 0;
grpc_core::global_stats().IncrementTcpWriteSize( grpc_core::global_stats().IncrementTcpWriteSize(sending_length);
static_cast<int>(sending_length));
grpc_core::global_stats().IncrementTcpWriteIovSize(iov_size); grpc_core::global_stats().IncrementTcpWriteIovSize(iov_size);
sent_length = tcp_send(tcp->fd, &msg, &saved_errno, MSG_ZEROCOPY); sent_length = tcp_send(tcp->fd, &msg, &saved_errno, MSG_ZEROCOPY);
} }
@ -1717,8 +1715,7 @@ static bool tcp_flush(grpc_tcp* tcp, grpc_error_handle* error) {
msg.msg_control = nullptr; msg.msg_control = nullptr;
msg.msg_controllen = 0; msg.msg_controllen = 0;
grpc_core::global_stats().IncrementTcpWriteSize( grpc_core::global_stats().IncrementTcpWriteSize(sending_length);
static_cast<int>(sending_length));
grpc_core::global_stats().IncrementTcpWriteIovSize(iov_size); grpc_core::global_stats().IncrementTcpWriteIovSize(iov_size);
sent_length = tcp_send(tcp->fd, &msg, &saved_errno); sent_length = tcp_send(tcp->fd, &msg, &saved_errno);

@ -134,7 +134,7 @@ grpc_slice CreateRootCertsBundle(const char* certs_directory) {
if (file_descriptor != -1) { if (file_descriptor != -1) {
// Read file into bundle. // Read file into bundle.
size_t cert_file_size = roots_filenames[i].size; size_t cert_file_size = roots_filenames[i].size;
ssize_t read_ret = int read_ret =
read(file_descriptor, bundle_string + bytes_read, cert_file_size); read(file_descriptor, bundle_string + bytes_read, cert_file_size);
if (read_ret != -1) { if (read_ret != -1) {
bytes_read += read_ret; bytes_read += read_ret;

@ -207,7 +207,7 @@ struct CopyConstructors {
static Out FromInt64(int64_t i) { static Out FromInt64(int64_t i) {
char buffer[GPR_LTOA_MIN_BUFSIZE]; char buffer[GPR_LTOA_MIN_BUFSIZE];
int64_ttoa(i, buffer); gpr_ltoa(i, buffer);
return FromCopiedString(buffer); return FromCopiedString(buffer);
} }
}; };

@ -79,7 +79,7 @@ inline absl::string_view StringViewFromSlice(const grpc_slice& slice) {
} // namespace grpc_core } // namespace grpc_core
inline uint32_t grpc_slice_hash(const grpc_slice& s) { inline uint32_t grpc_slice_hash(const grpc_slice& s) {
return static_cast<uint32_t>(absl::HashOf(grpc_core::StringViewFromSlice(s))); return absl::HashOf(grpc_core::StringViewFromSlice(s));
} }
namespace grpc_core { namespace grpc_core {

@ -636,7 +636,7 @@ grpc_error_handle FilterStackCall::Create(grpc_call_create_args* args,
grpc_error_handle error; grpc_error_handle error;
grpc_channel_stack* channel_stack = channel->channel_stack(); grpc_channel_stack* channel_stack = channel->channel_stack();
size_t initial_size = channel->CallSizeEstimate(); size_t initial_size = channel->CallSizeEstimate();
global_stats().IncrementCallInitialSize(static_cast<int>(initial_size)); global_stats().IncrementCallInitialSize(initial_size);
size_t call_alloc_size = size_t call_alloc_size =
GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(FilterStackCall)) + GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(FilterStackCall)) +
channel_stack->call_stack_size; channel_stack->call_stack_size;

@ -145,7 +145,7 @@ class Channel : public RefCounted<Channel>,
bool is_promising() const { return is_promising_; } bool is_promising() const { return is_promising_; }
RegisteredCall* RegisterCall(const char* method, const char* host); RegisteredCall* RegisterCall(const char* method, const char* host);
size_t TestOnlyRegisteredCalls() { int TestOnlyRegisteredCalls() {
MutexLock lock(&registration_table_.mu); MutexLock lock(&registration_table_.mu);
return registration_table_.map.size(); return registration_table_.map.size();
} }

@ -217,8 +217,8 @@ static tsi_result alts_zero_copy_grpc_protector_unprotect(
} }
if (min_progress_size != nullptr) { if (min_progress_size != nullptr) {
if (protector->parsed_frame_size > kZeroCopyFrameLengthFieldSize) { if (protector->parsed_frame_size > kZeroCopyFrameLengthFieldSize) {
*min_progress_size = static_cast<int>(protector->parsed_frame_size - *min_progress_size =
protector->protected_sb.length); protector->parsed_frame_size - protector->protected_sb.length;
} else { } else {
*min_progress_size = 1; *min_progress_size = 1;
} }

@ -485,8 +485,7 @@ static tsi_result fake_zero_copy_grpc_protector_unprotect(
} }
if (min_progress_size != nullptr) { if (min_progress_size != nullptr) {
if (impl->parsed_frame_size > TSI_FAKE_FRAME_HEADER_SIZE) { if (impl->parsed_frame_size > TSI_FAKE_FRAME_HEADER_SIZE) {
*min_progress_size = *min_progress_size = impl->parsed_frame_size - impl->protected_sb.length;
static_cast<int>(impl->parsed_frame_size - impl->protected_sb.length);
} else { } else {
*min_progress_size = 1; *min_progress_size = 1;
} }

@ -16,8 +16,6 @@
* *
*/ */
#include <stddef.h>
#include <grpcpp/channel.h> #include <grpcpp/channel.h>
#include <grpcpp/test/channel_test_peer.h> #include <grpcpp/test/channel_test_peer.h>
@ -26,7 +24,7 @@
namespace grpc { namespace grpc {
namespace testing { namespace testing {
size_t ChannelTestPeer::registered_calls() const { int ChannelTestPeer::registered_calls() const {
return grpc_core::Channel::FromC(channel_->c_channel_) return grpc_core::Channel::FromC(channel_->c_channel_)
->TestOnlyRegisteredCalls(); ->TestOnlyRegisteredCalls();
} }

@ -859,7 +859,7 @@ TEST_P(End2endTest, MultipleRpcs) {
TEST_P(End2endTest, ManyStubs) { TEST_P(End2endTest, ManyStubs) {
ResetStub(); ResetStub();
ChannelTestPeer peer(channel_.get()); ChannelTestPeer peer(channel_.get());
size_t registered_calls_pre = peer.registered_calls(); int registered_calls_pre = peer.registered_calls();
int registration_attempts_pre = peer.registration_attempts(); int registration_attempts_pre = peer.registration_attempts();
for (int i = 0; i < 1000; ++i) { for (int i = 0; i < 1000; ++i) {
grpc::testing::EchoTestService::NewStub(channel_); grpc::testing::EchoTestService::NewStub(channel_);

Loading…
Cancel
Save