From 0313d61e6f15b2b5c3db2899be3066c7fbbc8082 Mon Sep 17 00:00:00 2001 From: Carlos O'Ryan Date: Thu, 11 May 2023 11:00:22 +0000 Subject: [PATCH] fix: avoid warnings with MSVC In both cases a `size_t` was being converted to a `uint32_t`. These headers are used from application code, or at least from generated code, and the application may be compiling with more warnings enabled than normal. --- src/google/protobuf/has_bits.h | 2 +- src/google/protobuf/string_block.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/google/protobuf/has_bits.h b/src/google/protobuf/has_bits.h index b90c450059..aae330b22a 100644 --- a/src/google/protobuf/has_bits.h +++ b/src/google/protobuf/has_bits.h @@ -71,7 +71,7 @@ class HasBits { } void Or(const HasBits& rhs) { - for (size_t i = 0; i < doublewords; i++) has_bits_[i] |= rhs[i]; + for (size_t i = 0; i < doublewords; i++) has_bits_[i] |= rhs.has_bits_[i]; } bool empty() const; diff --git a/src/google/protobuf/string_block.h b/src/google/protobuf/string_block.h index b105d57f3c..1ba8980336 100644 --- a/src/google/protobuf/string_block.h +++ b/src/google/protobuf/string_block.h @@ -145,7 +145,8 @@ inline StringBlock* StringBlock::Emplace(void* p, size_t n, StringBlock* next) { ABSL_DCHECK_EQ(n, NextSize(next)); uint32_t doubled = static_cast(n) * 2; uint32_t next_size = next ? std::min(doubled, max_size()) : min_size(); - return new (p) StringBlock(next, false, RoundedSize(n), next_size); + return new (p) StringBlock( + next, false, RoundedSize(static_cast(n)), next_size); } inline StringBlock* StringBlock::New(StringBlock* next) {