diff options
author | Wei Li <weili@chromium.org> | 2016-03-28 10:33:33 -0700 |
---|---|---|
committer | Wei Li <weili@chromium.org> | 2016-03-28 10:33:33 -0700 |
commit | 8940993efffaaf432320509555dc61122b8b72b2 (patch) | |
tree | 2e9c42a78d96061ae06ee052e8a274ccfb8fcec7 /core/fxcodec | |
parent | b5e8f14e3eefc5da995b332788d3203cee204883 (diff) | |
download | pdfium-8940993efffaaf432320509555dc61122b8b72b2.tar.xz |
Reduce signed/unsigned comparison warnings
The warnings generated by Clang. This is part 1 for some simple cases.
BUG=pdfium:29
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1840483003 .
Diffstat (limited to 'core/fxcodec')
-rw-r--r-- | core/fxcodec/codec/fx_codec_flate.cpp | 5 | ||||
-rw-r--r-- | core/fxcodec/jbig2/JBig2_Context.cpp | 18 |
2 files changed, 11 insertions, 12 deletions
diff --git a/core/fxcodec/codec/fx_codec_flate.cpp b/core/fxcodec/codec/fx_codec_flate.cpp index e69c017ee7..6961dcccb3 100644 --- a/core/fxcodec/codec/fx_codec_flate.cpp +++ b/core/fxcodec/codec/fx_codec_flate.cpp @@ -9,6 +9,7 @@ #include <algorithm> #include <memory> +#include "core/fxcrt/include/fx_ext.h" #include "core/include/fxcodec/fx_codec.h" #include "core/include/fxcodec/fx_codec_flate.h" #include "third_party/zlib_v128/zlib.h" @@ -942,7 +943,7 @@ uint32_t CCodec_FlateModule::FlateOrLZWDecode(FX_BOOL bLZW, offset = src_size; int err = decoder->Decode(NULL, dest_size, src_buf, offset, bEarlyChange); if (err || dest_size == 0 || dest_size + 1 < dest_size) { - return static_cast<uint32_t>(-1); + return FX_INVALID_OFFSET; } } { @@ -965,7 +966,7 @@ uint32_t CCodec_FlateModule::FlateOrLZWDecode(FX_BOOL bLZW, ret = TIFF_Predictor(dest_buf, dest_size, Colors, BitsPerComponent, Columns); } - return ret ? offset : static_cast<uint32_t>(-1); + return ret ? offset : FX_INVALID_OFFSET; } FX_BOOL CCodec_FlateModule::Encode(const uint8_t* src_buf, uint32_t src_size, diff --git a/core/fxcodec/jbig2/JBig2_Context.cpp b/core/fxcodec/jbig2/JBig2_Context.cpp index 1c316a0dd2..1ff78e121f 100644 --- a/core/fxcodec/jbig2/JBig2_Context.cpp +++ b/core/fxcodec/jbig2/JBig2_Context.cpp @@ -1277,7 +1277,7 @@ JBig2HuffmanCode* CJBig2_Context::decodeSymbolIDHuffmanTable( const size_t kRunCodesSize = 35; int32_t runcodes[kRunCodesSize]; int32_t runcodes_len[kRunCodesSize]; - for (int32_t i = 0; i < kRunCodesSize; ++i) { + for (size_t i = 0; i < kRunCodesSize; ++i) { if (pStream->readNBits(4, &runcodes_len[i]) != 0) return nullptr; } @@ -1288,7 +1288,7 @@ JBig2HuffmanCode* CJBig2_Context::decodeSymbolIDHuffmanTable( int32_t run; int32_t i = 0; while (i < (int)SBNUMSYMS) { - int32_t j; + size_t j; int32_t nVal = 0; int32_t nBits = 0; uint32_t nTemp; @@ -1299,15 +1299,13 @@ JBig2HuffmanCode* CJBig2_Context::decodeSymbolIDHuffmanTable( nVal = (nVal << 1) | nTemp; ++nBits; for (j = 0; j < kRunCodesSize; ++j) { - if (nBits == runcodes_len[j] && nVal == runcodes[j]) { + if (nBits == runcodes_len[j] && nVal == runcodes[j]) break; - } } - if (j < kRunCodesSize) { + if (j < kRunCodesSize) break; - } } - int32_t runcode = j; + int32_t runcode = static_cast<int32_t>(j); if (runcode < 32) { SBSYMCODES.get()[i].codelen = runcode; run = 0; @@ -1327,11 +1325,11 @@ JBig2HuffmanCode* CJBig2_Context::decodeSymbolIDHuffmanTable( if (run > 0) { if (i + run > (int)SBNUMSYMS) return nullptr; - for (j = 0; j < run; ++j) { + for (int32_t k = 0; k < run; ++k) { if (runcode == 32 && i > 0) { - SBSYMCODES.get()[i + j].codelen = SBSYMCODES.get()[i - 1].codelen; + SBSYMCODES.get()[i + k].codelen = SBSYMCODES.get()[i - 1].codelen; } else { - SBSYMCODES.get()[i + j].codelen = 0; + SBSYMCODES.get()[i + k].codelen = 0; } } i += run; |