Prepare to make many APIs [[nodiscard]].

PiperOrigin-RevId: 844770264
This commit is contained in:
Chris Kennelly 2025-12-15 07:50:39 -08:00 committed by Copybara-Service
parent eade3d4c54
commit d326c1d6da
22 changed files with 102 additions and 60 deletions

View file

@ -328,9 +328,10 @@ BENCHMARK_TEMPLATE(BM_Parse_Proto2, FileDescSV, InitBlock, Alias);
static void BM_SerializeDescriptor_Proto2(benchmark::State& state) {
upb_benchmark::FileDescriptorProto proto;
proto.ParseFromString(absl::string_view(descriptor.data, descriptor.size));
(void)proto.ParseFromString(
absl::string_view(descriptor.data, descriptor.size));
for (auto _ : state) {
proto.SerializePartialToArray(buf, sizeof(buf));
(void)proto.SerializePartialToArray(buf, sizeof(buf));
benchmark::DoNotOptimize(buf);
}
state.SetBytesProcessed(state.iterations() * descriptor.size);
@ -420,7 +421,7 @@ BENCHMARK(BM_JsonParse_Upb);
static void BM_JsonParse_Proto2(benchmark::State& state) {
protobuf::FileDescriptorProto proto;
absl::string_view input(descriptor.data, descriptor.size);
proto.ParseFromString(input);
(void)proto.ParseFromString(input);
std::string json;
ABSL_CHECK_OK(google::protobuf::json::MessageToJsonString(proto, &json));
for (auto _ : state) {
@ -461,7 +462,7 @@ BENCHMARK(BM_JsonSerialize_Upb);
static void BM_JsonSerialize_Proto2(benchmark::State& state) {
protobuf::FileDescriptorProto proto;
absl::string_view input(descriptor.data, descriptor.size);
proto.ParseFromString(input);
(void)proto.ParseFromString(input);
std::string json;
for (auto _ : state) {
json.clear();

View file

@ -54,8 +54,8 @@ def RefMessage(name):
print('''
{{
{name} proto;
proto.ParseFromArray(buf, 0);
proto.SerializePartialToArray(&buf[0], 0);
(void)proto.ParseFromArray(buf, 0);
(void)proto.SerializePartialToArray(&buf[0], 0);
}}
'''.format(name=name))

View file

@ -99,7 +99,8 @@ bool LuaGenerator::Generate(const protobuf::FileDescriptor* file,
protobuf::FileDescriptorProto file_proto;
file->CopyTo(&file_proto);
std::string file_data;
file_proto.SerializeToString(&file_data);
// TODO: Remove this suppression.
(void)file_proto.SerializeToString(&file_data);
printer.Print("local descriptor = table.concat({\n");
absl::string_view data(file_data);

View file

@ -46,7 +46,8 @@ PythonMessageMutator::~PythonMessageMutator() {
// check.
if (!PyErr_Occurred() && owned_msg_ != nullptr) {
std::string wire;
message_->SerializePartialToString(&wire);
// TODO: Remove this suppression.
(void)message_->SerializePartialToString(&wire);
PyObject* py_wire = PyBytes_FromStringAndSize(
wire.data(), static_cast<Py_ssize_t>(wire.size()));
PyObject* parse =
@ -113,20 +114,23 @@ bool PythonConstMessagePointer::NotChanged() {
// serialize result may still diff between languages. So parse to
// another c++ message for compare.
std::unique_ptr<google::protobuf::Message> parsed_msg(owned_msg_->New());
parsed_msg->ParsePartialFromString(
// TODO: Remove this suppression.
(void)parsed_msg->ParsePartialFromString(
absl::string_view(data, static_cast<int>(len)));
std::string wire_other;
google::protobuf::io::StringOutputStream stream_other(&wire_other);
google::protobuf::io::CodedOutputStream output_other(&stream_other);
output_other.SetSerializationDeterministic(true);
parsed_msg->SerializePartialToCodedStream(&output_other);
// TODO: Remove this suppression.
(void)parsed_msg->SerializePartialToCodedStream(&output_other);
output_other.Trim();
std::string wire;
google::protobuf::io::StringOutputStream stream(&wire);
google::protobuf::io::CodedOutputStream output(&stream);
output.SetSerializationDeterministic(true);
owned_msg_->SerializePartialToCodedStream(&output);
// TODO: Remove this suppression.
(void)owned_msg_->SerializePartialToCodedStream(&output);
output.Trim();
if (wire == wire_other) {

View file

@ -228,7 +228,8 @@ bool Reparse(PyMessageFactory* message_factory, const Message& from,
Message* to) {
// Reparse message.
std::string serialized;
from.SerializeToString(&serialized);
// TODO: Remove this suppression.
(void)from.SerializeToString(&serialized);
io::CodedInputStream input(
reinterpret_cast<const uint8_t*>(serialized.c_str()), serialized.size());
input.SetExtensionRegistry(message_factory->pool->pool,
@ -1490,7 +1491,8 @@ static PyObject* GetSerializedPb(PyFileDescriptor* self, void* closure) {
FileDescriptorProto file_proto;
_GetDescriptor(self)->CopyTo(&file_proto);
std::string contents;
file_proto.SerializePartialToString(&contents);
// TODO: Remove this suppression.
(void)file_proto.SerializePartialToString(&contents);
self->serialized_pb = PyBytes_FromStringAndSize(
contents.c_str(), static_cast<size_t>(contents.size()));
if (self->serialized_pb == nullptr) {

View file

@ -285,8 +285,10 @@ absl::StatusOr<google::protobuf::Message*> CreateNewMessage(PyObject* py_msg) {
bool CopyToOwnedMsg(google::protobuf::Message** copy, const google::protobuf::Message& message) {
*copy = message.New();
std::string wire;
message.SerializePartialToString(&wire);
(*copy)->ParsePartialFromString(wire);
// TODO: Remove this suppression.
(void)message.SerializePartialToString(&wire);
// TODO: Remove this suppression.
(void)(*copy)->ParsePartialFromString(wire);
return true;
}

View file

@ -42,7 +42,8 @@ void FieldGeneratorBase::SetCommonFieldVariables(
}
uint tag = internal::WireFormat::MakeTag(descriptor_);
uint8_t tag_array[5];
io::CodedOutputStream::WriteTagToArray(tag, tag_array);
// TODO: Remove this suppression.
(void)io::CodedOutputStream::WriteTagToArray(tag, tag_array);
std::string tag_bytes = absl::StrCat(tag_array[0]);
for (int i = 1; i < part_tag_size; i++) {
absl::StrAppend(&tag_bytes, ", ", tag_array[i]);
@ -56,7 +57,8 @@ void FieldGeneratorBase::SetCommonFieldVariables(
tag = internal::WireFormatLite::MakeTag(
descriptor_->number(),
internal::WireFormatLite::WIRETYPE_END_GROUP);
io::CodedOutputStream::WriteTagToArray(tag, tag_array);
// TODO: Remove this suppression.
(void)io::CodedOutputStream::WriteTagToArray(tag, tag_array);
tag_bytes = absl::StrCat(tag_array[0]);
for (int i = 1; i < part_tag_size; i++) {
absl::StrAppend(&tag_bytes, ", ", tag_array[i]);

View file

@ -1432,7 +1432,9 @@ TEST(GeneratedMessageReflectionTest, ArenaReleaseOneofMessageTest) {
TEST(GeneratedMessageReflectionTest, UsageErrors) {
unittest::TestAllTypes message;
#ifndef NDEBUG
unittest::ForeignMessage foreign;
#endif
const Reflection* reflection = message.GetReflection();
const Descriptor* descriptor = message.GetDescriptor();

View file

@ -214,7 +214,8 @@ bool CodedInputStream::SkipFallback(int count, int original_buffer_size) {
// We hit the limit. Skip up to it then fail.
if (bytes_until_limit > 0) {
total_bytes_read_ = closest_limit;
input_->Skip(bytes_until_limit);
// TODO: Remove this suppression.
(void)input_->Skip(bytes_until_limit);
}
return false;
}
@ -337,7 +338,8 @@ bool CodedInputStream::ReadCord(absl::Cord* output, int size) {
const int available = closest_limit - total_bytes_read_;
if (ABSL_PREDICT_FALSE(size > available)) {
total_bytes_read_ = closest_limit;
input_->ReadCord(output, available);
// TODO: Remove this suppression.
(void)input_->ReadCord(output, available);
return false;
}
total_bytes_read_ += size;
@ -359,7 +361,8 @@ bool CodedInputStream::ReadLittleEndian16Fallback(uint16_t* value) {
if (!ReadRaw(bytes, kSize)) return false;
ptr = bytes;
}
ReadLittleEndian16FromArray(ptr, value);
// TODO: Remove this suppression.
(void)ReadLittleEndian16FromArray(ptr, value);
return true;
}
@ -377,7 +380,8 @@ bool CodedInputStream::ReadLittleEndian32Fallback(uint32_t* value) {
if (!ReadRaw(bytes, kSize)) return false;
ptr = bytes;
}
ReadLittleEndian32FromArray(ptr, value);
// TODO: Remove this suppression.
(void)ReadLittleEndian32FromArray(ptr, value);
return true;
}
@ -395,7 +399,8 @@ bool CodedInputStream::ReadLittleEndian64Fallback(uint64_t* value) {
if (!ReadRaw(bytes, kSize)) return false;
ptr = bytes;
}
ReadLittleEndian64FromArray(ptr, value);
// TODO: Remove this suppression.
(void)ReadLittleEndian64FromArray(ptr, value);
return true;
}

View file

@ -179,7 +179,8 @@ TEST_F(CodedStreamTest, EmptyInputBeforeEos) {
int count_;
} in;
CodedInputStream input(&in);
input.ReadTagNoLastTag();
// TODO: Remove this suppression.
(void)input.ReadTagNoLastTag();
EXPECT_TRUE(input.ConsumedEntireMessage());
}
@ -200,7 +201,8 @@ TEST_P(VarintCases, ExpectTag) {
// Read one byte to force coded_input.Refill() to be called. Otherwise,
// ExpectTag() will return a false negative.
uint8_t dummy;
coded_input.ReadRaw(&dummy, 1);
// TODO: Remove this suppression.
(void)coded_input.ReadRaw(&dummy, 1);
EXPECT_EQ((uint)'\0', (uint)dummy);
uint32_t expected_value = static_cast<uint32_t>(kVarintCases_case.value);
@ -831,7 +833,8 @@ TEST_P(BlockSizes, ReadStringReservesMemoryOnPushedLimit) {
{
CodedInputStream coded_input(&input);
coded_input.PushLimit(sizeof(buffer_));
// TODO: Remove this suppression.
(void)coded_input.PushLimit(sizeof(buffer_));
std::string str;
EXPECT_TRUE(coded_input.ReadString(&str, strlen(kRawBytes)));
@ -876,7 +879,8 @@ TEST_F(CodedStreamTest, ReadStringNoReservationSizeIsNegative) {
{
CodedInputStream coded_input(&input);
coded_input.PushLimit(sizeof(buffer_));
// TODO: Remove this suppression.
(void)coded_input.PushLimit(sizeof(buffer_));
std::string str;
EXPECT_FALSE(coded_input.ReadString(&str, -1));
@ -896,7 +900,8 @@ TEST_F(CodedStreamTest, ReadStringNoReservationSizeIsLarge) {
{
CodedInputStream coded_input(&input);
coded_input.PushLimit(sizeof(buffer_));
// TODO: Remove this suppression.
(void)coded_input.PushLimit(sizeof(buffer_));
std::string str;
EXPECT_FALSE(coded_input.ReadString(&str, 1 << 30));
@ -913,7 +918,8 @@ TEST_F(CodedStreamTest, ReadStringNoReservationSizeIsOverTheLimit) {
{
CodedInputStream coded_input(&input);
coded_input.PushLimit(16);
// TODO: Remove this suppression.
(void)coded_input.PushLimit(16);
std::string str;
EXPECT_FALSE(coded_input.ReadString(&str, strlen(kRawBytes)));
@ -954,7 +960,8 @@ TEST_F(CodedStreamTest,
{
CodedInputStream coded_input(&input);
coded_input.PushLimit(sizeof(buffer_));
// TODO: Remove this suppression.
(void)coded_input.PushLimit(sizeof(buffer_));
coded_input.SetTotalBytesLimit(16);
std::string str;
@ -976,7 +983,8 @@ TEST_F(CodedStreamTest,
{
CodedInputStream coded_input(&input);
coded_input.PushLimit(16);
// TODO: Remove this suppression.
(void)coded_input.PushLimit(16);
coded_input.SetTotalBytesLimit(sizeof(buffer_));
EXPECT_EQ(sizeof(buffer_), coded_input.BytesUntilTotalBytesLimit());

View file

@ -62,8 +62,8 @@ TEST(TestZeroCopyInputStreamTest, NextChecksPreconditions) {
std::make_unique<TestZeroCopyInputStream>(std::vector<std::string>{});
const void* data;
int size;
EXPECT_DEATH(stream->Next(nullptr, &size), "data must not be null");
EXPECT_DEATH(stream->Next(&data, nullptr), "size must not be null");
EXPECT_DEATH((void)stream->Next(nullptr, &size), "data must not be null");
EXPECT_DEATH((void)stream->Next(&data, nullptr), "size must not be null");
}
#endif // GTEST_HAS_DEATH_TEST
@ -119,7 +119,7 @@ TEST(TestZeroCopyInputStreamTest, BackUpChecksPreconditions) {
"The last call was not a successful Next\\(\\)");
EXPECT_THAT(CallNext(*stream), Optional(Eq("C")));
EXPECT_THAT(CallNext(*stream), Optional(Eq("D")));
stream->Skip(1);
(void)stream->Skip(1);
EXPECT_DEATH(stream->BackUp(0),
"The last call was not a successful Next\\(\\)");
EXPECT_THAT(CallNext(*stream), Optional(Eq("FG")));
@ -168,7 +168,7 @@ TEST(TestZeroCopyInputStreamTest, SkipWorks) {
TEST(TestZeroCopyInputStreamTest, SkipChecksPreconditions) {
std::unique_ptr<ZeroCopyInputStream> stream =
std::make_unique<TestZeroCopyInputStream>(std::vector<std::string>{});
EXPECT_DEATH(stream->Skip(-1), "count must not be negative");
EXPECT_DEATH((void)stream->Skip(-1), "count must not be negative");
}
#endif // GTEST_HAS_DEATH_TEST
@ -207,8 +207,8 @@ TEST(TestZeroCopyOutputStreamTest, NextChecksPreconditions) {
std::make_unique<TestZeroCopyOutputStream>(empty);
void* data;
int size;
EXPECT_DEATH(stream->Next(nullptr, &size), "data must not be null");
EXPECT_DEATH(stream->Next(&data, nullptr), "size must not be null");
EXPECT_DEATH((void)stream->Next(nullptr, &size), "data must not be null");
EXPECT_DEATH((void)stream->Next(&data, nullptr), "size must not be null");
}
#endif // GTEST_HAS_DEATH_TEST

View file

@ -443,7 +443,8 @@ void LimitingInputStream::BackUp(int count) {
bool LimitingInputStream::Skip(int count) {
if (count > limit_) {
if (limit_ < 0) return false;
input_->Skip(limit_);
// TODO: Remove this suppression.
(void)input_->Skip(limit_);
limit_ = 0;
return false;
} else {
@ -468,7 +469,8 @@ bool LimitingInputStream::ReadCord(absl::Cord* cord, int count) {
limit_ -= count;
return true;
}
input_->ReadCord(cord, limit_);
// TODO: Remove this suppression.
(void)input_->ReadCord(cord, limit_);
limit_ = 0;
return false;
}

View file

@ -256,7 +256,8 @@ absl::Status UntypedMessage::Decode(io::CodedInputStream& stream,
if (!stream.ReadVarint32(&x)) {
return MakeUnexpectedEofError();
}
stream.Skip(x);
// TODO: Remove this suppression.
(void)stream.Skip(x);
continue;
}
case WireFormatLite::WIRETYPE_START_GROUP: {
@ -516,7 +517,8 @@ absl::Status UntypedMessage::DecodeDelimited(io::CodedInputStream& stream,
break;
}
}
stream.DecrementRecursionDepthAndPopLimit(limit);
// TODO: Remove this suppression.
(void)stream.DecrementRecursionDepthAndPopLimit(limit);
return absl::OkStatus();
}

View file

@ -1399,8 +1399,9 @@ TEST(LiteTest, DynamicCastMessageInvalidReferenceType) {
CastType1 test_type_1;
const MessageLite& test_type_1_pointer_const_ref = test_type_1;
#if defined(ABSL_HAVE_EXCEPTIONS)
EXPECT_THROW(DynamicCastMessage<CastType2>(test_type_1_pointer_const_ref),
std::bad_cast);
EXPECT_THROW(
(void)DynamicCastMessage<CastType2>(test_type_1_pointer_const_ref),
std::bad_cast);
#elif defined(GTEST_HAS_DEATH_TEST)
ASSERT_DEATH(
(void)DynamicCastMessage<CastType2>(test_type_1_pointer_const_ref),

View file

@ -289,7 +289,8 @@ class ZeroCopyCodedInputStream : public io::ZeroCopyInputStream {
explicit ZeroCopyCodedInputStream(io::CodedInputStream* cis) : cis_(cis) {}
bool Next(const void** data, int* size) final {
if (!cis_->GetDirectBufferPointer(data, size)) return false;
cis_->Skip(*size);
// TODO: Remove this suppression.
(void)cis_->Skip(*size);
return true;
}
void BackUp(int count) final { cis_->Advance(-count); }
@ -479,7 +480,8 @@ inline uint8_t* SerializeToArrayImpl(const MessageLite& msg, uint8_t* target,
&stream, io::CodedOutputStream::IsDefaultSerializationDeterministic(),
&ptr);
ptr = msg._InternalSerialize(ptr, &out);
out.Trim(ptr);
// TODO: Remove this suppression.
(void)out.Trim(ptr);
ABSL_DCHECK(!out.HadError() && stream.ByteCount() == size);
return target + size;
} else {
@ -549,7 +551,8 @@ bool MessageLite::SerializePartialToZeroCopyStream(
output, io::CodedOutputStream::IsDefaultSerializationDeterministic(),
&target);
target = _InternalSerialize(target, &stream);
stream.Trim(target);
// TODO: Remove this suppression.
(void)stream.Trim(target);
if (stream.HadError()) return false;
return true;
}
@ -690,7 +693,8 @@ bool MessageLite::AppendPartialToString(absl::Cord* output) const {
target, static_cast<int>(available.size()), &output_stream,
io::CodedOutputStream::IsDefaultSerializationDeterministic(), &target);
target = _InternalSerialize(target, &out);
out.Trim(target);
// TODO: Remove this suppression.
(void)out.Trim(target);
if (out.HadError()) return false;
*output = output_stream.Consume();
ABSL_DCHECK_EQ(output->size(), total_size);

View file

@ -861,7 +861,7 @@ TEST(MESSAGE_TEST_NAME, DynamicCastMessageInvalidReferenceType) {
UNITTEST::TestAllTypes test_all_types;
const MessageLite& test_all_types_pointer_const_ref = test_all_types;
#if defined(ABSL_HAVE_EXCEPTIONS)
EXPECT_THROW(DynamicCastMessage<UNITTEST::TestRequired>(
EXPECT_THROW((void)DynamicCastMessage<UNITTEST::TestRequired>(
test_all_types_pointer_const_ref),
std::bad_cast);
#else

View file

@ -312,6 +312,7 @@ TEST(NoFieldPresenceTest, CopyTwiceDefaultStringFieldTest) {
dst = src;
dst = src;
(void)dst;
}
TEST(NoFieldPresenceTest, CopyTwiceAllocatedStringFieldTest) {
@ -325,6 +326,7 @@ TEST(NoFieldPresenceTest, CopyTwiceAllocatedStringFieldTest) {
dst = src;
dst = src;
(void)dst;
}
TEST(NoFieldPresenceTest, CopyTwiceEmptyStringFieldTest) {
@ -339,6 +341,7 @@ TEST(NoFieldPresenceTest, CopyTwiceEmptyStringFieldTest) {
dst = src;
dst = src;
(void)dst;
}
class NoFieldPresenceSwapFieldTest : public testing::Test {

View file

@ -698,7 +698,8 @@ class UnknownFieldLiteParserHelper {
if (unknown_ == nullptr) return;
WriteVarint(num * 8 + 1, unknown_);
char buffer[8];
io::CodedOutputStream::WriteLittleEndian64ToArray(
// TODO: Remove this suppression.
(void)io::CodedOutputStream::WriteLittleEndian64ToArray(
value, reinterpret_cast<uint8_t*>(buffer));
unknown_->append(buffer, 8);
}
@ -724,7 +725,8 @@ class UnknownFieldLiteParserHelper {
if (unknown_ == nullptr) return;
WriteVarint(num * 8 + 5, unknown_);
char buffer[4];
io::CodedOutputStream::WriteLittleEndian32ToArray(
// TODO: Remove this suppression.
(void)io::CodedOutputStream::WriteLittleEndian32ToArray(
value, reinterpret_cast<uint8_t*>(buffer));
unknown_->append(buffer, 4);
}

View file

@ -162,12 +162,13 @@ TEST(Proto3ArenaTest, GetArenaWithUnknown) {
// Tests arena-allocated message and submessages.
auto* arena_message1 = Arena::Create<TestAllTypes>(&arena);
arena_message1->GetReflection()->MutableUnknownFields(arena_message1);
(void)arena_message1->GetReflection()->MutableUnknownFields(arena_message1);
auto* arena_submessage1 = arena_message1->mutable_optional_foreign_message();
arena_submessage1->GetReflection()->MutableUnknownFields(arena_submessage1);
(void)arena_submessage1->GetReflection()->MutableUnknownFields(
arena_submessage1);
auto* arena_repeated_submessage1 =
arena_message1->add_repeated_foreign_message();
arena_repeated_submessage1->GetReflection()->MutableUnknownFields(
(void)arena_repeated_submessage1->GetReflection()->MutableUnknownFields(
arena_repeated_submessage1);
EXPECT_EQ(&arena, arena_message1->GetArena());
EXPECT_EQ(&arena, arena_submessage1->GetArena());
@ -179,10 +180,10 @@ TEST(Proto3ArenaTest, GetArenaWithUnknown) {
arena_message2->mutable_repeated_foreign_message()->AddAllocated(
new ForeignMessage());
auto* submessage2 = arena_message2->mutable_optional_foreign_message();
submessage2->GetReflection()->MutableUnknownFields(submessage2);
(void)submessage2->GetReflection()->MutableUnknownFields(submessage2);
auto* repeated_submessage2 =
arena_message2->mutable_repeated_foreign_message(0);
repeated_submessage2->GetReflection()->MutableUnknownFields(
(void)repeated_submessage2->GetReflection()->MutableUnknownFields(
repeated_submessage2);
EXPECT_EQ(nullptr, submessage2->GetArena());
EXPECT_EQ(nullptr, repeated_submessage2->GetArena());

View file

@ -779,7 +779,7 @@ TYPED_TEST_P(WireFormatTest, ParseMessageSetWithDeepRecReverseOrder) {
m->set_i(i);
mset = m->mutable_recursive();
}
message_set.ByteSizeLong();
EXPECT_GT(message_set.ByteSizeLong(), 0);
// Serialize with reverse payload tag order
io::StringOutputStream output_stream(&data);
io::CodedOutputStream coded_output(&output_stream);
@ -834,7 +834,7 @@ TYPED_TEST_P(WireFormatTest, ParseFailMalformedMessageSetReverseOrder) {
// SerializeReverseOrder() assumes "recursive" is always present.
m->mutable_recursive();
message_set.ByteSizeLong();
EXPECT_GT(message_set.ByteSizeLong(), 0);
// Serialize with reverse payload tag order
io::StringOutputStream output_stream(&data);

View file

@ -39,7 +39,7 @@ const google::protobuf::Descriptor* AddMessageDescriptor(upb::MessageDefPtr msgd
const char* buf =
google_protobuf_FileDescriptorProto_serialize(upb_proto, tmp_arena.ptr(), &size);
google::protobuf::FileDescriptorProto google_proto;
google_proto.ParseFromString(absl::string_view(buf, size));
EXPECT_TRUE(google_proto.ParseFromString(absl::string_view(buf, size)));
const google::protobuf::FileDescriptor* file_desc = pool->BuildFile(google_proto);
EXPECT_TRUE(file_desc != nullptr);
return pool->FindMessageTypeByName(msgdef.full_name());
@ -60,7 +60,7 @@ std::unique_ptr<google::protobuf::Message> ToProto(const upb_Message* msg,
upb_EncodeStatus status = upb_Encode(msg, upb_MessageDef_MiniTable(msgdef), 0,
arena.ptr(), &buf, &size);
EXPECT_EQ(status, kUpb_EncodeStatus_Ok);
google_msg->ParseFromString(absl::string_view(buf, size));
EXPECT_TRUE(google_msg->ParseFromString(absl::string_view(buf, size)));
return google_msg;
}

View file

@ -65,7 +65,7 @@ static void AddFile(google::protobuf::FileDescriptorProto& file, upb::DefPool* p
google::protobuf::FileDescriptorProto normalized_file;
file_desc->CopyTo(&normalized_file);
std::string serialized;
normalized_file.SerializeToString(&serialized);
(void)normalized_file.SerializeToString(&serialized);
upb::Arena arena;
upb::Status status;
google_protobuf_FileDescriptorProto* proto = google_protobuf_FileDescriptorProto_parse(
@ -100,7 +100,7 @@ static void AddFile(google::protobuf::FileDescriptorProto& file, upb::DefPool* p
// it may or may not be accepted, since upb does not perform as much
// validation as proto2. However it must not crash.
std::string serialized;
file.SerializeToString(&serialized);
(void)file.SerializeToString(&serialized);
upb::Arena arena;
upb::Status status;
google_protobuf_FileDescriptorProto* proto = google_protobuf_FileDescriptorProto_parse(