summaryrefslogtreecommitdiff
path: root/core/fpdfapi/fpdf_parser
diff options
context:
space:
mode:
authorWei Li <weili@chromium.org>2016-03-29 16:42:53 -0700
committerWei Li <weili@chromium.org>2016-03-29 16:42:53 -0700
commit05d53f0355e9889c43bfa436e985d5643f249d99 (patch)
treeeca037b407114efe357e8280a96e44eee182cdfc /core/fpdfapi/fpdf_parser
parent602aebc11a615971800d38f8d427a4e4f95c1134 (diff)
downloadpdfium-05d53f0355e9889c43bfa436e985d5643f249d99.tar.xz
Code change to avoid signed/unsigned mismatch warnings.
This makes pdfium code on Linux and Mac sign-compare warning free. The warning flag will be re-enabled after checking on windows clang build. BUG=pdfium:29 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1841643002 .
Diffstat (limited to 'core/fpdfapi/fpdf_parser')
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_array.cpp4
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp13
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_indirect_object_holder.cpp7
-rw-r--r--core/fpdfapi/fpdf_parser/include/cpdf_array.h2
-rw-r--r--core/fpdfapi/fpdf_parser/include/cpdf_object.h1
5 files changed, 16 insertions, 11 deletions
diff --git a/core/fpdfapi/fpdf_parser/cpdf_array.cpp b/core/fpdfapi/fpdf_parser/cpdf_array.cpp
index 7ea2734745..964ba64236 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_array.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_array.cpp
@@ -131,14 +131,14 @@ CPDF_Array* CPDF_Array::GetArrayAt(uint32_t i) const {
return ToArray(GetDirectObjectAt(i));
}
-void CPDF_Array::RemoveAt(uint32_t i, int nCount) {
+void CPDF_Array::RemoveAt(uint32_t i, uint32_t nCount) {
if (i >= (uint32_t)m_Objects.GetSize())
return;
if (nCount <= 0 || nCount > m_Objects.GetSize() - i)
return;
- for (int j = 0; j < nCount; ++j) {
+ for (uint32_t j = 0; j < nCount; ++j) {
if (CPDF_Object* p = m_Objects.GetAt(i + j))
p->Release();
}
diff --git a/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp b/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp
index d81725d06f..18687e5fb7 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp
@@ -59,7 +59,7 @@ FX_BOOL CPDF_HintTables::ReadPageHintTable(CFX_BitStream* hStream) {
// Item 2: The location of the first page's page object.
uint32_t dwFirstObjLoc = hStream->GetBits(32);
- if (dwFirstObjLoc > nStreamOffset) {
+ if (dwFirstObjLoc > static_cast<uint32_t>(nStreamOffset)) {
FX_SAFE_DWORD safeLoc = pdfium::base::checked_cast<uint32_t>(nStreamLen);
safeLoc += dwFirstObjLoc;
if (!safeLoc.IsValid())
@@ -236,7 +236,7 @@ FX_BOOL CPDF_HintTables::ReadSharedObjHintTable(CFX_BitStream* hStream,
// Item 2: The location of the first object in the shared objects section.
uint32_t dwFirstSharedObjLoc = hStream->GetBits(32);
- if (dwFirstSharedObjLoc > nStreamOffset)
+ if (dwFirstSharedObjLoc > static_cast<uint32_t>(nStreamOffset))
dwFirstSharedObjLoc += nStreamLen;
// Item 3: The number of shared object entries for the first page.
@@ -387,12 +387,13 @@ IPDF_DataAvail::DocAvailStatus CPDF_HintTables::CheckPage(
uint32_t dwObjNum = 0;
for (uint32_t j = 0; j < m_dwNSharedObjsArray[index]; ++j) {
dwIndex = m_dwIdentifierArray[offset + j];
- if (dwIndex >= m_dwSharedObjNumArray.GetSize())
+ if (dwIndex >= static_cast<uint32_t>(m_dwSharedObjNumArray.GetSize()))
return IPDF_DataAvail::DataNotAvailable;
dwObjNum = m_dwSharedObjNumArray[dwIndex];
- if (dwObjNum >= nFirstPageObjNum &&
- dwObjNum < nFirstPageObjNum + m_nFirstPageSharedObjs) {
+ if (dwObjNum >= static_cast<uint32_t>(nFirstPageObjNum) &&
+ dwObjNum <
+ static_cast<uint32_t>(nFirstPageObjNum) + m_nFirstPageSharedObjs) {
continue;
}
@@ -428,7 +429,7 @@ FX_BOOL CPDF_HintTables::LoadHintStream(CPDF_Stream* pHintStream) {
// Hint table has at least 60 bytes.
const uint32_t MIN_STREAM_LEN = 60;
if (size < MIN_STREAM_LEN || shared_hint_table_offset <= 0 ||
- size < shared_hint_table_offset) {
+ size < static_cast<uint32_t>(shared_hint_table_offset)) {
return FALSE;
}
diff --git a/core/fpdfapi/fpdf_parser/cpdf_indirect_object_holder.cpp b/core/fpdfapi/fpdf_parser/cpdf_indirect_object_holder.cpp
index 14410dabb5..ef3395d3ae 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_indirect_object_holder.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_indirect_object_holder.cpp
@@ -26,7 +26,8 @@ CPDF_Object* CPDF_IndirectObjectHolder::GetIndirectObject(uint32_t objnum) {
auto it = m_IndirectObjs.find(objnum);
if (it != m_IndirectObjs.end())
- return it->second->GetObjNum() != -1 ? it->second : nullptr;
+ return it->second->GetObjNum() != CPDF_Object::kInvalidObjNum ? it->second
+ : nullptr;
if (!m_pParser)
return nullptr;
@@ -56,8 +57,10 @@ uint32_t CPDF_IndirectObjectHolder::AddIndirectObject(CPDF_Object* pObj) {
void CPDF_IndirectObjectHolder::ReleaseIndirectObject(uint32_t objnum) {
auto it = m_IndirectObjs.find(objnum);
- if (it == m_IndirectObjs.end() || it->second->GetObjNum() == -1)
+ if (it == m_IndirectObjs.end() ||
+ it->second->GetObjNum() == CPDF_Object::kInvalidObjNum) {
return;
+ }
it->second->Destroy();
m_IndirectObjs.erase(it);
}
diff --git a/core/fpdfapi/fpdf_parser/include/cpdf_array.h b/core/fpdfapi/fpdf_parser/include/cpdf_array.h
index ea367785ed..b964f4955b 100644
--- a/core/fpdfapi/fpdf_parser/include/cpdf_array.h
+++ b/core/fpdfapi/fpdf_parser/include/cpdf_array.h
@@ -44,7 +44,7 @@ class CPDF_Array : public CPDF_Object {
void InsertAt(uint32_t index,
CPDF_Object* pObj,
CPDF_IndirectObjectHolder* pObjs = nullptr);
- void RemoveAt(uint32_t index, int nCount = 1);
+ void RemoveAt(uint32_t index, uint32_t nCount = 1);
void Add(CPDF_Object* pObj, CPDF_IndirectObjectHolder* pObjs = nullptr);
void AddNumber(FX_FLOAT f);
diff --git a/core/fpdfapi/fpdf_parser/include/cpdf_object.h b/core/fpdfapi/fpdf_parser/include/cpdf_object.h
index 1ba38a946e..802cbbc638 100644
--- a/core/fpdfapi/fpdf_parser/include/cpdf_object.h
+++ b/core/fpdfapi/fpdf_parser/include/cpdf_object.h
@@ -22,6 +22,7 @@ class CPDF_String;
class CPDF_Object {
public:
+ static const uint32_t kInvalidObjNum = static_cast<uint32_t>(-1);
enum Type {
BOOLEAN = 1,
NUMBER,