From f1ab8fecac43b2ee4243471b2d4150d8f3824300 Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 9 Dec 2018 22:48:47 +0800 Subject: [PATCH] Fix build warning --- trunk/src/core/srs_core.hpp | 2 +- trunk/src/kernel/srs_kernel_utility.cpp | 31 ++++++++++++------------ trunk/src/protocol/srs_protocol_json.cpp | 4 +-- trunk/src/utest/srs_utest_protocol.cpp | 16 ++++++------ 4 files changed, 27 insertions(+), 26 deletions(-) diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 129683acb..bd44bdbdc 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -27,7 +27,7 @@ // current release version #define VERSION_MAJOR 3 #define VERSION_MINOR 0 -#define VERSION_REVISION 44 +#define VERSION_REVISION 45 // generated by configure, only macros. #include diff --git a/trunk/src/kernel/srs_kernel_utility.cpp b/trunk/src/kernel/srs_kernel_utility.cpp index 49596d3e6..acc3147d9 100644 --- a/trunk/src/kernel/srs_kernel_utility.cpp +++ b/trunk/src/kernel/srs_kernel_utility.cpp @@ -76,7 +76,7 @@ srs_error_t srs_avc_nalu_read_uev(SrsBitBuffer* stream, int32_t& v) } v = (1 << leadingZeroBits) - 1; - for (int i = 0; i < leadingZeroBits; i++) { + for (int i = 0; i < (int)leadingZeroBits; i++) { int32_t b = stream->read_bit(); v += b << (leadingZeroBits - 1 - i); } @@ -700,7 +700,7 @@ uint64_t __crc32_reflect(uint64_t data, int width) { uint64_t res = data & 0x01; - for (int i = 0; i < width - 1; i++) { + for (int i = 0; i < (int)width - 1; i++) { data >>= 1; res = (res << 1) | (data & 0x01); } @@ -718,7 +718,7 @@ void __crc32_make_table(uint32_t t[256], uint32_t poly, bool reflect_in) int tbl_idx_width = 8; // table index size. int tbl_width = 0x01 << tbl_idx_width; // table size: 256 - for (int i = 0; i < tbl_width; i++) { + for (int i = 0; i < (int)tbl_width; i++) { uint64_t reg = uint64_t(i); if (reflect_in) { @@ -757,14 +757,14 @@ uint32_t __crc32_table_driven(uint32_t* t, const void* buf, int size, uint32_t p if (!reflect_in) { reg = xor_in; - for (int i = 0; i < size; i++) { + for (int i = 0; i < (int)size; i++) { uint8_t tblidx = (uint8_t)((reg >> (width - tbl_idx_width)) ^ p[i]); reg = t[tblidx] ^ (reg << tbl_idx_width); } } else { reg = previous ^ __crc32_reflect(xor_in, width); - for (int i = 0; i < size; i++) { + for (int i = 0; i < (int)size; i++) { uint8_t tblidx = (uint8_t)(reg ^ p[i]); reg = t[tblidx] ^ (reg >> tbl_idx_width); } @@ -870,7 +870,7 @@ srs_error_t srs_av_base64_decode(string cipher, string& plaintext) uint8_t decodeMap[256]; memset(decodeMap, 0xff, sizeof(decodeMap)); - for (int i = 0; i < encoder.length(); i++) { + for (int i = 0; i < (int)encoder.length(); i++) { decodeMap[(uint8_t)encoder.at(i)] = uint8_t(i); } @@ -880,19 +880,20 @@ srs_error_t srs_av_base64_decode(string cipher, string& plaintext) int si = 0; // skip over newlines - for (; si < cipher.length() && (cipher.at(si) == '\n' || cipher.at(si) == '\r'); si++) { + for (; si < (int)cipher.length() && (cipher.at(si) == '\n' || cipher.at(si) == '\r'); si++) { } - for (bool end = false; si < cipher.length() && !end;) { + for (bool end = false; si < (int)cipher.length() && !end;) { // Decode quantum using the base64 alphabet uint8_t dbuf[4]; memset(dbuf, 0x00, sizeof(dbuf)); int dinc = 3; int dlen = 4; + srs_assert(dinc > 0); - for (int j = 0; j < sizeof(dbuf); j++) { - if (si == cipher.length()) { + for (int j = 0; j < (int)sizeof(dbuf); j++) { + if (si == (int)cipher.length()) { if (padding != -1 || j < 2) { return srs_error_new(ERROR_BASE64_DECODE, "corrupt input at %d", si); } @@ -907,7 +908,7 @@ srs_error_t srs_av_base64_decode(string cipher, string& plaintext) si++; // skip over newlines - for (; si < cipher.length() && (cipher.at(si) == '\n' || cipher.at(si) == '\r'); si++) { + for (; si < (int)cipher.length() && (cipher.at(si) == '\n' || cipher.at(si) == '\r'); si++) { } if (in == padding) { @@ -919,7 +920,7 @@ srs_error_t srs_av_base64_decode(string cipher, string& plaintext) return srs_error_new(ERROR_BASE64_DECODE, "corrupt input at %d", si); case 2: // "==" is expected, the first "=" is already consumed. - if (si == cipher.length()) { + if (si == (int)cipher.length()) { return srs_error_new(ERROR_BASE64_DECODE, "corrupt input at %d", si); } if (cipher.at(si) != padding) { @@ -929,11 +930,11 @@ srs_error_t srs_av_base64_decode(string cipher, string& plaintext) si++; // skip over newlines - for (; si < cipher.length() && (cipher.at(si) == '\n' || cipher.at(si) == '\r'); si++) { + for (; si < (int)cipher.length() && (cipher.at(si) == '\n' || cipher.at(si) == '\r'); si++) { } } - if (si < cipher.length()) { + if (si < (int)cipher.length()) { // trailing garbage err = srs_error_new(ERROR_BASE64_DECODE, "corrupt input at %d", si); } @@ -1013,7 +1014,7 @@ int srs_hex_to_data(uint8_t* data, const char* p, int size) return -1; } - for (int i = 0; i < size / 2; i++) { + for (int i = 0; i < (int)size / 2; i++) { uint8_t a = srs_from_hex_char(p[i*2]); if (a == (uint8_t)-1) { return -1; diff --git a/trunk/src/protocol/srs_protocol_json.cpp b/trunk/src/protocol/srs_protocol_json.cpp index 287c36cb6..e25c19c12 100644 --- a/trunk/src/protocol/srs_protocol_json.cpp +++ b/trunk/src/protocol/srs_protocol_json.cpp @@ -1700,7 +1700,7 @@ SrsJsonAny* srs_json_parse_tree(json_value* node) return SrsJsonAny::boolean(node->u.boolean != 0); case json_object: { SrsJsonObject* obj = SrsJsonAny::object(); - for (int i = 0; i < node->u.object.length; i++) { + for (int i = 0; i < (int)node->u.object.length; i++) { json_object_entry& entry = node->u.object.values[i]; SrsJsonAny* value = srs_json_parse_tree(entry.value); @@ -1715,7 +1715,7 @@ SrsJsonAny* srs_json_parse_tree(json_value* node) } case json_array: { SrsJsonArray* arr = SrsJsonAny::array(); - for (int i = 0; i < node->u.array.length; i++) { + for (int i = 0; i < (int)node->u.array.length; i++) { json_value* p = node->u.array.values[i]; SrsJsonAny* value = srs_json_parse_tree(p); diff --git a/trunk/src/utest/srs_utest_protocol.cpp b/trunk/src/utest/srs_utest_protocol.cpp index bf996e952..80dd435c0 100644 --- a/trunk/src/utest/srs_utest_protocol.cpp +++ b/trunk/src/utest/srs_utest_protocol.cpp @@ -4862,14 +4862,14 @@ VOID TEST(ProtocolStackTest, ProtocolSendSrsFMLEStartResPacket) args->set("start" , SrsAmf0Any::number(0)); EXPECT_TRUE(ERROR_SUCCESS == proto.send_and_free_packet(pkt, 0)); - char buf[] = { + uint8_t buf[] = { 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x14, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x09, 0x46, 0x4d, 0x4c, 0x45, 0x53, 0x74, 0x61, 0x72, 0x74, 0x00, 0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x06 }; - EXPECT_TRUE(srs_bytes_equals(bio.out_buffer.bytes(), buf, sizeof(buf))); + EXPECT_TRUE(srs_bytes_equals(bio.out_buffer.bytes(), (char*)buf, sizeof(buf))); } /** @@ -4887,7 +4887,7 @@ VOID TEST(ProtocolStackTest, ProtocolSendSrsPublishPacket) pkt->type = "live"; EXPECT_TRUE(ERROR_SUCCESS == proto.send_and_free_packet(pkt, 0)); - char buf[] = { + uint8_t buf[] = { 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x14, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x07, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x00, 0x00, @@ -4896,7 +4896,7 @@ VOID TEST(ProtocolStackTest, ProtocolSendSrsPublishPacket) 0x74, 0x72, 0x65, 0x61, 0x6d, 0x02, 0x00, 0x04, 0x6c, 0x69, 0x76, 0x65 }; - EXPECT_TRUE(srs_bytes_equals(bio.out_buffer.bytes(), buf, sizeof(buf))); + EXPECT_TRUE(srs_bytes_equals(bio.out_buffer.bytes(), (char*)buf, sizeof(buf))); } /** @@ -5097,7 +5097,7 @@ VOID TEST(ProtocolStackTest, ProtocolSendSrsOnMetaDataPacket) pkt->metadata = args; EXPECT_TRUE(ERROR_SUCCESS == proto.send_and_free_packet(pkt, 0)); - char buf[] = { + uint8_t buf[] = { 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x12, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x0a, 0x6f, 0x6e, 0x4d, 0x65, 0x74, 0x61, 0x44, 0x61, 0x74, @@ -5107,7 +5107,7 @@ VOID TEST(ProtocolStackTest, ProtocolSendSrsOnMetaDataPacket) 0x68, 0x74, 0x00, 0x40, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09 }; - EXPECT_TRUE(srs_bytes_equals(bio.out_buffer.bytes(), buf, sizeof(buf))); + EXPECT_TRUE(srs_bytes_equals(bio.out_buffer.bytes(), (char*)buf, sizeof(buf))); } /** @@ -5122,11 +5122,11 @@ VOID TEST(ProtocolStackTest, ProtocolSendSrsSetWindowAckSizePacket) pkt->ackowledgement_window_size = 102400; EXPECT_TRUE(ERROR_SUCCESS == proto.send_and_free_packet(pkt, 0)); - char buf[] = { + uint8_t buf[] = { 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x90, 0x00 }; - EXPECT_TRUE(srs_bytes_equals(bio.out_buffer.bytes(), buf, sizeof(buf))); + EXPECT_TRUE(srs_bytes_equals(bio.out_buffer.bytes(), (char*)buf, sizeof(buf))); } /**