From dd4e61435aa91c89b1efc083c905f4376ef70aa9 Mon Sep 17 00:00:00 2001 From: avi Date: Tue, 8 Dec 2015 16:44:49 -0800 Subject: Remove kint64max. BUG=138542,488550 Review URL: https://codereview.chromium.org/1498003003 Cr-Commit-Position: refs/heads/master@{#363854} --- media/formats/webm/webm_parser.cc | 90 +++++++++------- media/formats/webm/webm_parser.h | 28 +++-- media/formats/webm/webm_parser_unittest.cc | 158 ++++++++++++++--------------- 3 files changed, 147 insertions(+), 129 deletions(-) (limited to 'media/formats') diff --git a/media/formats/webm/webm_parser.cc b/media/formats/webm/webm_parser.cc index fda287c..6929a83 100644 --- a/media/formats/webm/webm_parser.cc +++ b/media/formats/webm/webm_parser.cc @@ -12,6 +12,7 @@ // http://wiki.webmproject.org/encryption/webm-encryption-rfc #include +#include #include "base/logging.h" #include "base/numerics/safe_conversions.h" @@ -423,9 +424,11 @@ static const ListElementInfo kListElementInfo[] = { // element size fields and is false for ID field values. // // Returns: The number of bytes parsed on success. -1 on error. -static int ParseWebMElementHeaderField(const uint8* buf, int size, - int max_bytes, bool mask_first_byte, - int64* num) { +static int ParseWebMElementHeaderField(const uint8_t* buf, + int size, + int max_bytes, + bool mask_first_byte, + int64_t* num) { DCHECK(buf); DCHECK(num); @@ -436,7 +439,7 @@ static int ParseWebMElementHeaderField(const uint8* buf, int size, return 0; int mask = 0x80; - uint8 ch = buf[0]; + uint8_t ch = buf[0]; int extra_bytes = -1; bool all_ones = false; for (int i = 0; i < max_bytes; ++i) { @@ -466,13 +469,15 @@ static int ParseWebMElementHeaderField(const uint8* buf, int size, } if (all_ones) - *num = kint64max; + *num = std::numeric_limits::max(); return bytes_used; } -int WebMParseElementHeader(const uint8* buf, int size, - int* id, int64* element_size) { +int WebMParseElementHeader(const uint8_t* buf, + int size, + int* id, + int64_t* element_size) { DCHECK(buf); DCHECK_GE(size, 0); DCHECK(id); @@ -481,13 +486,13 @@ int WebMParseElementHeader(const uint8* buf, int size, if (size == 0) return 0; - int64 tmp = 0; + int64_t tmp = 0; int num_id_bytes = ParseWebMElementHeaderField(buf, size, 4, false, &tmp); if (num_id_bytes <= 0) return num_id_bytes; - if (tmp == kint64max) + if (tmp == std::numeric_limits::max()) tmp = kWebMReservedId; *id = static_cast(tmp); @@ -499,7 +504,7 @@ int WebMParseElementHeader(const uint8* buf, int size, if (num_size_bytes <= 0) return num_size_bytes; - if (tmp == kint64max) + if (tmp == std::numeric_limits::max()) tmp = kWebMUnknownSize; *element_size = tmp; @@ -543,19 +548,22 @@ static int FindListLevel(int id) { return -1; } -static int ParseUInt(const uint8* buf, int size, int id, +static int ParseUInt(const uint8_t* buf, + int size, + int id, WebMParserClient* client) { if ((size <= 0) || (size > 8)) return -1; // Read in the big-endian integer. - uint64 value = 0; + uint64_t value = 0; for (int i = 0; i < size; ++i) value = (value << 8) | buf[i]; - // We use int64 in place of uint64 everywhere for convenience. See this bug + // We use int64_t in place of uint64_t everywhere for convenience. See this + // bug // for more details: http://crbug.com/366750#c3 - if (!base::IsValueInRangeForNumericType(value)) + if (!base::IsValueInRangeForNumericType(value)) return -1; if (!client->OnUInt(id, value)) @@ -564,16 +572,17 @@ static int ParseUInt(const uint8* buf, int size, int id, return size; } -static int ParseFloat(const uint8* buf, int size, int id, +static int ParseFloat(const uint8_t* buf, + int size, + int id, WebMParserClient* client) { - if ((size != 4) && (size != 8)) return -1; double value = -1; // Read the bytes from big-endian form into a native endian integer. - int64 tmp = 0; + int64_t tmp = 0; for (int i = 0; i < size; ++i) tmp = (tmp << 8) | buf[i]; @@ -581,14 +590,14 @@ static int ParseFloat(const uint8* buf, int size, int id, // number. if (size == 4) { union { - int32 src; + int32_t src; float dst; } tmp2; - tmp2.src = static_cast(tmp); + tmp2.src = static_cast(tmp); value = tmp2.dst; } else if (size == 8) { union { - int64 src; + int64_t src; double dst; } tmp2; tmp2.src = tmp; @@ -603,21 +612,28 @@ static int ParseFloat(const uint8* buf, int size, int id, return size; } -static int ParseBinary(const uint8* buf, int size, int id, +static int ParseBinary(const uint8_t* buf, + int size, + int id, WebMParserClient* client) { return client->OnBinary(id, buf, size) ? size : -1; } -static int ParseString(const uint8* buf, int size, int id, +static int ParseString(const uint8_t* buf, + int size, + int id, WebMParserClient* client) { - const uint8* end = static_cast(memchr(buf, '\0', size)); + const uint8_t* end = static_cast(memchr(buf, '\0', size)); int length = (end != NULL) ? static_cast(end - buf) : size; std::string str(reinterpret_cast(buf), length); return client->OnString(id, str) ? size : -1; } -static int ParseNonListElement(ElementType type, int id, int64 element_size, - const uint8* buf, int size, +static int ParseNonListElement(ElementType type, + int id, + int64_t element_size, + const uint8_t* buf, + int size, WebMParserClient* client) { DCHECK_GE(size, element_size); @@ -664,7 +680,7 @@ bool WebMParserClient::OnListEnd(int id) { return false; } -bool WebMParserClient::OnUInt(int id, int64 val) { +bool WebMParserClient::OnUInt(int id, int64_t val) { DVLOG(1) << "Unexpected unsigned integer element with ID " << std::hex << id; return false; } @@ -674,7 +690,7 @@ bool WebMParserClient::OnFloat(int id, double val) { return false; } -bool WebMParserClient::OnBinary(int id, const uint8* data, int size) { +bool WebMParserClient::OnBinary(int id, const uint8_t* data, int size) { DVLOG(1) << "Unexpected binary element with ID " << std::hex << id; return false; } @@ -700,7 +716,7 @@ void WebMListParser::Reset() { list_state_stack_.clear(); } -int WebMListParser::Parse(const uint8* buf, int size) { +int WebMListParser::Parse(const uint8_t* buf, int size) { DCHECK(buf); if (size < 0 || state_ == PARSE_ERROR || state_ == DONE_PARSING_LIST) @@ -709,13 +725,13 @@ int WebMListParser::Parse(const uint8* buf, int size) { if (size == 0) return 0; - const uint8* cur = buf; + const uint8_t* cur = buf; int cur_size = size; int bytes_parsed = 0; while (cur_size > 0 && state_ != PARSE_ERROR && state_ != DONE_PARSING_LIST) { int element_id = 0; - int64 element_size = 0; + int64_t element_size = 0; int result = WebMParseElementHeader(cur, cur_size, &element_id, &element_size); @@ -749,7 +765,7 @@ int WebMListParser::Parse(const uint8* buf, int size) { case INSIDE_LIST: { int header_size = result; - const uint8* element_data = cur + header_size; + const uint8_t* element_data = cur + header_size; int element_data_size = cur_size - header_size; if (element_size < element_data_size) @@ -793,8 +809,10 @@ void WebMListParser::ChangeState(State new_state) { } int WebMListParser::ParseListElement(int header_size, - int id, int64 element_size, - const uint8* data, int size) { + int id, + int64_t element_size, + const uint8_t* data, + int size) { DCHECK_GT(list_state_stack_.size(), 0u); ListState& list_state = list_state_stack_.back(); @@ -827,7 +845,7 @@ int WebMListParser::ParseListElement(int header_size, } // Make sure the whole element can fit inside the current list. - int64 total_element_size = header_size + element_size; + int64_t total_element_size = header_size + element_size; if (list_state.size_ != kWebMUnknownSize && list_state.size_ < list_state.bytes_parsed_ + total_element_size) { return -1; @@ -869,7 +887,7 @@ int WebMListParser::ParseListElement(int header_size, return result; } -bool WebMListParser::OnListStart(int id, int64 size) { +bool WebMListParser::OnListStart(int id, int64_t size) { const ListElementInfo* element_info = FindListInfo(id); if (!element_info) return false; @@ -907,7 +925,7 @@ bool WebMListParser::OnListEnd() { int lists_ended = 0; for (; !list_state_stack_.empty(); ++lists_ended) { const ListState& list_state = list_state_stack_.back(); - int64 bytes_parsed = list_state.bytes_parsed_; + int64_t bytes_parsed = list_state.bytes_parsed_; int id = list_state.id_; if (bytes_parsed != list_state.size_) diff --git a/media/formats/webm/webm_parser.h b/media/formats/webm/webm_parser.h index 854db68..3af81ea 100644 --- a/media/formats/webm/webm_parser.h +++ b/media/formats/webm/webm_parser.h @@ -5,10 +5,12 @@ #ifndef MEDIA_FORMATS_WEBM_WEBM_PARSER_H_ #define MEDIA_FORMATS_WEBM_WEBM_PARSER_H_ +#include + #include #include -#include "base/basictypes.h" +#include "base/macros.h" #include "media/base/media_export.h" namespace media { @@ -31,9 +33,9 @@ class MEDIA_EXPORT WebMParserClient { virtual WebMParserClient* OnListStart(int id); virtual bool OnListEnd(int id); - virtual bool OnUInt(int id, int64 val); + virtual bool OnUInt(int id, int64_t val); virtual bool OnFloat(int id, double val); - virtual bool OnBinary(int id, const uint8* data, int size); + virtual bool OnBinary(int id, const uint8_t* data, int size); virtual bool OnString(int id, const std::string& str); protected: @@ -64,7 +66,7 @@ class MEDIA_EXPORT WebMListParser { // Returns < 0 if the parse fails. // Returns 0 if more data is needed. // Returning > 0 indicates success & the number of bytes parsed. - int Parse(const uint8* buf, int size); + int Parse(const uint8_t* buf, int size); // Returns true if the entire list has been parsed. bool IsParsingComplete() const; @@ -79,8 +81,8 @@ class MEDIA_EXPORT WebMListParser { struct ListState { int id_; - int64 size_; - int64 bytes_parsed_; + int64_t size_; + int64_t bytes_parsed_; const ListElementInfo* element_info_; WebMParserClient* client_; }; @@ -100,8 +102,10 @@ class MEDIA_EXPORT WebMListParser { // Returns 0 if more data is needed. // Returning > 0 indicates success & the number of bytes parsed. int ParseListElement(int header_size, - int id, int64 element_size, - const uint8* data, int size); + int id, + int64_t element_size, + const uint8_t* data, + int size); // Called when starting to parse a new list. // @@ -111,7 +115,7 @@ class MEDIA_EXPORT WebMListParser { // // Returns true if this list can be started in the current context. False // if starting this list causes some sort of parse error. - bool OnListStart(int id, int64 size); + bool OnListStart(int id, int64_t size); // Called when the end of the current list has been reached. This may also // signal the end of the current list's ancestors if the current list happens @@ -150,8 +154,10 @@ class MEDIA_EXPORT WebMListParser { // |*id| contains the element ID on success and is undefined otherwise. // |*element_size| contains the element size on success and is undefined // otherwise. -int MEDIA_EXPORT WebMParseElementHeader(const uint8* buf, int size, - int* id, int64* element_size); +int MEDIA_EXPORT WebMParseElementHeader(const uint8_t* buf, + int size, + int* id, + int64_t* element_size); } // namespace media diff --git a/media/formats/webm/webm_parser_unittest.cc b/media/formats/webm/webm_parser_unittest.cc index a1249e8..26f5f4b 100644 --- a/media/formats/webm/webm_parser_unittest.cc +++ b/media/formats/webm/webm_parser_unittest.cc @@ -25,9 +25,9 @@ class MockWebMParserClient : public WebMParserClient { // WebMParserClient methods. MOCK_METHOD1(OnListStart, WebMParserClient*(int)); MOCK_METHOD1(OnListEnd, bool(int)); - MOCK_METHOD2(OnUInt, bool(int, int64)); + MOCK_METHOD2(OnUInt, bool(int, int64_t)); MOCK_METHOD2(OnFloat, bool(int, double)); - MOCK_METHOD3(OnBinary, bool(int, const uint8*, int)); + MOCK_METHOD3(OnBinary, bool(int, const uint8_t*, int)); MOCK_METHOD2(OnString, bool(int, const std::string&)); }; @@ -41,7 +41,7 @@ static scoped_ptr CreateCluster(int block_count) { cb.SetClusterTimecode(0); for (int i = 0; i < block_count; i++) { - uint8 data[] = { 0x00 }; + uint8_t data[] = {0x00}; cb.AddSimpleBlock(0, i, 0, data, sizeof(data)); } @@ -67,8 +67,8 @@ static void CreateClusterExpectations(int block_count, } TEST_F(WebMParserTest, EmptyCluster) { - const uint8 kEmptyCluster[] = { - 0x1F, 0x43, 0xB6, 0x75, 0x80 // CLUSTER (size = 0) + const uint8_t kEmptyCluster[] = { + 0x1F, 0x43, 0xB6, 0x75, 0x80 // CLUSTER (size = 0) }; int size = sizeof(kEmptyCluster); @@ -82,9 +82,9 @@ TEST_F(WebMParserTest, EmptyCluster) { } TEST_F(WebMParserTest, EmptyClusterInSegment) { - const uint8 kBuffer[] = { - 0x18, 0x53, 0x80, 0x67, 0x85, // SEGMENT (size = 5) - 0x1F, 0x43, 0xB6, 0x75, 0x80, // CLUSTER (size = 0) + const uint8_t kBuffer[] = { + 0x18, 0x53, 0x80, 0x67, 0x85, // SEGMENT (size = 5) + 0x1F, 0x43, 0xB6, 0x75, 0x80, // CLUSTER (size = 0) }; int size = sizeof(kBuffer); @@ -102,9 +102,9 @@ TEST_F(WebMParserTest, EmptyClusterInSegment) { // Test the case where a non-list child element has a size // that is beyond the end of the parent. TEST_F(WebMParserTest, ChildNonListLargerThanParent) { - const uint8 kBuffer[] = { - 0x1F, 0x43, 0xB6, 0x75, 0x81, // CLUSTER (size = 1) - 0xE7, 0x81, 0x01, // Timecode (size=1, value=1) + const uint8_t kBuffer[] = { + 0x1F, 0x43, 0xB6, 0x75, 0x81, // CLUSTER (size = 1) + 0xE7, 0x81, 0x01, // Timecode (size=1, value=1) }; InSequence s; @@ -118,9 +118,10 @@ TEST_F(WebMParserTest, ChildNonListLargerThanParent) { // Test the case where a list child element has a size // that is beyond the end of the parent. TEST_F(WebMParserTest, ChildListLargerThanParent) { - const uint8 kBuffer[] = { - 0x18, 0x53, 0x80, 0x67, 0x85, // SEGMENT (size = 5) - 0x1F, 0x43, 0xB6, 0x75, 0x81, 0x11 // CLUSTER (size = 1) + const uint8_t kBuffer[] = { + 0x18, 0x53, 0x80, 0x67, 0x85, // SEGMENT (size = 5) + 0x1F, 0x43, 0xB6, 0x75, 0x81, + 0x11 // CLUSTER (size = 1) }; InSequence s; @@ -133,8 +134,8 @@ TEST_F(WebMParserTest, ChildListLargerThanParent) { // Expecting to parse a Cluster, but get a Segment. TEST_F(WebMParserTest, ListIdDoesNotMatch) { - const uint8 kBuffer[] = { - 0x18, 0x53, 0x80, 0x67, 0x80, // SEGMENT (size = 0) + const uint8_t kBuffer[] = { + 0x18, 0x53, 0x80, 0x67, 0x80, // SEGMENT (size = 0) }; WebMListParser parser(kWebMIdCluster, &client_); @@ -143,9 +144,9 @@ TEST_F(WebMParserTest, ListIdDoesNotMatch) { } TEST_F(WebMParserTest, InvalidElementInList) { - const uint8 kBuffer[] = { - 0x18, 0x53, 0x80, 0x67, 0x82, // SEGMENT (size = 2) - 0xAE, 0x80, // TrackEntry (size = 0) + const uint8_t kBuffer[] = { + 0x18, 0x53, 0x80, 0x67, 0x82, // SEGMENT (size = 2) + 0xAE, 0x80, // TrackEntry (size = 0) }; InSequence s; @@ -159,9 +160,9 @@ TEST_F(WebMParserTest, InvalidElementInList) { // Test specific case of InvalidElementInList to verify EBMLHEADER within // known-sized cluster causes parse error. TEST_F(WebMParserTest, InvalidEBMLHeaderInCluster) { - const uint8 kBuffer[] = { - 0x1F, 0x43, 0xB6, 0x75, 0x85, // CLUSTER (size = 5) - 0x1A, 0x45, 0xDF, 0xA3, 0x80, // EBMLHEADER (size = 0) + const uint8_t kBuffer[] = { + 0x1F, 0x43, 0xB6, 0x75, 0x85, // CLUSTER (size = 5) + 0x1A, 0x45, 0xDF, 0xA3, 0x80, // EBMLHEADER (size = 0) }; InSequence s; @@ -174,9 +175,11 @@ TEST_F(WebMParserTest, InvalidEBMLHeaderInCluster) { // Verify that EBMLHEADER ends a preceding "unknown"-sized CLUSTER. TEST_F(WebMParserTest, UnknownSizeClusterFollowedByEBMLHeader) { - const uint8 kBuffer[] = { - 0x1F, 0x43, 0xB6, 0x75, 0xFF, // CLUSTER (size = unknown; really 0 due to:) - 0x1A, 0x45, 0xDF, 0xA3, 0x80, // EBMLHEADER (size = 0) + const uint8_t kBuffer[] = { + 0x1F, 0x43, 0xB6, + 0x75, 0xFF, // CLUSTER (size = unknown; really 0 due to:) + 0x1A, 0x45, 0xDF, + 0xA3, 0x80, // EBMLHEADER (size = 0) }; InSequence s; @@ -191,13 +194,13 @@ TEST_F(WebMParserTest, UnknownSizeClusterFollowedByEBMLHeader) { } TEST_F(WebMParserTest, VoidAndCRC32InList) { - const uint8 kBuffer[] = { - 0x18, 0x53, 0x80, 0x67, 0x99, // SEGMENT (size = 25) - 0xEC, 0x83, 0x00, 0x00, 0x00, // Void (size = 3) - 0xBF, 0x83, 0x00, 0x00, 0x00, // CRC32 (size = 3) - 0x1F, 0x43, 0xB6, 0x75, 0x8A, // CLUSTER (size = 10) - 0xEC, 0x83, 0x00, 0x00, 0x00, // Void (size = 3) - 0xBF, 0x83, 0x00, 0x00, 0x00, // CRC32 (size = 3) + const uint8_t kBuffer[] = { + 0x18, 0x53, 0x80, 0x67, 0x99, // SEGMENT (size = 25) + 0xEC, 0x83, 0x00, 0x00, 0x00, // Void (size = 3) + 0xBF, 0x83, 0x00, 0x00, 0x00, // CRC32 (size = 3) + 0x1F, 0x43, 0xB6, 0x75, 0x8A, // CLUSTER (size = 10) + 0xEC, 0x83, 0x00, 0x00, 0x00, // Void (size = 3) + 0xBF, 0x83, 0x00, 0x00, 0x00, // CRC32 (size = 3) }; int size = sizeof(kBuffer); @@ -226,7 +229,7 @@ TEST_F(WebMParserTest, ParseListElementWithMultipleCalls) { scoped_ptr cluster(CreateCluster(kBlockCount)); CreateClusterExpectations(kBlockCount, true, &client_); - const uint8* data = cluster->data(); + const uint8_t* data = cluster->data(); int size = cluster->size(); int default_parse_size = 3; WebMListParser parser(kWebMIdCluster, &client_); @@ -283,13 +286,13 @@ TEST_F(WebMParserTest, Reset) { // Test the case where multiple clients are used for different lists. TEST_F(WebMParserTest, MultipleClients) { - const uint8 kBuffer[] = { - 0x18, 0x53, 0x80, 0x67, 0x94, // SEGMENT (size = 20) - 0x16, 0x54, 0xAE, 0x6B, 0x85, // TRACKS (size = 5) - 0xAE, 0x83, // TRACKENTRY (size = 3) - 0xD7, 0x81, 0x01, // TRACKNUMBER (size = 1) - 0x1F, 0x43, 0xB6, 0x75, 0x85, // CLUSTER (size = 5) - 0xEC, 0x83, 0x00, 0x00, 0x00, // Void (size = 3) + const uint8_t kBuffer[] = { + 0x18, 0x53, 0x80, 0x67, 0x94, // SEGMENT (size = 20) + 0x16, 0x54, 0xAE, 0x6B, 0x85, // TRACKS (size = 5) + 0xAE, 0x83, // TRACKENTRY (size = 3) + 0xD7, 0x81, 0x01, // TRACKNUMBER (size = 1) + 0x1F, 0x43, 0xB6, 0x75, 0x85, // CLUSTER (size = 5) + 0xEC, 0x83, 0x00, 0x00, 0x00, // Void (size = 3) }; int size = sizeof(kBuffer); @@ -315,9 +318,9 @@ TEST_F(WebMParserTest, MultipleClients) { // Test the case where multiple clients are used for different lists. TEST_F(WebMParserTest, InvalidClient) { - const uint8 kBuffer[] = { - 0x18, 0x53, 0x80, 0x67, 0x85, // SEGMENT (size = 20) - 0x16, 0x54, 0xAE, 0x6B, 0x80, // TRACKS (size = 5) + const uint8_t kBuffer[] = { + 0x18, 0x53, 0x80, 0x67, 0x85, // SEGMENT (size = 20) + 0x16, 0x54, 0xAE, 0x6B, 0x80, // TRACKS (size = 5) }; InSequence s; @@ -329,20 +332,16 @@ TEST_F(WebMParserTest, InvalidClient) { } TEST_F(WebMParserTest, ReservedIds) { - const uint8 k1ByteReservedId[] = { 0xFF, 0x81 }; - const uint8 k2ByteReservedId[] = { 0x7F, 0xFF, 0x81 }; - const uint8 k3ByteReservedId[] = { 0x3F, 0xFF, 0xFF, 0x81 }; - const uint8 k4ByteReservedId[] = { 0x1F, 0xFF, 0xFF, 0xFF, 0x81 }; - const uint8* kBuffers[] = { - k1ByteReservedId, - k2ByteReservedId, - k3ByteReservedId, - k4ByteReservedId - }; + const uint8_t k1ByteReservedId[] = {0xFF, 0x81}; + const uint8_t k2ByteReservedId[] = {0x7F, 0xFF, 0x81}; + const uint8_t k3ByteReservedId[] = {0x3F, 0xFF, 0xFF, 0x81}; + const uint8_t k4ByteReservedId[] = {0x1F, 0xFF, 0xFF, 0xFF, 0x81}; + const uint8_t* kBuffers[] = {k1ByteReservedId, k2ByteReservedId, + k3ByteReservedId, k4ByteReservedId}; for (size_t i = 0; i < arraysize(kBuffers); i++) { int id; - int64 element_size; + int64_t element_size; int buffer_size = 2 + i; EXPECT_EQ(buffer_size, WebMParseElementHeader(kBuffers[i], buffer_size, &id, &element_size)); @@ -352,31 +351,25 @@ TEST_F(WebMParserTest, ReservedIds) { } TEST_F(WebMParserTest, ReservedSizes) { - const uint8 k1ByteReservedSize[] = { 0xA3, 0xFF }; - const uint8 k2ByteReservedSize[] = { 0xA3, 0x7F, 0xFF }; - const uint8 k3ByteReservedSize[] = { 0xA3, 0x3F, 0xFF, 0xFF }; - const uint8 k4ByteReservedSize[] = { 0xA3, 0x1F, 0xFF, 0xFF, 0xFF }; - const uint8 k5ByteReservedSize[] = { 0xA3, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF }; - const uint8 k6ByteReservedSize[] = { 0xA3, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF }; - const uint8 k7ByteReservedSize[] = { 0xA3, 0x03, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF }; - const uint8 k8ByteReservedSize[] = { 0xA3, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF }; - const uint8* kBuffers[] = { - k1ByteReservedSize, - k2ByteReservedSize, - k3ByteReservedSize, - k4ByteReservedSize, - k5ByteReservedSize, - k6ByteReservedSize, - k7ByteReservedSize, - k8ByteReservedSize - }; + const uint8_t k1ByteReservedSize[] = {0xA3, 0xFF}; + const uint8_t k2ByteReservedSize[] = {0xA3, 0x7F, 0xFF}; + const uint8_t k3ByteReservedSize[] = {0xA3, 0x3F, 0xFF, 0xFF}; + const uint8_t k4ByteReservedSize[] = {0xA3, 0x1F, 0xFF, 0xFF, 0xFF}; + const uint8_t k5ByteReservedSize[] = {0xA3, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF}; + const uint8_t k6ByteReservedSize[] = {0xA3, 0x07, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF}; + const uint8_t k7ByteReservedSize[] = {0xA3, 0x03, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF}; + const uint8_t k8ByteReservedSize[] = {0xA3, 0x01, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF}; + const uint8_t* kBuffers[] = {k1ByteReservedSize, k2ByteReservedSize, + k3ByteReservedSize, k4ByteReservedSize, + k5ByteReservedSize, k6ByteReservedSize, + k7ByteReservedSize, k8ByteReservedSize}; for (size_t i = 0; i < arraysize(kBuffers); i++) { int id; - int64 element_size; + int64_t element_size; int buffer_size = 2 + i; EXPECT_EQ(buffer_size, WebMParseElementHeader(kBuffers[i], buffer_size, &id, &element_size)); @@ -386,12 +379,13 @@ TEST_F(WebMParserTest, ReservedSizes) { } TEST_F(WebMParserTest, ZeroPaddedStrings) { - const uint8 kBuffer[] = { - 0x1A, 0x45, 0xDF, 0xA3, 0x91, // EBMLHEADER (size = 17) - 0x42, 0x82, 0x80, // DocType (size = 0) - 0x42, 0x82, 0x81, 0x00, // DocType (size = 1) "" - 0x42, 0x82, 0x81, 'a', // DocType (size = 1) "a" - 0x42, 0x82, 0x83, 'a', 0x00, 0x00 // DocType (size = 3) "a" + const uint8_t kBuffer[] = { + 0x1A, 0x45, 0xDF, 0xA3, 0x91, // EBMLHEADER (size = 17) + 0x42, 0x82, 0x80, // DocType (size = 0) + 0x42, 0x82, 0x81, 0x00, // DocType (size = 1) "" + 0x42, 0x82, 0x81, 'a', // DocType (size = 1) "a" + 0x42, 0x82, 0x83, 'a', 0x00, + 0x00 // DocType (size = 3) "a" }; int size = sizeof(kBuffer); -- cgit v1.1