Skip to content

Commit

Permalink
Remove deprecated version of SetTotalBytesLimit() (#8794)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
georgthegreat committed Jul 9, 2021
1 parent 2126123 commit cda7954
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
7 changes: 0 additions & 7 deletions src/google/protobuf/io/coded_stream.h
Expand Up @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions src/google/protobuf/io/coded_stream_unittest.cc
Expand Up @@ -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;
Expand Down Expand Up @@ -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)));
Expand All @@ -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)));
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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());
Expand All @@ -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.
Expand Down

0 comments on commit cda7954

Please sign in to comment.