Remove deprecated version of SetTotalBytesLimit() (#8794)

* Remove deprecated version of SetTotalBytesLimit()

It has been depcated for at least 3 years.
Worst (backward incompatible) things happened during this period.

I think this method could be safely removed, as the client code fix is trivial.

* Fix coded_stream_unittest.cc
pull/8808/head
Yuriy Chernyshov 4 years ago committed by GitHub
parent 2126123b53
commit cda795437d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      src/google/protobuf/io/coded_stream.h
  2. 14
      src/google/protobuf/io/coded_stream_unittest.cc

@ -399,13 +399,6 @@ class PROTOBUF_EXPORT CodedInputStream {
// This is unrelated to PushLimit()/PopLimit().
void SetTotalBytesLimit(int total_bytes_limit);
PROTOBUF_DEPRECATED_MSG(
"Please use the single parameter version of SetTotalBytesLimit(). The "
"second parameter is ignored.")
void SetTotalBytesLimit(int total_bytes_limit, int) {
SetTotalBytesLimit(total_bytes_limit);
}
// The Total Bytes Limit minus the Current Position, or -1 if the total bytes
// limit is INT_MAX.
int BytesUntilTotalBytesLimit() const;

@ -741,7 +741,7 @@ TEST_1D(CodedStreamTest, ReadStringReservesMemoryOnTotalLimit, kBlockSizes) {
{
CodedInputStream coded_input(&input);
coded_input.SetTotalBytesLimit(sizeof(kRawBytes), sizeof(kRawBytes));
coded_input.SetTotalBytesLimit(sizeof(kRawBytes));
EXPECT_EQ(sizeof(kRawBytes), coded_input.BytesUntilTotalBytesLimit());
std::string str;
@ -864,7 +864,7 @@ TEST_F(CodedStreamTest, ReadStringNoReservationSizeIsOverTheTotalBytesLimit) {
{
CodedInputStream coded_input(&input);
coded_input.SetTotalBytesLimit(16, 16);
coded_input.SetTotalBytesLimit(16);
std::string str;
EXPECT_FALSE(coded_input.ReadString(&str, strlen(kRawBytes)));
@ -886,7 +886,7 @@ TEST_F(CodedStreamTest,
{
CodedInputStream coded_input(&input);
coded_input.PushLimit(sizeof(buffer_));
coded_input.SetTotalBytesLimit(16, 16);
coded_input.SetTotalBytesLimit(16);
std::string str;
EXPECT_FALSE(coded_input.ReadString(&str, strlen(kRawBytes)));
@ -908,7 +908,7 @@ TEST_F(CodedStreamTest,
{
CodedInputStream coded_input(&input);
coded_input.PushLimit(16);
coded_input.SetTotalBytesLimit(sizeof(buffer_), sizeof(buffer_));
coded_input.SetTotalBytesLimit(sizeof(buffer_));
EXPECT_EQ(sizeof(buffer_), coded_input.BytesUntilTotalBytesLimit());
std::string str;
@ -1180,7 +1180,7 @@ TEST_F(CodedStreamTest, OverflowLimit) {
TEST_F(CodedStreamTest, TotalBytesLimit) {
ArrayInputStream input(buffer_, sizeof(buffer_));
CodedInputStream coded_input(&input);
coded_input.SetTotalBytesLimit(16, -1);
coded_input.SetTotalBytesLimit(16);
EXPECT_EQ(16, coded_input.BytesUntilTotalBytesLimit());
std::string str;
@ -1200,7 +1200,7 @@ TEST_F(CodedStreamTest, TotalBytesLimit) {
"A protocol message was rejected because it was too big",
errors[0]);
coded_input.SetTotalBytesLimit(32, -1);
coded_input.SetTotalBytesLimit(32);
EXPECT_EQ(16, coded_input.BytesUntilTotalBytesLimit());
EXPECT_TRUE(coded_input.ReadString(&str, 16));
EXPECT_EQ(0, coded_input.BytesUntilTotalBytesLimit());
@ -1213,7 +1213,7 @@ TEST_F(CodedStreamTest, TotalBytesLimitNotValidMessageEnd) {
CodedInputStream coded_input(&input);
// Set both total_bytes_limit and a regular limit at 16 bytes.
coded_input.SetTotalBytesLimit(16, -1);
coded_input.SetTotalBytesLimit(16);
CodedInputStream::Limit limit = coded_input.PushLimit(16);
// Read 16 bytes.

Loading…
Cancel
Save