Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Unified Diff: webrtc/modules/rtp_rtcp/source/rtp_packet.cc

Issue 3013623002: Fix no_size_t_to_int_warning in rtp_rtcp:rtp_rtcp_format target (Closed)
Patch Set: . Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_packet.h ('k') | webrtc/modules/rtp_rtcp/source/rtp_packet_received.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/rtp_rtcp/source/rtp_packet.cc
diff --git a/webrtc/modules/rtp_rtcp/source/rtp_packet.cc b/webrtc/modules/rtp_rtcp/source/rtp_packet.cc
index 7df60053fb8e206e6d9ed0a6af12b1ecffacc66d..ba0a6ae769620d6386e00d57b402fb24e49e60c4 100644
--- a/webrtc/modules/rtp_rtcp/source/rtp_packet.cc
+++ b/webrtc/modules/rtp_rtcp/source/rtp_packet.cc
@@ -19,6 +19,7 @@
#include "webrtc/rtc_base/checks.h"
#include "webrtc/rtc_base/logging.h"
#include "webrtc/rtc_base/random.h"
+#include "webrtc/rtc_base/safe_conversions.h"
namespace webrtc {
namespace rtp {
@@ -30,7 +31,7 @@ constexpr size_t kOneByteHeaderSize = 1;
constexpr size_t kDefaultPacketSize = 1500;
} // namespace
-constexpr size_t Packet::kMaxExtensionHeaders;
+constexpr int Packet::kMaxExtensionHeaders;
constexpr int Packet::kMinExtensionId;
constexpr int Packet::kMaxExtensionId;
@@ -78,7 +79,7 @@ Packet::Packet(const ExtensionManager* extensions, size_t capacity)
Packet::~Packet() {}
void Packet::IdentifyExtensions(const ExtensionManager& extensions) {
- for (size_t i = 0; i < kMaxExtensionHeaders; ++i)
+ for (int i = 0; i < kMaxExtensionHeaders; ++i)
extension_entries_[i].type = extensions.GetType(i + 1);
}
@@ -242,7 +243,7 @@ void Packet::SetCsrcs(const std::vector<uint32_t>& csrcs) {
RTC_DCHECK_LE(csrcs.size(), 0x0fu);
RTC_DCHECK_LE(kFixedHeaderSize + 4 * csrcs.size(), capacity());
payload_offset_ = kFixedHeaderSize + 4 * csrcs.size();
- WriteAt(0, (data()[0] & 0xF0) | csrcs.size());
+ WriteAt(0, (data()[0] & 0xF0) | rtc::dchecked_cast<uint8_t>(csrcs.size()));
size_t offset = kFixedHeaderSize;
for (uint32_t csrc : csrcs) {
ByteWriter<uint32_t>::WriteBigEndian(WriteAt(offset), csrc);
@@ -328,12 +329,14 @@ rtc::ArrayView<uint8_t> Packet::AllocateRawExtension(int id, size_t length) {
kOneByteExtensionId);
}
- WriteAt(extensions_offset + extensions_size_, (id << 4) | (length - 1));
+ uint8_t one_byte_header = rtc::dchecked_cast<uint8_t>(id) << 4;
+ one_byte_header |= rtc::dchecked_cast<uint8_t>(length - 1);
+ WriteAt(extensions_offset + extensions_size_, one_byte_header);
- extension_entry->offset =
- extensions_offset + extensions_size_ + kOneByteHeaderSize;
- extension_entry->length = length;
- extensions_size_ = new_extensions_size;
+ extension_entry->offset = rtc::dchecked_cast<uint16_t>(
+ extensions_offset + extensions_size_ + kOneByteHeaderSize);
+ extension_entry->length = rtc::dchecked_cast<uint8_t>(length);
+ extensions_size_ = rtc::dchecked_cast<uint16_t>(new_extensions_size);
// Update header length field.
uint16_t extensions_words = (extensions_size_ + 3) / 4; // Wrap up to 32bit.
@@ -497,8 +500,9 @@ bool Packet::ParseBuffer(const uint8_t* buffer, size_t size) {
}
extensions_size_ += kOneByteHeaderSize;
- extension_entries_[idx].offset = extension_offset + extensions_size_;
- extension_entries_[idx].length = length;
+ extension_entries_[idx].offset =
+ rtc::dchecked_cast<uint16_t>(extension_offset + extensions_size_);
+ extension_entries_[idx].length = rtc::dchecked_cast<uint16_t>(length);
extensions_size_ += length;
}
}
@@ -527,7 +531,7 @@ rtc::ArrayView<const uint8_t> Packet::FindExtension(ExtensionType type) const {
rtc::ArrayView<uint8_t> Packet::AllocateExtension(ExtensionType type,
size_t length) {
- for (size_t i = 0; i < kMaxExtensionHeaders; ++i) {
+ for (int i = 0; i < kMaxExtensionHeaders; ++i) {
if (extension_entries_[i].type == type) {
int extension_id = i + 1;
return AllocateRawExtension(extension_id, length);
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_packet.h ('k') | webrtc/modules/rtp_rtcp/source/rtp_packet_received.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698