From a66cb1237d747ed07deb9933f7d3c3a60d400c18 Mon Sep 17 00:00:00 2001 From: shenweip <1037567878@qq.com> Date: Wed, 16 Sep 2020 14:05:06 +0800 Subject: [PATCH 1/2] Warning fixes. --- GPU/Common/FramebufferManagerCommon.cpp | 2 +- ext/snappy/snappy-stubs-internal.h | 2 +- ext/snappy/snappy.cpp | 34 ++++++++++++------------- ext/xbrz/xbrz.cpp | 2 +- ext/xxhash.h | 2 +- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 3df2eaddfd..93a6c3c2c9 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -1715,7 +1715,7 @@ void FramebufferManagerCommon::SetRenderSize(VirtualFramebuffer *vfb) { force1x = vfb->bufferWidth <= 256 || vfb->bufferHeight <= 128; break; case 3: - force1x = vfb->bufferWidth < 480 || vfb->bufferWidth > 800 || vfb->bufferHeight < 272; // GOW uses ‭864‬x272 + force1x = vfb->bufferWidth < 480 || vfb->bufferWidth > 800 || vfb->bufferHeight < 272; // GOW uses 864x272 break; } diff --git a/ext/snappy/snappy-stubs-internal.h b/ext/snappy/snappy-stubs-internal.h index 4854689d17..48698958e7 100644 --- a/ext/snappy/snappy-stubs-internal.h +++ b/ext/snappy/snappy-stubs-internal.h @@ -137,7 +137,7 @@ static const int64 kint64max = static_cast(0x7FFFFFFFFFFFFFFFLL); // and 32-bit values (not 64-bit); older versions either raise a fatal signal, // do an unaligned read and rotate the words around a bit, or do the reads very // slowly (trip through kernel mode). There's no simple #define that says just -// “ARMv7 or higher”, so we have to filter away all ARMv5 and ARMv6 +// "ARMv7 or higher", so we have to filter away all ARMv5 and ARMv6 // sub-architectures. // // This is a mess, but there's not much we can do about it. diff --git a/ext/snappy/snappy.cpp b/ext/snappy/snappy.cpp index ce1eef4630..cec2860b42 100644 --- a/ext/snappy/snappy.cpp +++ b/ext/snappy/snappy.cpp @@ -384,12 +384,12 @@ static inline char* EmitCopyAtMost64(char* op, size_t offset, size_t len) { if (len_less_than_12 && SNAPPY_PREDICT_TRUE(offset < 2048)) { // offset fits in 11 bits. The 3 highest go in the top of the first byte, // and the rest go in the second byte. - *op++ = COPY_1_BYTE_OFFSET + ((len - 4) << 2) + ((offset >> 3) & 0xe0); + *op++ = (char)(COPY_1_BYTE_OFFSET + ((len - 4) << 2) + ((offset >> 3) & 0xe0)); *op++ = offset & 0xff; } else { // Write 4 bytes, though we only care about 3 of them. The output buffer // is required to have some slack, so the extra byte won't overrun it. - uint32 u = COPY_2_BYTE_OFFSET + ((len - 1) << 2) + (offset << 8); + uint32 u = (uint32)(COPY_2_BYTE_OFFSET + ((len - 1) << 2) + (offset << 8)); LittleEndian::Store32(op, u); op += 3; } @@ -458,7 +458,7 @@ uint32 CalculateTableSize(uint32 input_size) { namespace internal { WorkingMemory::WorkingMemory(size_t input_size) { const size_t max_fragment_size = std::min(input_size, kBlockSize); - const size_t table_size = CalculateTableSize(max_fragment_size); + const size_t table_size = CalculateTableSize((uint32)max_fragment_size); size_ = table_size * sizeof(*table_) + max_fragment_size + MaxCompressedLength(max_fragment_size); mem_ = std::allocator().allocate(size_); @@ -473,9 +473,9 @@ WorkingMemory::~WorkingMemory() { uint16* WorkingMemory::GetHashTable(size_t fragment_size, int* table_size) const { - const size_t htsize = CalculateTableSize(fragment_size); + const size_t htsize = CalculateTableSize((uint32)fragment_size); memset(table_, 0, htsize * sizeof(*table_)); - *table_size = htsize; + *table_size = (int)htsize; return table_; } } // end namespace internal @@ -864,7 +864,7 @@ class SnappyDecompressor { // Long literal. const size_t literal_length_length = literal_length - 60; literal_length = - ExtractLowBytes(LittleEndian::Load32(ip), literal_length_length) + + ExtractLowBytes(LittleEndian::Load32(ip), (int)literal_length_length) + 1; ip += literal_length_length; } @@ -877,7 +877,7 @@ class SnappyDecompressor { size_t n; ip = reader_->Peek(&n); avail = n; - peeked_ = avail; + peeked_ = (uint32)avail; if (avail == 0) return; // Premature end of input ip_limit_ = ip + avail; } @@ -889,7 +889,7 @@ class SnappyDecompressor { } else { const size_t entry = char_table[c]; const size_t trailer = - ExtractLowBytes(LittleEndian::Load32(ip), entry >> 11); + ExtractLowBytes(LittleEndian::Load32(ip), (int)entry >> 11); const size_t length = entry & 0xff; ip += entry >> 11; @@ -915,7 +915,7 @@ bool SnappyDecompressor::RefillTag() { reader_->Skip(peeked_); // All peeked bytes are used up size_t n; ip = reader_->Peek(&n); - peeked_ = n; + peeked_ = (uint32)n; eof_ = (n == 0); if (eof_) return false; ip_limit_ = ip + n; @@ -942,7 +942,7 @@ bool SnappyDecompressor::RefillTag() { size_t length; const char* src = reader_->Peek(&length); if (length == 0) return false; - uint32 to_add = std::min(needed - nbuf, length); + uint32 to_add = std::min(needed - nbuf, (uint32)length); memcpy(scratch_ + nbuf, src, to_add); nbuf += to_add; reader_->Skip(to_add); @@ -972,7 +972,7 @@ static bool InternalUncompress(Source* r, Writer* writer) { uint32 uncompressed_len = 0; if (!decompressor.ReadUncompressedLength(&uncompressed_len)) return false; - return InternalUncompressAllTags(&decompressor, writer, r->Available(), + return InternalUncompressAllTags(&decompressor, writer, (uint32)r->Available(), uncompressed_len); } @@ -1001,7 +1001,7 @@ size_t Compress(Source* reader, Sink* writer) { size_t N = reader->Available(); const size_t uncompressed_size = N; char ulength[Varint::kMax32]; - char* p = Varint::Encode32(ulength, N); + char* p = Varint::Encode32(ulength, (uint32)N); writer->Append(ulength, p-ulength); written += (p - ulength); @@ -1043,7 +1043,7 @@ size_t Compress(Source* reader, Sink* writer) { uint16* table = wmem.GetHashTable(num_to_read, &table_size); // Compress input_fragment and append to dest - const int max_output = MaxCompressedLength(num_to_read); + const int max_output = (int)MaxCompressedLength(num_to_read); // Need a scratch buffer for the output, in case the byte sink doesn't // have room for us directly. @@ -1507,7 +1507,7 @@ class SnappyScatteredWriter { char* const op_end = op_ptr_ + len; // See SnappyArrayWriter::AppendFromSelf for an explanation of // the "offset - 1u" trick. - if (SNAPPY_PREDICT_TRUE(offset - 1u < op_ptr_ - op_base_ && + if (SNAPPY_PREDICT_TRUE(offset - 1u < (size_t)(op_ptr_ - op_base_) && op_end <= op_limit_)) { // Fast path: src and dst in current block. op_ptr_ = IncrementalCopy(op_ptr_ - offset, op_ptr_, op_end, op_limit_); @@ -1540,7 +1540,7 @@ bool SnappyScatteredWriter::SlowAppend(const char* ip, size_t len) { // Make new block size_t bsize = std::min(kBlockSize, expected_ - full_size_); - op_base_ = allocator_.Allocate(bsize); + op_base_ = allocator_.Allocate((int)bsize); op_ptr_ = op_base_; op_limit_ = op_base_ + bsize; blocks_.push_back(op_base_); @@ -1647,13 +1647,13 @@ bool Uncompress(Source* compressed, Sink* uncompressed) { if (allocated_size >= uncompressed_len) { SnappyArrayWriter writer(buf); bool result = InternalUncompressAllTags(&decompressor, &writer, - compressed_len, uncompressed_len); + (uint32)compressed_len, uncompressed_len); uncompressed->Append(buf, writer.Produced()); return result; } else { SnappySinkAllocator allocator(uncompressed); SnappyScatteredWriter writer(allocator); - return InternalUncompressAllTags(&decompressor, &writer, compressed_len, + return InternalUncompressAllTags(&decompressor, &writer, (uint32)compressed_len, uncompressed_len); } } diff --git a/ext/xbrz/xbrz.cpp b/ext/xbrz/xbrz.cpp index 61fa7e3284..dc2feb2ba9 100644 --- a/ext/xbrz/xbrz.cpp +++ b/ext/xbrz/xbrz.cpp @@ -444,7 +444,7 @@ void blendPixel(const Kernel_3x3& ker, return true; //make sure there is no second blending in an adjacent rotation for this pixel: handles insular pixels, mario eyes - if (getTopR(blend) != BLEND_NONE && !eq(e, g)) //but support double-blending for 90° corners + if (getTopR(blend) != BLEND_NONE && !eq(e, g)) //but support double-blending for 90?corners return false; if (getBottomL(blend) != BLEND_NONE && !eq(e, c)) return false; diff --git a/ext/xxhash.h b/ext/xxhash.h index 7fe59d9a3e..1790daf267 100644 --- a/ext/xxhash.h +++ b/ext/xxhash.h @@ -3115,7 +3115,7 @@ XXH3_initCustomSecret_avx512(void* XXH_RESTRICT customSecret, xxh_u64 seed64) int i; for (i=0; i < nbRounds; ++i) { /* GCC has a bug, _mm512_stream_load_si512 accepts 'void*', not 'void const*', - * this will warn "discards ‘const’ qualifier". */ + * this will warn "discards 'const' qualifier". */ union { XXH_ALIGN(64) const __m512i* cp; XXH_ALIGN(64) void* p; From 3788537ddc473d5f433339461a099b3412e95e90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 10 Oct 2020 19:21:12 +0200 Subject: [PATCH 2/2] Fix additional snappy warnings. --- ext/snappy/snappy.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ext/snappy/snappy.cpp b/ext/snappy/snappy.cpp index cec2860b42..74891a6a3f 100644 --- a/ext/snappy/snappy.cpp +++ b/ext/snappy/snappy.cpp @@ -602,7 +602,7 @@ char* CompressFragment(const char* input, assert(candidate >= base_ip); assert(candidate < ip); - table[hash] = ip - base_ip; + table[hash] = (uint16)(ip - base_ip); } while (SNAPPY_PREDICT_TRUE(UNALIGNED_LOAD32(ip) != UNALIGNED_LOAD32(candidate))); @@ -610,7 +610,7 @@ char* CompressFragment(const char* input, // than 4 bytes match. But, prior to the match, input // bytes [next_emit, ip) are unmatched. Emit them as "literal bytes." assert(next_emit + 16 <= ip_end); - op = EmitLiteral(op, next_emit, ip - next_emit); + op = EmitLiteral(op, next_emit, (int)(ip - next_emit)); // Step 3: Call EmitCopy, and then see if another EmitCopy could // be our next move. Repeat until we find no match for the @@ -647,11 +647,11 @@ char* CompressFragment(const char* input, // we also update table[Hash(ip - 1, shift)] and table[Hash(ip, shift)]. input_bytes = GetEightBytesAt(ip - 1); uint32 prev_hash = HashBytes(GetUint32AtOffset(input_bytes, 0), shift); - table[prev_hash] = ip - base_ip - 1; + table[prev_hash] = (uint16)(ip - base_ip - 1); uint32 cur_hash = HashBytes(GetUint32AtOffset(input_bytes, 1), shift); candidate = base_ip + table[cur_hash]; candidate_bytes = UNALIGNED_LOAD32(candidate); - table[cur_hash] = ip - base_ip; + table[cur_hash] = (uint16)(ip - base_ip); } while (GetUint32AtOffset(input_bytes, 1) == candidate_bytes); next_hash = HashBytes(GetUint32AtOffset(input_bytes, 2), shift); @@ -663,7 +663,7 @@ char* CompressFragment(const char* input, // Emit the remaining bytes as a literal if (next_emit < ip_end) { op = EmitLiteral(op, next_emit, - ip_end - next_emit); + (int)(ip_end - next_emit)); } return op; @@ -929,7 +929,7 @@ bool SnappyDecompressor::RefillTag() { assert(needed <= sizeof(scratch_)); // Read more bytes from reader if needed - uint32 nbuf = ip_limit_ - ip; + uint32 nbuf = (uint32)(ip_limit_ - ip); if (nbuf < needed) { // Stitch together bytes from ip and reader to form the word // contents. We store the needed bytes in "scratch_". They @@ -1491,7 +1491,7 @@ class SnappyScatteredWriter { inline bool TryFastAppend(const char* ip, size_t available, size_t length) { char* op = op_ptr_; - const int space_left = op_limit_ - op; + const int space_left = (int)(op_limit_ - op); if (length <= 16 && available >= 16 + kMaximumTagLength && space_left >= 16) { // Fast path, used for the majority (about 95%) of invocations.