diff options
author | Wei Li <weili@chromium.org> | 2016-03-21 11:20:44 -0700 |
---|---|---|
committer | Wei Li <weili@chromium.org> | 2016-03-21 11:20:44 -0700 |
commit | d4e8f1222ca17b57ac74019b2fc3706e1192645c (patch) | |
tree | 0dd5e1627fd684205631f875cbf5946178177766 /core/fxcrt | |
parent | 34fa8d90ae2f60fae219e4dbeff14c053d2e8eef (diff) | |
download | pdfium-d4e8f1222ca17b57ac74019b2fc3706e1192645c.tar.xz |
Re-enable several MSVC warnings
Re-enable the following warnings:
4245: signed/unsigned conversion mismatch;
4310: cast may truncate data;
4389: operator on signed/unsigned mismatch;
4701: use potentially uninitialized local variable;
4706: assignment within conditional expression
Clean up the code to avoid those warnings.
BUG=pdfium:29
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1801383002 .
Diffstat (limited to 'core/fxcrt')
-rw-r--r-- | core/fxcrt/fx_basic_maps.cpp | 15 | ||||
-rw-r--r-- | core/fxcrt/fx_basic_wstring.cpp | 20 |
2 files changed, 16 insertions, 19 deletions
diff --git a/core/fxcrt/fx_basic_maps.cpp b/core/fxcrt/fx_basic_maps.cpp index eb4f2868f5..bad1868286 100644 --- a/core/fxcrt/fx_basic_maps.cpp +++ b/core/fxcrt/fx_basic_maps.cpp @@ -39,19 +39,16 @@ void CFX_MapPtrToPtr::GetNextAssoc(FX_POSITION& rNextPosition, ASSERT(pAssocRet); if (pAssocRet == (CAssoc*)-1) { for (FX_DWORD nBucket = 0; nBucket < m_nHashTableSize; nBucket++) { - if ((pAssocRet = m_pHashTable[nBucket])) + pAssocRet = m_pHashTable[nBucket]; + if (pAssocRet) break; } ASSERT(pAssocRet); } - CAssoc* pAssocNext; - if ((pAssocNext = pAssocRet->pNext) == NULL) { - for (FX_DWORD nBucket = (HashKey(pAssocRet->key) % m_nHashTableSize) + 1; - nBucket < m_nHashTableSize; nBucket++) { - if ((pAssocNext = m_pHashTable[nBucket])) { - break; - } - } + CAssoc* pAssocNext = pAssocRet->pNext; + for (FX_DWORD nBucket = (HashKey(pAssocRet->key) % m_nHashTableSize) + 1; + nBucket < m_nHashTableSize && !pAssocNext; nBucket++) { + pAssocNext = m_pHashTable[nBucket]; } rNextPosition = (FX_POSITION)pAssocNext; rKey = pAssocRet->key; diff --git a/core/fxcrt/fx_basic_wstring.cpp b/core/fxcrt/fx_basic_wstring.cpp index 95b761bd09..8282bd5014 100644 --- a/core/fxcrt/fx_basic_wstring.cpp +++ b/core/fxcrt/fx_basic_wstring.cpp @@ -640,13 +640,12 @@ FX_STRSIZE CFX_WideString::Replace(const FX_WCHAR* lpszOld, FX_STRSIZE nCount = 0; FX_WCHAR* lpszStart = m_pData->m_String; FX_WCHAR* lpszEnd = m_pData->m_String + m_pData->m_nDataLength; - FX_WCHAR* lpszTarget; - { - while ((lpszTarget = (FX_WCHAR*)FXSYS_wcsstr(lpszStart, lpszOld)) && - lpszStart < lpszEnd) { - nCount++; - lpszStart = lpszTarget + nSourceLen; - } + while (lpszStart < lpszEnd) { + FX_WCHAR* lpszTarget = FXSYS_wcsstr(lpszStart, lpszOld); + if (!lpszTarget) + break; + nCount++; + lpszStart = lpszTarget + nSourceLen; } if (nCount > 0) { CopyBeforeWrite(); @@ -667,9 +666,10 @@ FX_STRSIZE CFX_WideString::Replace(const FX_WCHAR* lpszOld, lpszStart = m_pData->m_String; lpszEnd = m_pData->m_String + std::max(m_pData->m_nDataLength, nNewLength); { - while ((lpszTarget = (FX_WCHAR*)FXSYS_wcsstr(lpszStart, lpszOld)) != - NULL && - lpszStart < lpszEnd) { + while (lpszStart < lpszEnd) { + FX_WCHAR* lpszTarget = FXSYS_wcsstr(lpszStart, lpszOld); + if (!lpszTarget) + break; FX_STRSIZE nBalance = nOldLength - (FX_STRSIZE)(lpszTarget - m_pData->m_String + nSourceLen); |