summaryrefslogtreecommitdiff
path: root/core/fxcrt
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-08-29 16:39:44 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-08-30 14:35:33 +0000
commitaa3a9cd82df9dff1ef136797259e606a39c18b75 (patch)
tree5ca71f96fa289c5f13d22b371341882b77c7331f /core/fxcrt
parent980a3ea30872cef9ada360aa85e7c3573d7668b5 (diff)
downloadpdfium-aa3a9cd82df9dff1ef136797259e606a39c18b75.tar.xz
Convert int* references to FX_STRSIZE
Through out the code base there are numerous places where variables are declared using a signed integer type when interacting with the string classes, since they assume that FX_STRSIZE is 'int'. As part of changing the underling type of FX_STRSIZE to be unsigned, these locations are being changed to use FX_STRSIZE. This is necessary as part of converting the type, but has been broken off into a separate CL, since it should be low risk. Some related cleanups that are low risk are included as part of this CL. BUG=pdfium:828 Change-Id: Ifaae54ad195ccde0fe8672f71271d29a6ebd65fd Reviewed-on: https://pdfium-review.googlesource.com/12210 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'core/fxcrt')
-rw-r--r--core/fxcrt/cfx_bytestring.cpp2
-rw-r--r--core/fxcrt/cfx_chariter.cpp7
-rw-r--r--core/fxcrt/cfx_seekablestreamproxy.cpp4
-rw-r--r--core/fxcrt/cfx_string_data_template.h6
-rw-r--r--core/fxcrt/fx_basic.h2
-rw-r--r--core/fxcrt/fx_basic_buffer.cpp2
-rw-r--r--core/fxcrt/fx_basic_util.cpp2
7 files changed, 13 insertions, 12 deletions
diff --git a/core/fxcrt/cfx_bytestring.cpp b/core/fxcrt/cfx_bytestring.cpp
index ac390949ee..13b6673c70 100644
--- a/core/fxcrt/cfx_bytestring.cpp
+++ b/core/fxcrt/cfx_bytestring.cpp
@@ -427,7 +427,7 @@ FX_STRSIZE CFX_ByteString::Delete(FX_STRSIZE index, FX_STRSIZE count) {
return old_length;
ReallocBeforeWrite(old_length);
- int chars_to_copy = old_length - removal_length + 1;
+ FX_STRSIZE chars_to_copy = old_length - removal_length + 1;
memmove(m_pData->m_String + index, m_pData->m_String + removal_length,
chars_to_copy);
m_pData->m_nDataLength = old_length - count;
diff --git a/core/fxcrt/cfx_chariter.cpp b/core/fxcrt/cfx_chariter.cpp
index db94fb09f4..827e86967d 100644
--- a/core/fxcrt/cfx_chariter.cpp
+++ b/core/fxcrt/cfx_chariter.cpp
@@ -21,7 +21,7 @@ bool CFX_CharIter::Next(bool bPrev) {
return false;
m_nIndex--;
} else {
- if (m_nIndex + 1 >= m_wsText.GetLength())
+ if (static_cast<FX_STRSIZE>(m_nIndex + 1) >= m_wsText.GetLength())
return false;
m_nIndex++;
}
@@ -33,7 +33,7 @@ wchar_t CFX_CharIter::GetChar() const {
}
void CFX_CharIter::SetAt(int32_t nIndex) {
- if (nIndex < 0 || nIndex >= m_wsText.GetLength())
+ if (nIndex < 0 || static_cast<FX_STRSIZE>(nIndex) >= m_wsText.GetLength())
return;
m_nIndex = nIndex;
}
@@ -43,7 +43,8 @@ int32_t CFX_CharIter::GetAt() const {
}
bool CFX_CharIter::IsEOF(bool bTail) const {
- return bTail ? (m_nIndex + 1 == m_wsText.GetLength()) : (m_nIndex == 0);
+ return bTail ? (static_cast<FX_STRSIZE>(m_nIndex + 1) == m_wsText.GetLength())
+ : (m_nIndex == 0);
}
std::unique_ptr<IFX_CharIter> CFX_CharIter::Clone() const {
diff --git a/core/fxcrt/cfx_seekablestreamproxy.cpp b/core/fxcrt/cfx_seekablestreamproxy.cpp
index e610e0a9c3..da1170717a 100644
--- a/core/fxcrt/cfx_seekablestreamproxy.cpp
+++ b/core/fxcrt/cfx_seekablestreamproxy.cpp
@@ -98,8 +98,8 @@ void UTF16ToWChar(void* pBuffer, FX_STRSIZE iLength) {
uint16_t* pSrc = static_cast<uint16_t*>(pBuffer);
wchar_t* pDst = static_cast<wchar_t*>(pBuffer);
- while (--iLength >= 0)
- pDst[iLength] = static_cast<wchar_t>(pSrc[iLength]);
+ for (FX_STRSIZE i = 0; i < iLength; i++)
+ pDst[i] = static_cast<wchar_t>(pSrc[i]);
}
void SwapByteOrder(wchar_t* pStr, FX_STRSIZE iLength) {
diff --git a/core/fxcrt/cfx_string_data_template.h b/core/fxcrt/cfx_string_data_template.h
index e39f6a5dfd..eabb608818 100644
--- a/core/fxcrt/cfx_string_data_template.h
+++ b/core/fxcrt/cfx_string_data_template.h
@@ -21,7 +21,7 @@ class CFX_StringDataTemplate {
// NUL char that is not included in |m_nAllocLength|.
int overhead =
offsetof(CFX_StringDataTemplate, m_String) + sizeof(CharType);
- pdfium::base::CheckedNumeric<int> nSize = nLen;
+ pdfium::base::CheckedNumeric<FX_STRSIZE> nSize = nLen;
nSize *= sizeof(CharType);
nSize += overhead;
@@ -31,8 +31,8 @@ class CFX_StringDataTemplate {
// by using this otherwise wasted space.
nSize += 7;
nSize &= ~7;
- int totalSize = nSize.ValueOrDie();
- int usableLen = (totalSize - overhead) / sizeof(CharType);
+ FX_STRSIZE totalSize = nSize.ValueOrDie();
+ FX_STRSIZE usableLen = (totalSize - overhead) / sizeof(CharType);
ASSERT(usableLen >= nLen);
void* pData = pdfium::base::PartitionAllocGeneric(
diff --git a/core/fxcrt/fx_basic.h b/core/fxcrt/fx_basic.h
index 47cce9a60f..1f05dfb627 100644
--- a/core/fxcrt/fx_basic.h
+++ b/core/fxcrt/fx_basic.h
@@ -43,7 +43,7 @@ class CFX_BinaryBuf {
}
void InsertBlock(FX_STRSIZE pos, const void* pBuf, FX_STRSIZE size);
- void Delete(int start_index, int count);
+ void Delete(FX_STRSIZE start_index, FX_STRSIZE count);
// Releases ownership of |m_pBuffer| and returns it.
std::unique_ptr<uint8_t, FxFreeDeleter> DetachBuffer();
diff --git a/core/fxcrt/fx_basic_buffer.cpp b/core/fxcrt/fx_basic_buffer.cpp
index a359bdd5d0..310aec7faf 100644
--- a/core/fxcrt/fx_basic_buffer.cpp
+++ b/core/fxcrt/fx_basic_buffer.cpp
@@ -23,7 +23,7 @@ CFX_BinaryBuf::CFX_BinaryBuf(FX_STRSIZE size)
CFX_BinaryBuf::~CFX_BinaryBuf() {}
-void CFX_BinaryBuf::Delete(int start_index, int count) {
+void CFX_BinaryBuf::Delete(FX_STRSIZE start_index, FX_STRSIZE count) {
if (!m_pBuffer || start_index < 0 || count < 0 || count > m_DataSize ||
start_index > m_DataSize - count) {
return;
diff --git a/core/fxcrt/fx_basic_util.cpp b/core/fxcrt/fx_basic_util.cpp
index 05ab20472c..6f59f32fff 100644
--- a/core/fxcrt/fx_basic_util.cpp
+++ b/core/fxcrt/fx_basic_util.cpp
@@ -28,7 +28,7 @@ bool FX_atonum(const CFX_ByteStringC& strc, void* pData) {
pdfium::base::CheckedNumeric<uint32_t> integer = 0;
bool bNegative = false;
bool bSigned = false;
- int cc = 0;
+ FX_STRSIZE cc = 0;
if (strc[0] == '+') {
cc++;
bSigned = true;