Remove deprecated ByteBufferReader and ByteBufferWriter functions

This completes the conversion of ByteBufferReader and ByteBufferWriter
to uint8_t.

No-Try: True
Bug: webrtc:15661
Change-Id: I4152a8a4fd2462282d4107b3c2eed19acc8b29b0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/331640
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41403}
This commit is contained in:
Harald Alvestrand 2023-12-18 12:53:09 +00:00 committed by WebRTC LUCI CQ
parent 944b01eb97
commit e0e03ba73a
5 changed files with 8 additions and 23 deletions

View File

@ -587,7 +587,7 @@ bool StunMessage::AddFingerprint() {
bool StunMessage::Read(ByteBufferReader* buf) {
// Keep a copy of the buffer data around for later verification.
buffer_.assign(buf->Data(), buf->Length());
buffer_.assign(reinterpret_cast<const char*>(buf->Data()), buf->Length());
if (!buf->ReadUInt16(&type_)) {
return false;

View File

@ -1213,7 +1213,7 @@ void PseudoTcp::parseOptions(const char* data, uint32_t len) {
// Content of this option.
if (opt_len <= buf.Length()) {
applyOption(kind, buf.Data(), opt_len);
applyOption(kind, reinterpret_cast<const char*>(buf.Data()), opt_len);
buf.Consume(opt_len);
} else {
RTC_LOG(LS_ERROR) << "Invalid option length received.";

View File

@ -139,10 +139,6 @@ bool ByteBufferReader::ReadBytes(rtc::ArrayView<uint8_t> val) {
return ReadBytes(val.data(), val.size());
}
bool ByteBufferReader::ReadBytes(char* val, size_t len) {
return ReadBytes(reinterpret_cast<uint8_t*>(val), len);
}
// Private function supporting the other Read* functions.
bool ByteBufferReader::ReadBytes(uint8_t* val, size_t len) {
if (len > Length()) {

View File

@ -100,12 +100,6 @@ class ByteBufferWriterT {
void WriteBytes(const uint8_t* val, size_t len) {
WriteBytesInternal(reinterpret_cast<const value_type*>(val), len);
}
// For backwards compatibility: Write an array of char
// TODO(bugs.webrtc.org/15665): Remove when users converted
[[deprecated("Use WriteString")]] void WriteBytes(const char* val,
size_t len) {
WriteBytesInternal(reinterpret_cast<const value_type*>(val), len);
}
// Reserves the given number of bytes and returns a value_type* that can be
// written into. Useful for functions that require a value_type* buffer and
@ -163,14 +157,10 @@ class ByteBufferReader {
ByteBufferReader(const ByteBufferReader&) = delete;
ByteBufferReader& operator=(const ByteBufferReader&) = delete;
// Returns start of unprocessed data.
// TODO(bugs.webrtc.org/15661): Deprecate and remove.
const char* Data() const {
return reinterpret_cast<const char*>(bytes_ + start_);
}
const uint8_t* Data() const { return bytes_ + start_; }
// Returns number of unprocessed bytes.
size_t Length() const { return end_ - start_; }
// Returns a view of the unprocessed data.
// Returns a view of the unprocessed data. Does not move current position.
rtc::ArrayView<const uint8_t> DataView() const {
return rtc::ArrayView<const uint8_t>(bytes_ + start_, end_ - start_);
}
@ -183,11 +173,8 @@ class ByteBufferReader {
bool ReadUInt32(uint32_t* val);
bool ReadUInt64(uint64_t* val);
bool ReadUVarint(uint64_t* val);
// Copies the val.size() next bytes into val.data().
bool ReadBytes(rtc::ArrayView<uint8_t> val);
// For backwards compatibility.
// TODO(bugs.webrtc.org/15661): Deprecate and remove.
[[deprecated("Read using ArrayView")]] bool ReadBytes(char* val, size_t len);
// Appends next `len` bytes from the buffer to `val`. Returns false
// if there is less than `len` bytes left.
bool ReadString(std::string* val, size_t len);

View File

@ -75,7 +75,9 @@ void AsyncSocksProxyServerSocket::ProcessInput(char* data, size_t* len) {
// Consume parsed data
*len = response.Length();
memmove(data, response.Data(), *len);
if (response.Length() > 0) {
memmove(data, response.DataView().data(), *len);
}
}
void AsyncSocksProxyServerSocket::DirectSend(const ByteBufferWriter& buf) {