diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h index fb5e33cbea87e..b6233ffb49416 100644 --- a/src/google/protobuf/map.h +++ b/src/google/protobuf/map.h @@ -698,11 +698,12 @@ struct KeyNode : NodeBase { // random iteration order. inline map_index_t Hash(absl::string_view k, void* salt) { const uintptr_t salt_int = reinterpret_cast(salt); - return absl::HashOf(k, absl::rotr(salt_int, k.size())); + return static_cast( + absl::HashOf(k, absl::rotr(salt_int, k.size()))); } inline map_index_t Hash(uint64_t k, void* salt) { const uintptr_t salt_int = reinterpret_cast(salt); - return absl::HashOf(k, absl::rotr(salt_int, k)); + return static_cast(absl::HashOf(k, absl::rotr(salt_int, k))); } // KeyMapBase is a chaining hash map. diff --git a/src/google/protobuf/micro_string.h b/src/google/protobuf/micro_string.h index 80fde6e710953..a22f4b0d55d61 100644 --- a/src/google/protobuf/micro_string.h +++ b/src/google/protobuf/micro_string.h @@ -83,12 +83,12 @@ class PROTOBUF_EXPORT MicroString { void SetExternalBuffer(absl::string_view buffer) { payload = const_cast(buffer.data()); - size = buffer.size(); + size = static_cast(buffer.size()); } - void SetInitialSize(size_t size) { - PoisonMemoryRegion(owned_head() + size, capacity - size); - this->size = size; + void SetInitialSize(size_t new_size) { + PoisonMemoryRegion(owned_head() + new_size, capacity - new_size); + this->size = static_cast(new_size); } void Unpoison() { UnpoisonMemoryRegion(owned_head(), capacity); } @@ -96,7 +96,7 @@ class PROTOBUF_EXPORT MicroString { void ChangeSize(size_t new_size) { PoisonMemoryRegion(owned_head() + new_size, capacity - new_size); UnpoisonMemoryRegion(owned_head(), new_size); - size = new_size; + size = static_cast(new_size); } }; @@ -108,9 +108,9 @@ class PROTOBUF_EXPORT MicroString { const char* data() const { return reinterpret_cast(this + 1); } absl::string_view view() const { return {data(), size}; } - void SetInitialSize(uint8_t size) { - PoisonMemoryRegion(data() + size, capacity - size); - this->size = size; + void SetInitialSize(uint8_t new_size) { + PoisonMemoryRegion(data() + new_size, capacity - new_size); + this->size = new_size; } void Unpoison() { UnpoisonMemoryRegion(data(), capacity); } diff --git a/src/google/protobuf/repeated_ptr_field.h b/src/google/protobuf/repeated_ptr_field.h index 345b396c46891..e300cd7578a12 100644 --- a/src/google/protobuf/repeated_ptr_field.h +++ b/src/google/protobuf/repeated_ptr_field.h @@ -2152,16 +2152,17 @@ class RustRepeatedMessageHelper { } static void Reserve(RepeatedPtrFieldBase& field, size_t additional) { - field.ReserveWithArena(field.GetArena(), field.size() + additional); + field.ReserveWithArena(field.GetArena(), + static_cast(field.size() + additional)); } static const MessageLite& At(const RepeatedPtrFieldBase& field, size_t index) { - return field.at>(index); + return field.at>(static_cast(index)); } static MessageLite& At(RepeatedPtrFieldBase& field, size_t index) { - return field.at>(index); + return field.at>(static_cast(index)); } };