Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated version of SetTotalBytesLimit() #8794

Merged
merged 2 commits into from
Jul 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/google/protobuf/io/coded_stream.h
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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