diff --git a/src/google/protobuf/parse_context.h b/src/google/protobuf/parse_context.h index 15051c3eba82f..525ddb2a22870 100644 --- a/src/google/protobuf/parse_context.h +++ b/src/google/protobuf/parse_context.h @@ -327,7 +327,7 @@ class PROTOBUF_EXPORT EpsCopyInputStream { template const char* AppendSize(const char* ptr, int size, const A& append) { - int chunk_size = buffer_end_ + kSlopBytes - ptr; + int chunk_size = static_cast(buffer_end_ + kSlopBytes - ptr); do { GOOGLE_DCHECK(size > chunk_size); if (next_chunk_ == nullptr) return nullptr; @@ -341,7 +341,7 @@ class PROTOBUF_EXPORT EpsCopyInputStream { ptr = Next(); if (ptr == nullptr) return nullptr; // passed the limit ptr += kSlopBytes; - chunk_size = buffer_end_ + kSlopBytes - ptr; + chunk_size = static_cast(buffer_end_ + kSlopBytes - ptr); } while (size > chunk_size); append(ptr, size); return ptr + size; @@ -785,7 +785,7 @@ template const char* EpsCopyInputStream::ReadPackedFixed(const char* ptr, int size, RepeatedField* out) { GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); - int nbytes = buffer_end_ + kSlopBytes - ptr; + int nbytes = static_cast(buffer_end_ + kSlopBytes - ptr); while (size > nbytes) { int num = nbytes / sizeof(T); int old_entries = out->size(); @@ -803,7 +803,7 @@ const char* EpsCopyInputStream::ReadPackedFixed(const char* ptr, int size, ptr = Next(); if (ptr == nullptr) return nullptr; ptr += kSlopBytes - (nbytes - block_size); - nbytes = buffer_end_ + kSlopBytes - ptr; + nbytes = static_cast(buffer_end_ + kSlopBytes - ptr); } int num = size / sizeof(T); int old_entries = out->size(); @@ -835,11 +835,11 @@ template const char* EpsCopyInputStream::ReadPackedVarint(const char* ptr, Add add) { int size = ReadSize(&ptr); GOOGLE_PROTOBUF_PARSER_ASSERT(ptr); - int chunk_size = buffer_end_ - ptr; + int chunk_size = static_cast(buffer_end_ - ptr); while (size > chunk_size) { ptr = ReadPackedVarintArray(ptr, buffer_end_, add); if (ptr == nullptr) return nullptr; - int overrun = ptr - buffer_end_; + int overrun = static_cast(ptr - buffer_end_); GOOGLE_DCHECK(overrun >= 0 && overrun <= kSlopBytes); if (size - chunk_size <= kSlopBytes) { // The current buffer contains all the information needed, we don't need @@ -860,7 +860,7 @@ const char* EpsCopyInputStream::ReadPackedVarint(const char* ptr, Add add) { ptr = Next(); if (ptr == nullptr) return nullptr; ptr += overrun; - chunk_size = buffer_end_ - ptr; + chunk_size = static_cast(buffer_end_ - ptr); } auto end = ptr + size; ptr = ReadPackedVarintArray(ptr, end, add); @@ -883,7 +883,7 @@ PROTOBUF_NODISCARD PROTOBUF_EXPORT const char* InlineGreedyStringParser( template PROTOBUF_NODISCARD const char* FieldParser(uint64_t tag, T& field_parser, const char* ptr, ParseContext* ctx) { - uint32_t number = tag >> 3; + uint32_t number = static_cast(tag >> 3); GOOGLE_PROTOBUF_PARSER_ASSERT(number != 0); using WireType = internal::WireFormatLite::WireType; switch (tag & 7) {