summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
authorWei Li <weili@chromium.org>2016-03-28 10:33:33 -0700
committerWei Li <weili@chromium.org>2016-03-28 10:33:33 -0700
commit8940993efffaaf432320509555dc61122b8b72b2 (patch)
tree2e9c42a78d96061ae06ee052e8a274ccfb8fcec7 /core/fpdfapi
parentb5e8f14e3eefc5da995b332788d3203cee204883 (diff)
downloadpdfium-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/fpdfapi')
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_colorspace.cpp12
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_textobject.cpp15
-rw-r--r--core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp4
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_array.cpp2
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp4
-rw-r--r--core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp15
6 files changed, 25 insertions, 27 deletions
diff --git a/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp b/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp
index 3add21cfed..213d777ecb 100644
--- a/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_colorspace.cpp
@@ -467,7 +467,7 @@ void CPDF_ColorSpace::GetDefaultColor(FX_FLOAT* buf) const {
return;
}
FX_FLOAT min, max;
- for (int i = 0; i < m_nComponents; i++) {
+ for (uint32_t i = 0; i < m_nComponents; i++) {
GetDefaultValue(i, buf[i], min, max);
}
}
@@ -490,7 +490,7 @@ void CPDF_ColorSpace::TranslateImageLine(uint8_t* dest_buf,
FX_FLOAT* src = srcbuf;
FX_FLOAT R, G, B;
for (int i = 0; i < pixels; i++) {
- for (int j = 0; j < m_nComponents; j++)
+ for (uint32_t j = 0; j < m_nComponents; j++)
if (m_Family == PDFCS_INDEXED) {
src[j] = (FX_FLOAT)(*src_buf++);
} else {
@@ -842,7 +842,7 @@ FX_BOOL CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) {
}
CPDF_Array* pRanges = pDict->GetArrayBy("Range");
m_pRanges = FX_Alloc2D(FX_FLOAT, m_nComponents, 2);
- for (int i = 0; i < m_nComponents * 2; i++) {
+ for (uint32_t i = 0; i < m_nComponents * 2; i++) {
if (pRanges)
m_pRanges[i] = pRanges->GetNumberAt(i);
else if (i % 2)
@@ -918,7 +918,7 @@ void CPDF_ICCBasedCS::TranslateImageLine(uint8_t* pDestBuf,
ReverseRGB(pDestBuf, pSrcBuf, pixels);
} else if (m_pProfile->m_pTransform) {
int nMaxColors = 1;
- for (int i = 0; i < m_nComponents; i++) {
+ for (uint32_t i = 0; i < m_nComponents; i++) {
nMaxColors *= 52;
}
if (m_nComponents > 3 || image_width * image_height < nMaxColors * 3 / 2) {
@@ -932,7 +932,7 @@ void CPDF_ICCBasedCS::TranslateImageLine(uint8_t* pDestBuf,
for (int i = 0; i < nMaxColors; i++) {
uint32_t color = i;
uint32_t order = nMaxColors / 52;
- for (int c = 0; c < m_nComponents; c++) {
+ for (uint32_t c = 0; c < m_nComponents; c++) {
*pSrc++ = (uint8_t)(color / order * 5);
color %= order;
order /= 52;
@@ -944,7 +944,7 @@ void CPDF_ICCBasedCS::TranslateImageLine(uint8_t* pDestBuf,
}
for (int i = 0; i < pixels; i++) {
int index = 0;
- for (int c = 0; c < m_nComponents; c++) {
+ for (uint32_t c = 0; c < m_nComponents; c++) {
index = index * 52 + (*pSrcBuf) / 5;
pSrcBuf++;
}
diff --git a/core/fpdfapi/fpdf_page/cpdf_textobject.cpp b/core/fpdfapi/fpdf_page/cpdf_textobject.cpp
index 7ca03b4f05..444101fb9e 100644
--- a/core/fpdfapi/fpdf_page/cpdf_textobject.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_textobject.cpp
@@ -28,7 +28,7 @@ void CPDF_TextObject::GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const {
m_nChars == 1 ? (uint32_t)(uintptr_t)m_pCharCodes : m_pCharCodes[index];
pInfo->m_OriginX = index ? m_pCharPos[index - 1] : 0;
pInfo->m_OriginY = 0;
- if (pInfo->m_CharCode == -1) {
+ if (pInfo->m_CharCode == CPDF_Font::kInvalidCharCode) {
return;
}
CPDF_Font* pFont = m_TextState.GetFont();
@@ -54,7 +54,7 @@ int CPDF_TextObject::CountChars() const {
}
int count = 0;
for (int i = 0; i < m_nChars; ++i)
- if (m_pCharCodes[i] != (uint32_t)-1) {
+ if (m_pCharCodes[i] != CPDF_Font::kInvalidCharCode) {
++count;
}
return count;
@@ -70,10 +70,11 @@ void CPDF_TextObject::GetCharInfo(int index,
}
int count = 0;
for (int i = 0; i < m_nChars; ++i) {
- if (m_pCharCodes[i] != (uint32_t)-1) {
+ if (m_pCharCodes[i] != CPDF_Font::kInvalidCharCode) {
if (count == index) {
charcode = m_pCharCodes[i];
- if (i == m_nChars - 1 || m_pCharCodes[i + 1] != (uint32_t)-1) {
+ if (i == m_nChars - 1 ||
+ m_pCharCodes[i + 1] != CPDF_Font::kInvalidCharCode) {
kerning = 0;
} else {
kerning = m_pCharPos[i];
@@ -93,7 +94,7 @@ void CPDF_TextObject::GetCharInfo(int index, CPDF_TextObjectItem* pInfo) const {
int count = 0;
for (int i = 0; i < m_nChars; ++i) {
uint32_t charcode = m_pCharCodes[i];
- if (charcode == (uint32_t)-1) {
+ if (charcode == CPDF_Font::kInvalidCharCode) {
continue;
}
if (count == index) {
@@ -156,7 +157,7 @@ void CPDF_TextObject::SetSegments(const CFX_ByteString* pStrs,
}
if (i != nsegs - 1) {
m_pCharPos[index - 1] = pKerning[i];
- m_pCharCodes[index++] = (uint32_t)-1;
+ m_pCharCodes[index++] = CPDF_Font::kInvalidCharCode;
}
}
} else {
@@ -206,7 +207,7 @@ void CPDF_TextObject::CalcPositionData(FX_FLOAT* pTextAdvanceX,
uint32_t charcode =
m_nChars == 1 ? (uint32_t)(uintptr_t)m_pCharCodes : m_pCharCodes[i];
if (i > 0) {
- if (charcode == (uint32_t)-1) {
+ if (charcode == CPDF_Font::kInvalidCharCode) {
curpos -= (m_pCharPos[i - 1] * fontsize) / 1000;
continue;
}
diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
index f2b7582a01..8bff5445ff 100644
--- a/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
+++ b/core/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
@@ -48,7 +48,7 @@ uint32_t DecodeAllScanlines(ICodec_ScanlineDecoder* pDecoder,
uint8_t*& dest_buf,
uint32_t& dest_size) {
if (!pDecoder) {
- return static_cast<uint32_t>(-1);
+ return FX_INVALID_OFFSET;
}
int ncomps = pDecoder->CountComps();
int bpc = pDecoder->GetBPC();
@@ -57,7 +57,7 @@ uint32_t DecodeAllScanlines(ICodec_ScanlineDecoder* pDecoder,
int pitch = (width * ncomps * bpc + 7) / 8;
if (height == 0 || pitch > (1 << 30) / height) {
delete pDecoder;
- return static_cast<uint32_t>(-1);
+ return FX_INVALID_OFFSET;
}
dest_buf = FX_Alloc2D(uint8_t, pitch, height);
dest_size = pitch * height; // Safe since checked alloc returned.
diff --git a/core/fpdfapi/fpdf_parser/cpdf_array.cpp b/core/fpdfapi/fpdf_parser/cpdf_array.cpp
index 69de5bbc26..544469916b 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_array.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_array.cpp
@@ -47,7 +47,7 @@ const CPDF_Array* CPDF_Array::AsArray() const {
CPDF_Object* CPDF_Array::Clone(FX_BOOL bDirect) const {
CPDF_Array* pCopy = new CPDF_Array();
- for (int i = 0; i < GetCount(); i++) {
+ for (size_t i = 0; i < GetCount(); i++) {
CPDF_Object* value = m_Objects.GetAt(i);
pCopy->m_Objects.Add(value->Clone(bDirect));
}
diff --git a/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp b/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp
index dd2be01311..147ae37ed0 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp
@@ -185,7 +185,7 @@ FX_BOOL CPDF_HintTables::ReadPageHintTable(CFX_BitStream* hStream) {
if (!CanReadFromBitStream(hStream, required_bits))
return FALSE;
- for (int j = 0; j < m_dwNSharedObjsArray[i]; j++)
+ for (uint32_t j = 0; j < m_dwNSharedObjsArray[i]; j++)
m_dwIdentifierArray.Add(hStream->GetBits(dwSharedIdBits));
}
hStream->ByteAlign();
@@ -385,7 +385,7 @@ IPDF_DataAvail::DocAvailStatus CPDF_HintTables::CheckPage(
uint32_t dwIndex = 0;
uint32_t dwObjNum = 0;
- for (int j = 0; j < m_dwNSharedObjsArray[index]; ++j) {
+ for (uint32_t j = 0; j < m_dwNSharedObjsArray[index]; ++j) {
dwIndex = m_dwIdentifierArray[offset + j];
if (dwIndex >= m_dwSharedObjNumArray.GetSize())
return IPDF_DataAvail::DataNotAvailable;
diff --git a/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
index 219a72507b..346476b62b 100644
--- a/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
+++ b/core/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
@@ -176,24 +176,21 @@ uint32_t RunLengthDecode(const uint8_t* src_buf,
if (src_buf[i] < 128) {
old = dest_size;
dest_size += src_buf[i] + 1;
- if (dest_size < old) {
- return static_cast<uint32_t>(-1);
- }
+ if (dest_size < old)
+ return FX_INVALID_OFFSET;
i += src_buf[i] + 2;
} else if (src_buf[i] > 128) {
old = dest_size;
dest_size += 257 - src_buf[i];
- if (dest_size < old) {
- return static_cast<uint32_t>(-1);
- }
+ if (dest_size < old)
+ return FX_INVALID_OFFSET;
i += 2;
} else {
break;
}
}
- if (dest_size >= _STREAM_MAX_SIZE_) {
- return static_cast<uint32_t>(-1);
- }
+ if (dest_size >= _STREAM_MAX_SIZE_)
+ return FX_INVALID_OFFSET;
dest_buf = FX_Alloc(uint8_t, dest_size);
i = 0;
int dest_count = 0;