diff options
Diffstat (limited to 'core')
46 files changed, 170 insertions, 202 deletions
diff --git a/core/include/fxcrt/fx_basic.h b/core/include/fxcrt/fx_basic.h index d5673271e6..e1c384f2c5 100644 --- a/core/include/fxcrt/fx_basic.h +++ b/core/include/fxcrt/fx_basic.h @@ -1176,7 +1176,7 @@ class CFX_ListArrayTemplate { T2& operator[](int32_t nIndex) { uint8_t* data = m_Data.GetAt(nIndex); - FXSYS_assert(data != NULL); + FXSYS_assert(data); return (T2&)(*(volatile T2*)data); } diff --git a/core/include/fxcrt/fx_ext.h b/core/include/fxcrt/fx_ext.h index 48801bb196..6cba8eeb91 100644 --- a/core/include/fxcrt/fx_ext.h +++ b/core/include/fxcrt/fx_ext.h @@ -93,7 +93,7 @@ template <class baseType> class CFX_SSortTemplate { public: void ShellSort(baseType* pArray, int32_t iCount) { - FXSYS_assert(pArray != NULL && iCount > 0); + FXSYS_assert(pArray && iCount > 0); int32_t i, j, gap; baseType v1, v2; gap = iCount >> 1; diff --git a/core/src/fdrm/crypto/fx_crypt_sha.cpp b/core/src/fdrm/crypto/fx_crypt_sha.cpp index 21046f1df2..ecefdde05a 100644 --- a/core/src/fdrm/crypto/fx_crypt_sha.cpp +++ b/core/src/fdrm/crypto/fx_crypt_sha.cpp @@ -369,7 +369,7 @@ typedef struct { uint8_t buffer[128]; } sha384_context; uint64_t FX_ato64i(const FX_CHAR* str) { - FXSYS_assert(str != NULL); + FXSYS_assert(str); uint64_t ret = 0; int len = (int)FXSYS_strlen(str); len = len > 16 ? 16 : len; diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp index 4df841fb75..eda51deb3b 100644 --- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp +++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp @@ -45,7 +45,7 @@ void CPDF_PageContentGenerate::GenerateContent() { } CPDF_Object* pContent = pPageDict ? pPageDict->GetElementValue("Contents") : NULL; - if (pContent != NULL) { + if (pContent) { pPageDict->RemoveAt("Contents"); } CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp index 52129d9e54..a797332727 100644 --- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp +++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp @@ -1433,8 +1433,8 @@ void CPDF_Creator::InitNewObjNumOffsets() { FX_BOOL bNewStart = FALSE; for (; i < iCount; i++) { FX_DWORD dwCurObjNum = m_NewObjNumArray.ElementAt(i); - FX_BOOL bExist = (dwCurObjNum < nOldSize && - m_ObjectOffset.GetPtrAt(dwCurObjNum) != NULL); + FX_BOOL bExist = + (dwCurObjNum < nOldSize && m_ObjectOffset.GetPtrAt(dwCurObjNum)); if (bExist || dwCurObjNum - dwLastObjNum > 1) { if (!bNewStart) { m_ObjectOffset.Add(dwStartObjNum, dwLastObjNum - dwStartObjNum + 1); diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp index 5467cfdaec..7febc7932f 100644 --- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp +++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp @@ -429,7 +429,7 @@ CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTA* pLogFont, #if (_FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_) uint32_t FX_GetLangHashCode(const FX_CHAR* pStr) { - FXSYS_assert(pStr != NULL); + FXSYS_assert(pStr); int32_t iLength = FXSYS_strlen(pStr); const FX_CHAR* pStrEnd = pStr + iLength; uint32_t uHashCode = 0; diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp index ccb184c6cf..640e8671f8 100644 --- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp +++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp @@ -259,7 +259,7 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, delete pMaskBitmap; } } - FX_BOOL bStream = pFileWrite != NULL && pFileRead != NULL; + FX_BOOL bStream = pFileWrite && pFileRead; if (opType == 0) { if (iCompress & PDF_IMAGE_LOSSLESS_COMPRESS) { if (pBitmap->GetBPP() == 1) { @@ -270,7 +270,7 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, if (pBitmap->GetBPP() == 1) { _JBIG2EncodeBitmap(pDict, pBitmap, m_pDocument, dest_buf, dest_size, FALSE); - } else if (pBitmap->GetBPP() >= 8 && pBitmap->GetPalette() != NULL) { + } else if (pBitmap->GetBPP() >= 8 && pBitmap->GetPalette()) { CFX_DIBitmap* pNewBitmap = new CFX_DIBitmap(); pNewBitmap->Copy(pBitmap); pNewBitmap->ConvertFormat(FXDIB_Rgb); diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp index b515d90a7f..4a71382da4 100644 --- a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp +++ b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp @@ -1519,7 +1519,7 @@ void CPDF_TrueTypeFont::LoadGlyphMap() { } } if ((m_GlyphIndex[charcode] == 0 || m_GlyphIndex[charcode] == 0xffff) && - name != NULL) { + name) { if (name[0] == '.' && FXSYS_strcmp(name, ".notdef") == 0) { m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.GetFace(), 32); } else { diff --git a/core/src/fpdfapi/fpdf_font/ttgsubtable.h b/core/src/fpdfapi/fpdf_font/ttgsubtable.h index e3c9965654..605d25fd57 100644 --- a/core/src/fpdfapi/fpdf_font/ttgsubtable.h +++ b/core/src/fpdfapi/fpdf_font/ttgsubtable.h @@ -277,10 +277,9 @@ class CFX_CTTGSUBTable { TLookup() : LookupType(0), LookupFlag(0), SubTableCount(0), SubTable(NULL) {} ~TLookup() { - if (SubTableCount > 0 && SubTable != NULL) { - for (int i = 0; i < SubTableCount; i++) { + if (SubTable) { + for (int i = 0; i < SubTableCount; ++i) delete SubTable[i]; - } delete[] SubTable; } } diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp index 0bf044101c..fbe6faa471 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp @@ -349,7 +349,7 @@ CPDF_Stream* CPDF_StreamParser::ReadInlineStream(CPDF_Document* pDoc, FX_DWORD width = pDict->GetInteger("Width"); FX_DWORD height = pDict->GetInteger("Height"); FX_DWORD OrigSize = 0; - if (pCSObj != NULL) { + if (pCSObj) { FX_DWORD bpc = pDict->GetInteger("BitsPerComponent"); FX_DWORD nComponents = 1; CPDF_ColorSpace* pCS = pDoc->LoadColorSpace(pCSObj); diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp index e1a7493a2f..5ead9a5bea 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp @@ -44,7 +44,7 @@ CPDF_TilingPattern::CPDF_TilingPattern(CPDF_Document* pDoc, m_pPatternObj = pPatternObj; m_pDocument = pDoc; CPDF_Dictionary* pDict = m_pPatternObj->GetDict(); - ASSERT(pDict != NULL); + ASSERT(pDict); m_Pattern2Form = pDict->GetMatrix("Matrix"); m_bColored = pDict->GetInteger("PaintType") == 1; if (parentMatrix) { @@ -88,7 +88,7 @@ CPDF_ShadingPattern::CPDF_ShadingPattern(CPDF_Document* pDoc, m_bShadingObj = bShading; if (!bShading) { CPDF_Dictionary* pDict = m_pPatternObj->GetDict(); - ASSERT(pDict != NULL); + ASSERT(pDict); m_Pattern2Form = pDict->GetMatrix("Matrix"); m_pShadingObj = pDict->GetElementValue("Shading"); if (parentMatrix) { diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp index 2d7c4b0eec..6625cce2e6 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp @@ -9,7 +9,7 @@ CPDF_Document::CPDF_Document(CPDF_Parser* pParser) : CPDF_IndirectObjects(pParser) { - ASSERT(pParser != NULL); + ASSERT(pParser); m_pRootDict = NULL; m_pInfoDict = NULL; m_bLinearized = FALSE; diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp index 857e19c28f..58b03c1887 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp @@ -161,7 +161,6 @@ CPDF_Array* CPDF_Object::GetArray() const { return const_cast<CPDF_Array*>(AsArray()); } void CPDF_Object::SetString(const CFX_ByteString& str) { - ASSERT(this != NULL); switch (m_Type) { case PDFOBJ_BOOLEAN: AsBoolean()->m_bValue = (str == "true"); @@ -526,17 +525,15 @@ void CPDF_Array::SetAt(FX_DWORD i, void CPDF_Array::InsertAt(FX_DWORD index, CPDF_Object* pObj, CPDF_IndirectObjects* pObjs) { - ASSERT(pObj != NULL); if (pObj->GetObjNum()) { - ASSERT(pObjs != NULL); + ASSERT(pObjs); pObj = new CPDF_Reference(pObjs, pObj->GetObjNum()); } m_Objects.InsertAt(index, pObj); } void CPDF_Array::Add(CPDF_Object* pObj, CPDF_IndirectObjects* pObjs) { - ASSERT(pObj != NULL); if (pObj->GetObjNum()) { - ASSERT(pObjs != NULL); + ASSERT(pObjs); pObj = new CPDF_Reference(pObjs, pObj->GetObjNum()); } m_Objects.Add(pObj); diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp index d7c3b6e6e8..801f9e737c 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp @@ -434,7 +434,7 @@ void CPDF_RenderStatus::DrawObjWithBackground(const CPDF_PageObject* pObj, res = 0; } CPDF_ScaledRenderBuffer buffer; - if (!buffer.Initialize(m_pContext, m_pDevice, &rect, pObj, &m_Options, res)) { + if (!buffer.Initialize(m_pContext, m_pDevice, rect, pObj, &m_Options, res)) { return; } CFX_Matrix matrix = *pObj2Device; @@ -537,12 +537,9 @@ FX_BOOL CPDF_RenderStatus::ProcessPath(CPDF_PathObject* pPathObj, m_curBlend); } CPDF_TransferFunc* CPDF_RenderStatus::GetTransferFunc(CPDF_Object* pObj) const { - ASSERT(pObj != NULL); + ASSERT(pObj); CPDF_DocRenderData* pDocCache = m_pContext->m_pDocument->GetRenderData(); - if (!pDocCache) { - return NULL; - } - return pDocCache->GetTransferFunc(pObj); + return pDocCache ? pDocCache->GetTransferFunc(pObj) : nullptr; } FX_ARGB CPDF_RenderStatus::GetFillArgb(const CPDF_PageObject* pObj, FX_BOOL bType3) const { @@ -1343,19 +1340,18 @@ CPDF_ScaledRenderBuffer::~CPDF_ScaledRenderBuffer() {} #define _FPDFAPI_IMAGESIZE_LIMIT_ (30 * 1024 * 1024) FX_BOOL CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext, CFX_RenderDevice* pDevice, - FX_RECT* pRect, + const FX_RECT& pRect, const CPDF_PageObject* pObj, const CPDF_RenderOptions* pOptions, int max_dpi) { - FXSYS_assert(pRect != NULL); m_pDevice = pDevice; if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_GET_BITS) { return TRUE; } m_pContext = pContext; - m_Rect = *pRect; + m_Rect = pRect; m_pObject = pObj; - m_Matrix.TranslateI(-pRect->left, -pRect->top); + m_Matrix.TranslateI(-pRect.left, -pRect.top); int horz_size = pDevice->GetDeviceCaps(FXDC_HORZ_SIZE); int vert_size = pDevice->GetDeviceCaps(FXDC_VERT_SIZE); if (horz_size && vert_size && max_dpi) { @@ -1380,7 +1376,7 @@ FX_BOOL CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext, CFX_FloatRect rect; int32_t iWidth, iHeight, iPitch; while (1) { - rect = *pRect; + rect = pRect; m_Matrix.TransformRect(rect); FX_RECT bitmap_rect = rect.GetOutterRect(); iWidth = bitmap_rect.Width(); diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp index 1d1c392af5..938a495eb1 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp @@ -344,7 +344,7 @@ FX_BOOL CPDF_ImageRenderer::StartLoadDIBSource() { m_LoadHandle, m_bStdCS, m_pRenderStatus->m_GroupFamily, m_pRenderStatus->m_bLoadMask, m_pRenderStatus, dest_width, dest_height)) { - if (m_LoadHandle != NULL) { + if (m_LoadHandle) { m_Status = 4; return TRUE; } @@ -389,7 +389,7 @@ FX_BOOL CPDF_ImageRenderer::StartRenderDIBSource() { CPDF_Color* pColor = m_pImageObject->m_ColorState.GetFillColor(); if (pColor && pColor->IsPattern()) { m_pPattern = pColor->GetPattern(); - if (m_pPattern != NULL) { + if (m_pPattern) { m_bPatternColor = TRUE; } } @@ -711,7 +711,7 @@ FX_BOOL CPDF_ImageRenderer::StartDIBSource() { if (m_pRenderStatus->m_pDevice->StartDIBits( m_pDIBSource, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags, m_DeviceHandle, 0, NULL, m_BlendType)) { - if (m_DeviceHandle != NULL) { + if (m_DeviceHandle) { m_Status = 3; return TRUE; } diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp index 70d2340c22..521ec16be1 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp @@ -788,7 +788,7 @@ int CPDF_DIBSource::StratLoadMask() { m_pMaskStream = m_pDict->GetStream("SMask"); if (m_pMaskStream) { CPDF_Array* pMatte = m_pMaskStream->GetDict()->GetArray("Matte"); - if (pMatte != NULL && m_pColorSpace && + if (pMatte && m_pColorSpace && (FX_DWORD)m_pColorSpace->CountComponents() <= m_nComponents) { FX_FLOAT R, G, B; FX_FLOAT* pColor = FX_Alloc(FX_FLOAT, m_nComponents); diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp index 3a56058295..774e749322 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp @@ -313,7 +313,7 @@ static void ReleaseCachedType3(CPDF_Type3Font* pFont) { pFont->m_pDocument->GetPageData()->ReleaseFont(pFont->GetFontDict()); } FX_BOOL CPDF_Type3Char::LoadBitmap(CPDF_RenderContext* pContext) { - if (m_pBitmap != NULL || m_pForm == NULL) { + if (m_pBitmap || m_pForm == NULL) { return TRUE; } if (m_pForm->CountObjects() == 1 && !m_bColored) { diff --git a/core/src/fpdfapi/fpdf_render/render_int.h b/core/src/fpdfapi/fpdf_render/render_int.h index d348b48dfd..26bef8ba42 100644 --- a/core/src/fpdfapi/fpdf_render/render_int.h +++ b/core/src/fpdfapi/fpdf_render/render_int.h @@ -384,7 +384,7 @@ class CPDF_ScaledRenderBuffer { FX_BOOL Initialize(CPDF_RenderContext* pContext, CFX_RenderDevice* pDevice, - FX_RECT* pRect, + const FX_RECT& pRect, const CPDF_PageObject* pObj, const CPDF_RenderOptions* pOptions = NULL, int max_dpi = 0); diff --git a/core/src/fpdfdoc/doc_action.cpp b/core/src/fpdfdoc/doc_action.cpp index 3ad746067d..87cfe7e642 100644 --- a/core/src/fpdfdoc/doc_action.cpp +++ b/core/src/fpdfdoc/doc_action.cpp @@ -34,7 +34,7 @@ const FX_CHAR* g_sATypes[] = { "SetOCGState", "Rendition", "Trans", "GoTo3DView", ""}; CPDF_Action::ActionType CPDF_Action::GetType() const { ActionType eType = Unknown; - if (m_pDict != NULL) { + if (m_pDict) { CFX_ByteString csType = m_pDict->GetString("S"); if (!csType.IsEmpty()) { int i = 0; @@ -80,7 +80,7 @@ CFX_ByteString CPDF_Action::GetURI(CPDF_Document* pDoc) const { csURI = m_pDict->GetString("URI"); CPDF_Dictionary* pRoot = pDoc->GetRoot(); CPDF_Dictionary* pURI = pRoot->GetDict("URI"); - if (pURI != NULL) { + if (pURI) { if (csURI.Find(":", 0) < 1) { csURI = pURI->GetString("Base") + csURI; } @@ -179,10 +179,7 @@ CFX_WideString CPDF_Action::GetJavaScript() const { return csJS; } CPDF_Object* pJS = m_pDict->GetElementValue("JS"); - if (pJS != NULL) { - return pJS->GetUnicodeText(); - } - return csJS; + return pJS ? pJS->GetUnicodeText() : csJS; } CPDF_Dictionary* CPDF_Action::GetAnnot() const { if (!m_pDict) { @@ -298,13 +295,13 @@ CPDF_Action CPDF_AAction::GetNextAction(FX_POSITION& pos, CPDF_DocJSActions::CPDF_DocJSActions(CPDF_Document* pDoc) : m_pDocument(pDoc) {} int CPDF_DocJSActions::CountJSActions() const { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); CPDF_NameTree name_tree(m_pDocument, "JavaScript"); return name_tree.GetCount(); } CPDF_Action CPDF_DocJSActions::GetJSAction(int index, CFX_ByteString& csName) const { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); CPDF_NameTree name_tree(m_pDocument, "JavaScript"); CPDF_Object* pAction = name_tree.LookupValue(index, csName); if (!ToDictionary(pAction)) { @@ -313,7 +310,7 @@ CPDF_Action CPDF_DocJSActions::GetJSAction(int index, return CPDF_Action(pAction->GetDict()); } CPDF_Action CPDF_DocJSActions::GetJSAction(const CFX_ByteString& csName) const { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); CPDF_NameTree name_tree(m_pDocument, "JavaScript"); CPDF_Object* pAction = name_tree.LookupValue(csName); if (!ToDictionary(pAction)) { @@ -322,7 +319,7 @@ CPDF_Action CPDF_DocJSActions::GetJSAction(const CFX_ByteString& csName) const { return CPDF_Action(pAction->GetDict()); } int CPDF_DocJSActions::FindJSAction(const CFX_ByteString& csName) const { - ASSERT(m_pDocument != NULL); + ASSERT(m_pDocument); CPDF_NameTree name_tree(m_pDocument, "JavaScript"); return name_tree.GetIndex(csName); } diff --git a/core/src/fpdfdoc/doc_annot.cpp b/core/src/fpdfdoc/doc_annot.cpp index cacd650dde..0871b357cf 100644 --- a/core/src/fpdfdoc/doc_annot.cpp +++ b/core/src/fpdfdoc/doc_annot.cpp @@ -304,7 +304,7 @@ void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice, } CPDF_Array* pColor = m_pAnnotDict->GetArray("C"); FX_DWORD argb = 0xff000000; - if (pColor != NULL) { + if (pColor) { int R = (int32_t)(pColor->GetNumber(0) * 255); int G = (int32_t)(pColor->GetNumber(1) * 255); int B = (int32_t)(pColor->GetNumber(2) * 255); diff --git a/core/src/fpdfdoc/doc_ap.cpp b/core/src/fpdfdoc/doc_ap.cpp index effe587090..1392ae6e2e 100644 --- a/core/src/fpdfdoc/doc_ap.cpp +++ b/core/src/fpdfdoc/doc_ap.cpp @@ -123,7 +123,7 @@ CFX_ByteString CPVT_FontMap::GetPDFFontAlias(int32_t nFontIndex) { return ""; } CPVT_Provider::CPVT_Provider(IPVT_FontMap* pFontMap) : m_pFontMap(pFontMap) { - ASSERT(m_pFontMap != NULL); + ASSERT(m_pFontMap); } CPVT_Provider::~CPVT_Provider() {} int32_t CPVT_Provider::GetCharWidth(int32_t nFontIndex, diff --git a/core/src/fpdfdoc/doc_basic.cpp b/core/src/fpdfdoc/doc_basic.cpp index 904ccf7c1f..c58e10b779 100644 --- a/core/src/fpdfdoc/doc_basic.cpp +++ b/core/src/fpdfdoc/doc_basic.cpp @@ -77,7 +77,7 @@ static CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, return NULL; } CPDF_Array* pLimits = pNode->GetArray("Limits"); - if (pLimits != NULL) { + if (pLimits) { CFX_ByteString csLeft = pLimits->GetString(0); CFX_ByteString csRight = pLimits->GetString(1); if (csLeft.Compare(csRight) > 0) { @@ -96,7 +96,7 @@ static CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, CFX_ByteString csValue = pNames->GetString(i * 2); int32_t iCompare = csValue.Compare(csName); if (iCompare <= 0) { - if (ppFind != NULL) { + if (ppFind) { *ppFind = pNames; } if (iCompare < 0) { @@ -144,7 +144,7 @@ static CPDF_Object* SearchNameNode(CPDF_Dictionary* pNode, nCurIndex += nCount; return NULL; } - if (ppFind != NULL) { + if (ppFind) { *ppFind = pNames; } csName = pNames->GetString((nIndex - nCurIndex) * 2); @@ -389,7 +389,6 @@ CPDF_Stream* CPDF_FileSpec::GetFileStream() const { static void FPDFDOC_FILESPEC_SetFileName(CPDF_Object* pObj, const CFX_WideStringC& wsFileName, FX_BOOL bURL) { - ASSERT(pObj != NULL); CFX_WideString wsStr; if (bURL) { wsStr = wsFileName; @@ -405,7 +404,6 @@ static void FPDFDOC_FILESPEC_SetFileName(CPDF_Object* pObj, } void CPDF_FileSpec::SetFileName(const CFX_WideStringC& wsFileName, FX_BOOL bURL) { - ASSERT(m_pObj != NULL); if (bURL) { if (CPDF_Dictionary* pDict = m_pObj->AsDictionary()) { pDict->SetAtName("FS", "URL"); @@ -483,12 +481,12 @@ CFX_WideString CPDF_PageLabel::GetLabel(int nPage) const { int n = nPage; while (n >= 0) { pValue = numberTree.LookupValue(n); - if (pValue != NULL) { + if (pValue) { break; } n--; } - if (pValue != NULL) { + if (pValue) { pValue = pValue->GetDirect(); if (CPDF_Dictionary* pLabel = pValue->AsDictionary()) { if (pLabel->KeyExist("P")) { diff --git a/core/src/fpdfdoc/doc_form.cpp b/core/src/fpdfdoc/doc_form.cpp index 0201b5c85a..0617609fc2 100644 --- a/core/src/fpdfdoc/doc_form.cpp +++ b/core/src/fpdfdoc/doc_form.cpp @@ -328,7 +328,7 @@ static int CALLBACK EnumFontFamExProc(ENUMLOGFONTEXA* lpelfe, NEWTEXTMETRICEX* lpntme, DWORD FontType, LPARAM lParam) { - if (FontType != 0x004 || strchr(lpelfe->elfLogFont.lfFaceName, '@') != NULL) { + if (FontType != 0x004 || strchr(lpelfe->elfLogFont.lfFaceName, '@')) { return 1; } LPDF_FONTDATA pData = (LPDF_FONTDATA)lParam; @@ -355,7 +355,7 @@ static FX_BOOL RetrieveSpecificFont(uint8_t charSet, memset(&lf, 0, sizeof(LOGFONTA)); lf.lfCharSet = charSet; lf.lfPitchAndFamily = pitchAndFamily; - if (pcsFontName != NULL) { + if (pcsFontName) { strcpy(lf.lfFaceName, pcsFontName); } return RetrieveSpecificFont(lf); @@ -421,7 +421,7 @@ CFX_ByteString CPDF_InterForm::GetNativeFont(uint8_t charSet, void* pLogFont) { bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, NULL, lf); } if (bRet) { - if (pLogFont != NULL) { + if (pLogFont) { memcpy(pLogFont, &lf, sizeof(LOGFONTA)); } csFontName = lf.lfFaceName; @@ -555,7 +555,7 @@ FX_BOOL CPDF_InterForm::ValidateFieldName( continue; } if (pField == pExcludedField) { - if (pExcludedControl != NULL) { + if (pExcludedControl) { if (pField->CountControls() < 2) { continue; } @@ -919,10 +919,9 @@ void CPDF_InterForm::LoadField(CPDF_Dictionary* pFieldDict, int nLevel) { } } FX_BOOL CPDF_InterForm::HasXFAForm() const { - return m_pFormDict && m_pFormDict->GetArray("XFA") != NULL; + return m_pFormDict && m_pFormDict->GetArray("XFA"); } void CPDF_InterForm::FixPageFields(const CPDF_Page* pPage) { - ASSERT(pPage != NULL); CPDF_Dictionary* pPageDict = pPage->m_pFormDict; if (pPageDict == NULL) { return; @@ -934,7 +933,7 @@ void CPDF_InterForm::FixPageFields(const CPDF_Page* pPage) { int iAnnotCount = pAnnots->GetCount(); for (int i = 0; i < iAnnotCount; i++) { CPDF_Dictionary* pAnnot = pAnnots->GetDict(i); - if (pAnnot != NULL && pAnnot->GetString("Subtype") == "Widget") { + if (pAnnot && pAnnot->GetString("Subtype") == "Widget") { LoadField(pAnnot); } } @@ -1142,7 +1141,6 @@ const struct _SupportFieldEncoding { static void FPDFDOC_FDF_GetFieldValue(CPDF_Dictionary* pFieldDict, CFX_WideString& csValue, CFX_ByteString& bsEncoding) { - ASSERT(pFieldDict != NULL); CFX_ByteString csBValue = pFieldDict->GetString("V"); int32_t iCount = sizeof(g_fieldEncoding) / sizeof(g_fieldEncoding[0]); int32_t i = 0; @@ -1153,7 +1151,7 @@ static void FPDFDOC_FDF_GetFieldValue(CPDF_Dictionary* pFieldDict, if (i < iCount) { CFX_CharMap* pCharMap = CFX_CharMap::GetDefaultMapper(g_fieldEncoding[i].m_codePage); - FXSYS_assert(pCharMap != NULL); + FXSYS_assert(pCharMap); csValue.ConvertFrom(csBValue, pCharMap); return; } @@ -1196,7 +1194,7 @@ void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict, CFX_WideString csWValue; FPDFDOC_FDF_GetFieldValue(pFieldDict, csWValue, m_bsEncoding); int iType = pField->GetFieldType(); - if (bNotify && m_pFormNotify != NULL) { + if (bNotify && m_pFormNotify) { int iRet = 0; if (iType == FIELDTYPE_LISTBOX) { iRet = m_pFormNotify->BeforeSelectionChange(pField, csWValue); @@ -1218,7 +1216,7 @@ void CPDF_InterForm::FDF_ImportField(CPDF_Dictionary* pFieldDict, pField->m_pDict->SetAt("Opt", pFieldDict->GetElementValue("Opt")->Clone(TRUE)); } - if (bNotify && m_pFormNotify != NULL) { + if (bNotify && m_pFormNotify) { if (iType == FIELDTYPE_CHECKBOX || iType == FIELDTYPE_RADIOBUTTON) { m_pFormNotify->AfterCheckedStatusChange(pField, statusArray); } else if (iType == FIELDTYPE_LISTBOX) { @@ -1245,7 +1243,7 @@ FX_BOOL CPDF_InterForm::ImportFromFDF(const CFDF_Document* pFDF, return FALSE; } m_bsEncoding = pMainDict->GetString("Encoding"); - if (bNotify && m_pFormNotify != NULL) { + if (bNotify && m_pFormNotify) { int iRet = m_pFormNotify->BeforeFormImportData(this); if (iRet < 0) { return FALSE; @@ -1258,7 +1256,7 @@ FX_BOOL CPDF_InterForm::ImportFromFDF(const CFDF_Document* pFDF, } FDF_ImportField(pField, L"", bNotify); } - if (bNotify && m_pFormNotify != NULL) { + if (bNotify && m_pFormNotify) { m_pFormNotify->AfterFormImportData(this); } return TRUE; diff --git a/core/src/fpdfdoc/doc_formfield.cpp b/core/src/fpdfdoc/doc_formfield.cpp index ca2fe05476..e14b5ad31a 100644 --- a/core/src/fpdfdoc/doc_formfield.cpp +++ b/core/src/fpdfdoc/doc_formfield.cpp @@ -103,7 +103,7 @@ FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) { case CPDF_FormField::CheckBox: case CPDF_FormField::RadioButton: { CFX_ByteArray statusArray; - if (bNotify && m_pForm->m_pFormNotify != NULL) { + if (bNotify && m_pForm->m_pFormNotify) { SaveCheckedFieldStatus(this, statusArray); } int iCount = CountControls(); @@ -120,7 +120,7 @@ FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) { } } } - if (bNotify && m_pForm->m_pFormNotify != NULL) { + if (bNotify && m_pForm->m_pFormNotify) { m_pForm->m_pFormNotify->AfterCheckedStatusChange(this, statusArray); } } break; @@ -131,14 +131,14 @@ FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) { if (iIndex >= 0) { csValue = GetOptionLabel(iIndex); } - if (bNotify && m_pForm->m_pFormNotify != NULL) { + if (bNotify && m_pForm->m_pFormNotify) { int iRet = m_pForm->m_pFormNotify->BeforeValueChange(this, csValue); if (iRet < 0) { return FALSE; } } SetItemSelection(iIndex, TRUE); - if (bNotify && m_pForm->m_pFormNotify != NULL) { + if (bNotify && m_pForm->m_pFormNotify) { m_pForm->m_pFormNotify->AfterValueChange(this); } } break; @@ -149,14 +149,14 @@ FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) { if (iIndex >= 0) { csValue = GetOptionLabel(iIndex); } - if (bNotify && m_pForm->m_pFormNotify != NULL) { + if (bNotify && m_pForm->m_pFormNotify) { int iRet = m_pForm->m_pFormNotify->BeforeSelectionChange(this, csValue); if (iRet < 0) { return FALSE; } } SetItemSelection(iIndex, TRUE); - if (bNotify && m_pForm->m_pFormNotify != NULL) { + if (bNotify && m_pForm->m_pFormNotify) { m_pForm->m_pFormNotify->AfterSelectionChange(this); } } break; @@ -166,19 +166,19 @@ FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) { default: { CPDF_Object* pDV = FPDF_GetFieldAttr(m_pDict, "DV"); CFX_WideString csDValue; - if (pDV != NULL) { + if (pDV) { csDValue = pDV->GetUnicodeText(); } CPDF_Object* pV = FPDF_GetFieldAttr(m_pDict, "V"); CFX_WideString csValue; - if (pV != NULL) { + if (pV) { csValue = pV->GetUnicodeText(); } CPDF_Object* pRV = FPDF_GetFieldAttr(m_pDict, "RV"); if (!pRV && (csDValue == csValue)) { return FALSE; } - if (bNotify && m_pForm->m_pFormNotify != NULL) { + if (bNotify && m_pForm->m_pFormNotify) { int iRet = m_pForm->m_pFormNotify->BeforeValueChange(this, csDValue); if (iRet < 0) { return FALSE; @@ -198,7 +198,7 @@ FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) { m_pDict->SetAt("RV", pCloneR); } } - if (bNotify && m_pForm->m_pFormNotify != NULL) { + if (bNotify && m_pForm->m_pFormNotify) { m_pForm->m_pFormNotify->AfterValueChange(this); } m_pForm->m_bUpdated = TRUE; @@ -331,7 +331,7 @@ FX_BOOL CPDF_FormField::SetValue(const CFX_WideString& value, case Text: case ComboBox: { CFX_WideString csValue = value; - if (bNotify && m_pForm->m_pFormNotify != NULL) { + if (bNotify && m_pForm->m_pFormNotify) { int iRet = m_pForm->m_pFormNotify->BeforeValueChange(this, csValue); if (iRet < 0) { return FALSE; @@ -353,7 +353,7 @@ FX_BOOL CPDF_FormField::SetValue(const CFX_WideString& value, SetItemSelection(iIndex, TRUE); } } - if (bNotify && m_pForm->m_pFormNotify != NULL) { + if (bNotify && m_pForm->m_pFormNotify) { m_pForm->m_pFormNotify->AfterValueChange(this); } m_pForm->m_bUpdated = TRUE; @@ -366,7 +366,7 @@ FX_BOOL CPDF_FormField::SetValue(const CFX_WideString& value, if (bDefault && iIndex == GetDefaultSelectedItem()) { return FALSE; } - if (bNotify && m_pForm->m_pFormNotify != NULL) { + if (bNotify && m_pForm->m_pFormNotify) { CFX_WideString csValue = value; int iRet = m_pForm->m_pFormNotify->BeforeSelectionChange(this, csValue); if (iRet < 0) { @@ -378,7 +378,7 @@ FX_BOOL CPDF_FormField::SetValue(const CFX_WideString& value, ClearSelection(); SetItemSelection(iIndex, TRUE); } - if (bNotify && m_pForm->m_pFormNotify != NULL) { + if (bNotify && m_pForm->m_pFormNotify) { m_pForm->m_pFormNotify->AfterSelectionChange(this); } m_pForm->m_bUpdated = TRUE; @@ -464,7 +464,7 @@ int CPDF_FormField::GetSelectedIndex(int index) { return -1; } FX_BOOL CPDF_FormField::ClearSelection(FX_BOOL bNotify) { - if (bNotify && m_pForm->m_pFormNotify != NULL) { + if (bNotify && m_pForm->m_pFormNotify) { int iRet = 0; CFX_WideString csValue; int iIndex = GetSelectedIndex(0); @@ -483,7 +483,7 @@ FX_BOOL CPDF_FormField::ClearSelection(FX_BOOL bNotify) { } m_pDict->RemoveAt("V"); m_pDict->RemoveAt("I"); - if (bNotify && m_pForm->m_pFormNotify != NULL) { + if (bNotify && m_pForm->m_pFormNotify) { if (GetType() == ListBox) { m_pForm->m_pFormNotify->AfterSelectionChange(this); } @@ -549,7 +549,7 @@ FX_BOOL CPDF_FormField::SetItemSelection(int index, return FALSE; } CFX_WideString opt_value = GetOptionValue(index); - if (bNotify && m_pForm->m_pFormNotify != NULL) { + if (bNotify && m_pForm->m_pFormNotify) { int iRet = 0; if (GetType() == ListBox) { iRet = m_pForm->m_pFormNotify->BeforeSelectionChange(this, opt_value); @@ -563,7 +563,7 @@ FX_BOOL CPDF_FormField::SetItemSelection(int index, } if (!bSelected) { CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V"); - if (pValue != NULL) { + if (pValue) { if (m_Type == ListBox) { SelectOption(index, FALSE); if (pValue->IsString()) { @@ -627,7 +627,7 @@ FX_BOOL CPDF_FormField::SetItemSelection(int index, m_pDict->SetAt("I", pI); } } - if (bNotify && m_pForm->m_pFormNotify != NULL) { + if (bNotify && m_pForm->m_pFormNotify) { if (GetType() == ListBox) { m_pForm->m_pFormNotify->AfterSelectionChange(this); } @@ -824,7 +824,7 @@ FX_BOOL CPDF_FormField::CheckControl(int iControlIndex, return FALSE; } CFX_ByteArray statusArray; - if (bNotify && m_pForm->m_pFormNotify != NULL) { + if (bNotify && m_pForm->m_pFormNotify) { SaveCheckedFieldStatus(this, statusArray); } CFX_WideString csWExport = pControl->GetExportValue(); @@ -859,7 +859,7 @@ FX_BOOL CPDF_FormField::CheckControl(int iControlIndex, } else { CFX_ByteString csV; CPDF_Object* pV = FPDF_GetFieldAttr(m_pDict, "V"); - if (pV != NULL) { + if (pV) { csV = pV->GetString(); } if (csV == csBExport) { @@ -871,7 +871,7 @@ FX_BOOL CPDF_FormField::CheckControl(int iControlIndex, csIndex.Format("%d", iControlIndex); m_pDict->SetAtName("V", csIndex); } - if (bNotify && m_pForm->m_pFormNotify != NULL) { + if (bNotify && m_pForm->m_pFormNotify) { m_pForm->m_pFormNotify->AfterCheckedStatusChange(this, statusArray); } m_pForm->m_bUpdated = TRUE; @@ -901,7 +901,7 @@ FX_BOOL CPDF_FormField::SetCheckValue(const CFX_WideString& value, FX_BOOL bNotify) { ASSERT(GetType() == CheckBox || GetType() == RadioButton); CFX_ByteArray statusArray; - if (bNotify && m_pForm->m_pFormNotify != NULL) { + if (bNotify && m_pForm->m_pFormNotify) { SaveCheckedFieldStatus(this, statusArray); } int iCount = CountControls(); @@ -921,7 +921,7 @@ FX_BOOL CPDF_FormField::SetCheckValue(const CFX_WideString& value, } } } - if (bNotify && m_pForm->m_pFormNotify != NULL) { + if (bNotify && m_pForm->m_pFormNotify) { m_pForm->m_pFormNotify->AfterCheckedStatusChange(this, statusArray); } m_pForm->m_bUpdated = TRUE; @@ -998,7 +998,7 @@ FX_BOOL CPDF_FormField::SelectOption(int iOptIndex, if (bSelected) { return TRUE; } - if (bNotify && m_pForm->m_pFormNotify != NULL) { + if (bNotify && m_pForm->m_pFormNotify) { int iRet = 0; CFX_WideString csValue = GetOptionLabel(iOptIndex); if (GetType() == ListBox) { @@ -1018,7 +1018,7 @@ FX_BOOL CPDF_FormField::SelectOption(int iOptIndex, if (!bSelected) { continue; } - if (bNotify && m_pForm->m_pFormNotify != NULL) { + if (bNotify && m_pForm->m_pFormNotify) { int iRet = 0; CFX_WideString csValue = GetOptionLabel(iOptIndex); if (GetType() == ListBox) { @@ -1048,7 +1048,7 @@ FX_BOOL CPDF_FormField::SelectOption(int iOptIndex, m_pDict->RemoveAt("I"); } } - if (bNotify && m_pForm->m_pFormNotify != NULL) { + if (bNotify && m_pForm->m_pFormNotify) { if (GetType() == ListBox) { m_pForm->m_pFormNotify->AfterSelectionChange(this); } @@ -1060,7 +1060,7 @@ FX_BOOL CPDF_FormField::SelectOption(int iOptIndex, return TRUE; } FX_BOOL CPDF_FormField::ClearSelectedOptions(FX_BOOL bNotify) { - if (bNotify && m_pForm->m_pFormNotify != NULL) { + if (bNotify && m_pForm->m_pFormNotify) { int iRet = 0; CFX_WideString csValue; int iIndex = GetSelectedIndex(0); @@ -1078,7 +1078,7 @@ FX_BOOL CPDF_FormField::ClearSelectedOptions(FX_BOOL bNotify) { } } m_pDict->RemoveAt("I"); - if (bNotify && m_pForm->m_pFormNotify != NULL) { + if (bNotify && m_pForm->m_pFormNotify) { if (GetType() == ListBox) { m_pForm->m_pFormNotify->AfterSelectionChange(this); } diff --git a/core/src/fpdfdoc/doc_ocg.cpp b/core/src/fpdfdoc/doc_ocg.cpp index 4e0e1c5a31..cfca121d36 100644 --- a/core/src/fpdfdoc/doc_ocg.cpp +++ b/core/src/fpdfdoc/doc_ocg.cpp @@ -24,7 +24,6 @@ static int32_t FPDFDOC_OCG_FindGroup(const CPDF_Object* pObject, static FX_BOOL FPDFDOC_OCG_HasIntent(const CPDF_Dictionary* pDict, const CFX_ByteStringC& csElement, const CFX_ByteStringC& csDef = "") { - FXSYS_assert(pDict != NULL); CPDF_Object* pIntent = pDict->GetElementValue("Intent"); if (pIntent == NULL) { return csElement == csDef; @@ -89,7 +88,7 @@ static CFX_ByteString FPDFDOC_OCG_GetUsageTypeString( return csState; } CPDF_OCContext::CPDF_OCContext(CPDF_Document* pDoc, UsageType eUsageType) { - FXSYS_assert(pDoc != NULL); + FXSYS_assert(pDoc); m_pDocument = pDoc; m_eUsageType = eUsageType; } @@ -235,9 +234,8 @@ FX_BOOL CPDF_OCContext::GetOCGVE(CPDF_Array* pExpression, } FX_BOOL CPDF_OCContext::LoadOCMDState(const CPDF_Dictionary* pOCMDDict, FX_BOOL bFromConfig) { - FXSYS_assert(pOCMDDict != NULL); CPDF_Array* pVE = pOCMDDict->GetArray("VE"); - if (pVE != NULL) { + if (pVE) { return GetOCGVE(pVE, bFromConfig); } CFX_ByteString csP = pOCMDDict->GetString("P", "AnyOn"); diff --git a/core/src/fpdfdoc/doc_utils.cpp b/core/src/fpdfdoc/doc_utils.cpp index adf523f74e..f26355fae5 100644 --- a/core/src/fpdfdoc/doc_utils.cpp +++ b/core/src/fpdfdoc/doc_utils.cpp @@ -242,7 +242,7 @@ void InitInterFormDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) { CFX_ByteString csBaseName, csDefault; uint8_t charSet = CPDF_InterForm::GetNativeCharSet(); pFont = CPDF_InterForm::AddStandardFont(pDocument, "Helvetica"); - if (pFont != NULL) { + if (pFont) { AddInterFormFont(pFormDict, pDocument, pFont, csBaseName); csDefault = csBaseName; } @@ -250,14 +250,14 @@ void InitInterFormDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) { CFX_ByteString csFontName = CPDF_InterForm::GetNativeFont(charSet, NULL); if (pFont == NULL || csFontName != "Helvetica") { pFont = CPDF_InterForm::AddNativeFont(pDocument); - if (pFont != NULL) { + if (pFont) { csBaseName = ""; AddInterFormFont(pFormDict, pDocument, pFont, csBaseName); csDefault = csBaseName; } } } - if (pFont != NULL) { + if (pFont) { csDA = "/" + PDF_NameEncode(csDefault) + " 0 Tf"; } } @@ -452,9 +452,9 @@ CPDF_Font* GetNativeInterFormFont(CPDF_Dictionary* pFormDict, uint8_t charSet = CPDF_InterForm::GetNativeCharSet(); CFX_SubstFont* pSubst; CPDF_Font* pFont = GetDefaultInterFormFont(pFormDict, pDocument); - if (pFont != NULL) { + if (pFont) { pSubst = (CFX_SubstFont*)pFont->GetSubstFont(); - if (pSubst != NULL && pSubst->m_Charset == (int)charSet) { + if (pSubst && pSubst->m_Charset == (int)charSet) { FindInterFormFont(pFormDict, pFont, csNameTag); return pFont; } @@ -592,7 +592,7 @@ CPDF_Font* AddNativeInterFormFont(CPDF_Dictionary*& pFormDict, CFX_ByteString csTemp; CPDF_Font* pFont = GetNativeInterFormFont(pFormDict, pDocument, charSet, csTemp); - if (pFont != NULL) { + if (pFont) { csNameTag = csTemp; return pFont; } @@ -603,7 +603,7 @@ CPDF_Font* AddNativeInterFormFont(CPDF_Dictionary*& pFormDict, } } pFont = CPDF_InterForm::AddNativeFont(charSet, pDocument); - if (pFont != NULL) { + if (pFont) { AddInterFormFont(pFormDict, pDocument, pFont, csNameTag); } return pFont; @@ -679,7 +679,7 @@ void CPDF_IconFit::GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom) { return; } CPDF_Array* pA = m_pDict->GetArray("A"); - if (pA != NULL) { + if (pA) { FX_DWORD dwCount = pA->GetCount(); if (dwCount > 0) { fLeft = pA->GetNumber(0); diff --git a/core/src/fpdfdoc/doc_vt.cpp b/core/src/fpdfdoc/doc_vt.cpp index 07824e8f04..8df687ed59 100644 --- a/core/src/fpdfdoc/doc_vt.cpp +++ b/core/src/fpdfdoc/doc_vt.cpp @@ -84,7 +84,6 @@ CPVT_WordPlace CSection::AddLine(const CPVT_LineInfo& lineinfo) { return CPVT_WordPlace(SecPlace.nSecIndex, m_LineArray.Add(lineinfo), -1); } CPVT_FloatRect CSection::Rearrange() { - ASSERT(m_pVT != NULL); if (m_pVT->m_nCharArray > 0) { return CTypeset(this).CharArray(); } @@ -166,7 +165,7 @@ void CSection::UpdateWordPlace(CPVT_WordPlace& place) const { } } CPVT_WordPlace CSection::SearchWordPlace(const CPDF_Point& point) const { - ASSERT(m_pVT != NULL); + ASSERT(m_pVT); CPVT_WordPlace place = GetBeginWordPlace(); FX_BOOL bUp = TRUE; FX_BOOL bDown = TRUE; @@ -306,8 +305,7 @@ CTypeset::CTypeset(CSection* pSection) m_pSection(pSection) {} CTypeset::~CTypeset() {} CPVT_FloatRect CTypeset::CharArray() { - ASSERT(m_pSection != NULL); - ASSERT(m_pVT != NULL); + ASSERT(m_pSection); FX_FLOAT fLineAscent = m_pVT->GetFontAscent(m_pVT->GetDefaultFontIndex(), m_pVT->GetFontSize()); FX_FLOAT fLineDescent = @@ -382,14 +380,13 @@ CPVT_FloatRect CTypeset::CharArray() { return m_rcRet = CPVT_FloatRect(0, 0, x, y); } CPVT_Size CTypeset::GetEditSize(FX_FLOAT fFontSize) { - ASSERT(m_pSection != NULL); - ASSERT(m_pVT != NULL); + ASSERT(m_pSection); + ASSERT(m_pVT); SplitLines(FALSE, fFontSize); return CPVT_Size(m_rcRet.Width(), m_rcRet.Height()); } CPVT_FloatRect CTypeset::Typeset() { - ASSERT(m_pSection != NULL); - ASSERT(m_pVT != NULL); + ASSERT(m_pVT); m_pSection->m_LineArray.Empty(); SplitLines(TRUE, 0.0f); m_pSection->m_LineArray.Clear(); @@ -571,8 +568,8 @@ static FX_BOOL NeedDivision(FX_WORD prevWord, FX_WORD curWord) { return FALSE; } void CTypeset::SplitLines(FX_BOOL bTypeset, FX_FLOAT fFontSize) { - ASSERT(m_pVT != NULL); - ASSERT(m_pSection != NULL); + ASSERT(m_pVT); + ASSERT(m_pSection); int32_t nLineHead = 0; int32_t nLineTail = 0; FX_FLOAT fMaxX = 0.0f, fMaxY = 0.0f; @@ -619,7 +616,7 @@ void CTypeset::SplitLines(FX_BOOL bTypeset, FX_FLOAT fFontSize) { if (IsOpenStylePunctuation(pWord->Word)) { bOpened = TRUE; bFullWord = TRUE; - } else if (pOldWord != NULL) { + } else if (pOldWord) { if (NeedDivision(pOldWord->Word, pWord->Word)) { bFullWord = TRUE; } @@ -718,8 +715,8 @@ void CTypeset::SplitLines(FX_BOOL bTypeset, FX_FLOAT fFontSize) { m_rcRet = CPVT_FloatRect(0, 0, fMaxX, fMaxY); } void CTypeset::OutputLines() { - ASSERT(m_pVT != NULL); - ASSERT(m_pSection != NULL); + ASSERT(m_pVT); + ASSERT(m_pSection); FX_FLOAT fMinX = 0.0f, fMinY = 0.0f, fMaxX = 0.0f, fMaxY = 0.0f; FX_FLOAT fPosX = 0.0f, fPosY = 0.0f; FX_FLOAT fLineIndent = m_pVT->GetLineIndent(m_pSection->m_SecInfo); @@ -1677,11 +1674,10 @@ CPDF_VariableText_Iterator::CPDF_VariableText_Iterator(CPDF_VariableText* pVT) : m_CurPos(-1, -1, -1), m_pVT(pVT) {} CPDF_VariableText_Iterator::~CPDF_VariableText_Iterator() {} void CPDF_VariableText_Iterator::SetAt(int32_t nWordIndex) { - ASSERT(m_pVT != NULL); m_CurPos = m_pVT->WordIndexToWordPlace(nWordIndex); } void CPDF_VariableText_Iterator::SetAt(const CPVT_WordPlace& place) { - ASSERT(m_pVT != NULL); + ASSERT(m_pVT); m_CurPos = place; } FX_BOOL CPDF_VariableText_Iterator::NextWord() { @@ -1738,7 +1734,7 @@ FX_BOOL CPDF_VariableText_Iterator::NextSection() { return FALSE; } FX_BOOL CPDF_VariableText_Iterator::PrevSection() { - ASSERT(m_pVT != NULL); + ASSERT(m_pVT); if (m_CurPos.nSecIndex > 0) { m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex - 1, 0, -1); return TRUE; @@ -1746,7 +1742,6 @@ FX_BOOL CPDF_VariableText_Iterator::PrevSection() { return FALSE; } FX_BOOL CPDF_VariableText_Iterator::GetWord(CPVT_Word& word) const { - ASSERT(m_pVT != NULL); word.WordPlace = m_CurPos; if (CSection* pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { if (pSection->m_LineArray.GetAt(m_CurPos.nLineIndex)) { @@ -1772,7 +1767,6 @@ FX_BOOL CPDF_VariableText_Iterator::GetWord(CPVT_Word& word) const { return FALSE; } FX_BOOL CPDF_VariableText_Iterator::SetWord(const CPVT_Word& word) { - ASSERT(m_pVT != NULL); if (CSection* pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { if (CPVT_WordInfo* pWord = pSection->m_WordArray.GetAt(m_CurPos.nWordIndex)) { @@ -1785,7 +1779,7 @@ FX_BOOL CPDF_VariableText_Iterator::SetWord(const CPVT_Word& word) { return FALSE; } FX_BOOL CPDF_VariableText_Iterator::GetLine(CPVT_Line& line) const { - ASSERT(m_pVT != NULL); + ASSERT(m_pVT); line.lineplace = CPVT_WordPlace(m_CurPos.nSecIndex, m_CurPos.nLineIndex, -1); if (CSection* pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { if (CLine* pLine = pSection->m_LineArray.GetAt(m_CurPos.nLineIndex)) { @@ -1802,7 +1796,6 @@ FX_BOOL CPDF_VariableText_Iterator::GetLine(CPVT_Line& line) const { return FALSE; } FX_BOOL CPDF_VariableText_Iterator::GetSection(CPVT_Section& section) const { - ASSERT(m_pVT != NULL); section.secplace = CPVT_WordPlace(m_CurPos.nSecIndex, 0, -1); if (CSection* pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { section.rcSection = m_pVT->InToOut(pSection->m_SecInfo.rcSection); @@ -1817,7 +1810,6 @@ FX_BOOL CPDF_VariableText_Iterator::GetSection(CPVT_Section& section) const { return FALSE; } FX_BOOL CPDF_VariableText_Iterator::SetSection(const CPVT_Section& section) { - ASSERT(m_pVT != NULL); if (CSection* pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { if (pSection->m_SecInfo.pSecProps) { *pSection->m_SecInfo.pSecProps = section.SecProps; diff --git a/core/src/fxcodec/codec/fx_codec_jpeg.cpp b/core/src/fxcodec/codec/fx_codec_jpeg.cpp index 1276219123..0bb9e8aa26 100644 --- a/core/src/fxcodec/codec/fx_codec_jpeg.cpp +++ b/core/src/fxcodec/codec/fx_codec_jpeg.cpp @@ -297,10 +297,10 @@ static FX_BOOL _JpegLoadInfo(const uint8_t* src_buf, color_transform = cinfo.jpeg_color_space == JCS_YCbCr || cinfo.jpeg_color_space == JCS_YCCK; bits_per_components = cinfo.data_precision; - if (icc_buf_ptr != NULL) { + if (icc_buf_ptr) { *icc_buf_ptr = NULL; } - if (icc_length != NULL) { + if (icc_length) { *icc_length = 0; } jpeg_destroy_decompress(&cinfo); @@ -546,7 +546,7 @@ FX_BOOL CCodec_JpegModule::Encode(const CFX_DIBSource* pSource, int quality, const uint8_t* icc_buf, FX_DWORD icc_length) { - if (pSource->GetBPP() < 8 || pSource->GetPalette() != NULL) { + if (pSource->GetBPP() < 8 || pSource->GetPalette()) { ASSERT(pSource->GetBPP() >= 8 && pSource->GetPalette() == NULL); return FALSE; } @@ -682,7 +682,7 @@ FX_BOOL CCodec_JpegModule::ReadScanline(void* pContext, } FX_DWORD CCodec_JpegModule::GetAvailInput(void* pContext, uint8_t** avail_buf_ptr) { - if (avail_buf_ptr != NULL) { + if (avail_buf_ptr) { *avail_buf_ptr = NULL; if (((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) { *avail_buf_ptr = diff --git a/core/src/fxcrt/fx_basic_bstring.cpp b/core/src/fxcrt/fx_basic_bstring.cpp index 7576ab86eb..cd4770282a 100644 --- a/core/src/fxcrt/fx_basic_bstring.cpp +++ b/core/src/fxcrt/fx_basic_bstring.cpp @@ -295,7 +295,7 @@ void CFX_ByteString::CopyBeforeWrite() { m_pData->Release(); FX_STRSIZE nDataLength = pData->m_nDataLength; m_pData = StringData::Create(nDataLength); - if (m_pData != NULL) { + if (m_pData) { FXSYS_memcpy(m_pData->m_String, pData->m_String, nDataLength + 1); } } @@ -698,7 +698,7 @@ FX_STRSIZE CFX_ByteString::Insert(FX_STRSIZE nIndex, FX_CHAR ch) { if (!m_pData) { return 0; } - if (pOldData != NULL) { + if (pOldData) { FXSYS_memmove(m_pData->m_String, pstr, (pOldData->m_nDataLength + 1)); pOldData->Release(); } else { diff --git a/core/src/fxcrt/fx_basic_buffer.cpp b/core/src/fxcrt/fx_basic_buffer.cpp index cc72e471f1..e5c6c6d4b9 100644 --- a/core/src/fxcrt/fx_basic_buffer.cpp +++ b/core/src/fxcrt/fx_basic_buffer.cpp @@ -151,7 +151,7 @@ void CFX_WideTextBuf::AppendChar(FX_WCHAR ch) { if (m_AllocSize < m_DataSize + (FX_STRSIZE)sizeof(FX_WCHAR)) { ExpandBuf(sizeof(FX_WCHAR)); } - ASSERT(m_pBuffer != NULL); + ASSERT(m_pBuffer); *(FX_WCHAR*)(m_pBuffer + m_DataSize) = ch; m_DataSize += sizeof(FX_WCHAR); } @@ -170,7 +170,7 @@ CFX_WideTextBuf& CFX_WideTextBuf::operator<<(int i) { if (m_AllocSize < m_DataSize + (FX_STRSIZE)(len * sizeof(FX_WCHAR))) { ExpandBuf(len * sizeof(FX_WCHAR)); } - ASSERT(m_pBuffer != NULL); + ASSERT(m_pBuffer); FX_WCHAR* str = (FX_WCHAR*)(m_pBuffer + m_DataSize); for (FX_STRSIZE j = 0; j < len; j++) { *str++ = buf[j]; @@ -184,7 +184,7 @@ CFX_WideTextBuf& CFX_WideTextBuf::operator<<(double f) { if (m_AllocSize < m_DataSize + (FX_STRSIZE)(len * sizeof(FX_WCHAR))) { ExpandBuf(len * sizeof(FX_WCHAR)); } - ASSERT(m_pBuffer != NULL); + ASSERT(m_pBuffer); FX_WCHAR* str = (FX_WCHAR*)(m_pBuffer + m_DataSize); for (FX_STRSIZE i = 0; i < len; i++) { *str++ = buf[i]; diff --git a/core/src/fxcrt/fx_basic_list.cpp b/core/src/fxcrt/fx_basic_list.cpp index de5d9f3269..292e2a7b53 100644 --- a/core/src/fxcrt/fx_basic_list.cpp +++ b/core/src/fxcrt/fx_basic_list.cpp @@ -17,7 +17,7 @@ CFX_PtrList::CFX_PtrList(int nBlockSize) FX_POSITION CFX_PtrList::AddTail(void* newElement) { CNode* pNewNode = NewNode(m_pNodeTail, NULL); pNewNode->data = newElement; - if (m_pNodeTail != NULL) { + if (m_pNodeTail) { m_pNodeTail->pNext = pNewNode; } else { m_pNodeHead = pNewNode; @@ -28,7 +28,7 @@ FX_POSITION CFX_PtrList::AddTail(void* newElement) { FX_POSITION CFX_PtrList::AddHead(void* newElement) { CNode* pNewNode = NewNode(NULL, m_pNodeHead); pNewNode->data = newElement; - if (m_pNodeHead != NULL) { + if (m_pNodeHead) { m_pNodeHead->pPrev = pNewNode; } else { m_pNodeTail = pNewNode; @@ -43,7 +43,7 @@ FX_POSITION CFX_PtrList::InsertAfter(FX_POSITION position, void* newElement) { CNode* pOldNode = (CNode*)position; CNode* pNewNode = NewNode(pOldNode, pOldNode->pNext); pNewNode->data = newElement; - if (pOldNode->pNext != NULL) { + if (pOldNode->pNext) { pOldNode->pNext->pPrev = pNewNode; } else { m_pNodeTail = pNewNode; @@ -91,7 +91,6 @@ CFX_PtrList::CNode* CFX_PtrList::NewNode(CFX_PtrList::CNode* pPrev, m_pNodeFree = pNode; } } - ASSERT(m_pNodeFree != NULL); CFX_PtrList::CNode* pNode = m_pNodeFree; m_pNodeFree = m_pNodeFree->pNext; pNode->pPrev = pPrev; @@ -122,9 +121,9 @@ FX_POSITION CFX_PtrList::Find(void* searchValue, FX_POSITION startAfter) const { } else { pNode = pNode->pNext; } - for (; pNode != NULL; pNode = pNode->pNext) - if (pNode->data == searchValue) { + for (; pNode; pNode = pNode->pNext) { + if (pNode->data == searchValue) return (FX_POSITION)pNode; - } + } return NULL; } diff --git a/core/src/fxcrt/fx_basic_maps.cpp b/core/src/fxcrt/fx_basic_maps.cpp index aadeb15cb4..f8751ae340 100644 --- a/core/src/fxcrt/fx_basic_maps.cpp +++ b/core/src/fxcrt/fx_basic_maps.cpp @@ -34,15 +34,15 @@ FX_DWORD CFX_MapPtrToPtr::HashKey(void* key) const { void CFX_MapPtrToPtr::GetNextAssoc(FX_POSITION& rNextPosition, void*& rKey, void*& rValue) const { - ASSERT(m_pHashTable != NULL); + ASSERT(m_pHashTable); CAssoc* pAssocRet = (CAssoc*)rNextPosition; - ASSERT(pAssocRet != NULL); + ASSERT(pAssocRet); if (pAssocRet == (CAssoc*)-1) { - for (FX_DWORD nBucket = 0; nBucket < m_nHashTableSize; nBucket++) - if ((pAssocRet = m_pHashTable[nBucket]) != NULL) { + for (FX_DWORD nBucket = 0; nBucket < m_nHashTableSize; nBucket++) { + if ((pAssocRet = m_pHashTable[nBucket]) != NULL) break; - } - ASSERT(pAssocRet != NULL); + } + ASSERT(pAssocRet); } CAssoc* pAssocNext; if ((pAssocNext = pAssocRet->pNext) == NULL) { @@ -95,10 +95,9 @@ CFX_MapPtrToPtr::CAssoc* CFX_MapPtrToPtr::GetAssocAt(void* key, return NULL; } CAssoc* pAssoc; - for (pAssoc = m_pHashTable[nHash]; pAssoc != NULL; pAssoc = pAssoc->pNext) { - if (pAssoc->key == key) { + for (pAssoc = m_pHashTable[nHash]; pAssoc; pAssoc = pAssoc->pNext) { + if (pAssoc->key == key) return pAssoc; - } } return NULL; } @@ -114,7 +113,6 @@ CFX_MapPtrToPtr::CAssoc* CFX_MapPtrToPtr::NewAssoc() { m_pFreeList = pAssoc; } } - ASSERT(m_pFreeList != NULL); CFX_MapPtrToPtr::CAssoc* pAssoc = m_pFreeList; m_pFreeList = m_pFreeList->pNext; m_nCount++; @@ -140,7 +138,7 @@ FX_BOOL CFX_MapPtrToPtr::RemoveKey(void* key) { CAssoc** ppAssocPrev; ppAssocPrev = &m_pHashTable[HashKey(key) % m_nHashTableSize]; CAssoc* pAssoc; - for (pAssoc = *ppAssocPrev; pAssoc != NULL; pAssoc = pAssoc->pNext) { + for (pAssoc = *ppAssocPrev; pAssoc; pAssoc = pAssoc->pNext) { if (pAssoc->key == key) { *ppAssocPrev = pAssoc->pNext; FreeAssoc(pAssoc); @@ -293,10 +291,10 @@ FX_BOOL CFX_CMapByteStringToPtr::Lookup(const CFX_ByteStringC& key, return TRUE; } void CFX_CMapByteStringToPtr::SetAt(const CFX_ByteStringC& key, void* value) { - ASSERT(value != NULL); - int index, key_len = key.GetLength(); + ASSERT(value); + int key_len = key.GetLength(); int size = m_Buffer.GetSize(); - for (index = 0; index < size; index++) { + for (int index = 0; index < size; index++) { _CompactString* pKey = (_CompactString*)m_Buffer.GetAt(index); if (!_CompactStringSame(pKey, key.GetPtr(), key_len)) { continue; @@ -304,7 +302,7 @@ void CFX_CMapByteStringToPtr::SetAt(const CFX_ByteStringC& key, void* value) { *(void**)(pKey + 1) = value; return; } - for (index = 0; index < size; index++) { + for (int index = 0; index < size; index++) { _CompactString* pKey = (_CompactString*)m_Buffer.GetAt(index); if (pKey->m_CompactLen) { continue; @@ -319,7 +317,7 @@ void CFX_CMapByteStringToPtr::SetAt(const CFX_ByteStringC& key, void* value) { } void CFX_CMapByteStringToPtr::AddValue(const CFX_ByteStringC& key, void* value) { - ASSERT(value != NULL); + ASSERT(value); _CompactString* pKey = (_CompactString*)m_Buffer.Add(); _CompactStringStore(pKey, key.GetPtr(), key.GetLength()); *(void**)(pKey + 1) = value; diff --git a/core/src/fxcrt/fx_basic_plex.cpp b/core/src/fxcrt/fx_basic_plex.cpp index b6383ecf20..91cc1313bd 100644 --- a/core/src/fxcrt/fx_basic_plex.cpp +++ b/core/src/fxcrt/fx_basic_plex.cpp @@ -18,10 +18,9 @@ CFX_Plex* CFX_Plex::Create(CFX_Plex*& pHead, } void CFX_Plex::FreeDataChain() { CFX_Plex* p = this; - while (p != NULL) { - uint8_t* bytes = (uint8_t*)p; - CFX_Plex* pNext = p->pNext; - FX_Free(bytes); - p = pNext; + while (p) { + CFX_Plex* old = p; + p = p->pNext; + FX_Free(old); } } diff --git a/core/src/fxcrt/fx_basic_utf.cpp b/core/src/fxcrt/fx_basic_utf.cpp index 749e1226d3..3625feb130 100644 --- a/core/src/fxcrt/fx_basic_utf.cpp +++ b/core/src/fxcrt/fx_basic_utf.cpp @@ -74,7 +74,7 @@ void CFX_UTF8Encoder::Input(FX_WCHAR unicode) { } } CFX_ByteString FX_UTF8Encode(const FX_WCHAR* pwsStr, FX_STRSIZE len) { - FXSYS_assert(pwsStr != NULL); + FXSYS_assert(pwsStr); if (len < 0) { len = FXSYS_wcslen(pwsStr); } diff --git a/core/src/fxcrt/fx_basic_wstring.cpp b/core/src/fxcrt/fx_basic_wstring.cpp index 78746e383c..a3de140e8b 100644 --- a/core/src/fxcrt/fx_basic_wstring.cpp +++ b/core/src/fxcrt/fx_basic_wstring.cpp @@ -258,7 +258,7 @@ void CFX_WideString::CopyBeforeWrite() { m_pData->Release(); FX_STRSIZE nDataLength = pData->m_nDataLength; m_pData = StringData::Create(nDataLength); - if (m_pData != NULL) { + if (m_pData) { FXSYS_memcpy(m_pData->m_String, pData->m_String, (nDataLength + 1) * sizeof(FX_WCHAR)); } @@ -540,7 +540,7 @@ FX_STRSIZE CFX_WideString::Find(FX_WCHAR ch, FX_STRSIZE nStart) const { return (lpsz == NULL) ? -1 : (int)(lpsz - m_pData->m_String); } void CFX_WideString::TrimRight(const FX_WCHAR* lpszTargetList) { - FXSYS_assert(lpszTargetList != NULL); + FXSYS_assert(lpszTargetList); if (m_pData == NULL || *lpszTargetList == 0) { return; } @@ -569,7 +569,7 @@ void CFX_WideString::TrimRight() { TrimRight(L"\x09\x0a\x0b\x0c\x0d\x20"); } void CFX_WideString::TrimLeft(const FX_WCHAR* lpszTargets) { - FXSYS_assert(lpszTargets != NULL); + FXSYS_assert(lpszTargets); if (m_pData == NULL || *lpszTargets == 0) { return; } @@ -617,7 +617,7 @@ FX_STRSIZE CFX_WideString::Replace(const FX_WCHAR* lpszOld, FX_WCHAR* lpszEnd = m_pData->m_String + m_pData->m_nDataLength; FX_WCHAR* lpszTarget; { - while ((lpszTarget = (FX_WCHAR*)FXSYS_wcsstr(lpszStart, lpszOld)) != NULL && + while ((lpszTarget = (FX_WCHAR*)FXSYS_wcsstr(lpszStart, lpszOld)) && lpszStart < lpszEnd) { nCount++; lpszStart = lpszTarget + nSourceLen; @@ -678,7 +678,7 @@ FX_STRSIZE CFX_WideString::Insert(FX_STRSIZE nIndex, FX_WCHAR ch) { if (!m_pData) { return 0; } - if (pOldData != NULL) { + if (pOldData) { FXSYS_memmove(m_pData->m_String, pstr, (pOldData->m_nDataLength + 1) * sizeof(FX_WCHAR)); pOldData->Release(); diff --git a/core/src/fxcrt/fx_extension.cpp b/core/src/fxcrt/fx_extension.cpp index 84186fb769..fd1ecafe06 100644 --- a/core/src/fxcrt/fx_extension.cpp +++ b/core/src/fxcrt/fx_extension.cpp @@ -76,7 +76,7 @@ FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x) { FX_FLOAT FXSYS_strtof(const FX_CHAR* pcsStr, int32_t iLength, int32_t* pUsedLen) { - FXSYS_assert(pcsStr != NULL); + FXSYS_assert(pcsStr); if (iLength < 0) { iLength = (int32_t)FXSYS_strlen(pcsStr); } @@ -86,7 +86,7 @@ FX_FLOAT FXSYS_strtof(const FX_CHAR* pcsStr, FX_FLOAT FXSYS_wcstof(const FX_WCHAR* pwsStr, int32_t iLength, int32_t* pUsedLen) { - FXSYS_assert(pwsStr != NULL); + FXSYS_assert(pwsStr); if (iLength < 0) { iLength = (int32_t)FXSYS_wcslen(pwsStr); } @@ -132,7 +132,7 @@ FX_FLOAT FXSYS_wcstof(const FX_WCHAR* pwsStr, FX_WCHAR* FXSYS_wcsncpy(FX_WCHAR* dstStr, const FX_WCHAR* srcStr, size_t count) { - FXSYS_assert(dstStr != NULL && srcStr != NULL && count > 0); + FXSYS_assert(dstStr && srcStr && count > 0); for (size_t i = 0; i < count; ++i) if ((dstStr[i] = srcStr[i]) == L'\0') { break; @@ -140,7 +140,7 @@ FX_WCHAR* FXSYS_wcsncpy(FX_WCHAR* dstStr, return dstStr; } int32_t FXSYS_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t count) { - FXSYS_assert(s1 != NULL && s2 != NULL && count > 0); + FXSYS_assert(s1 && s2 && count > 0); FX_WCHAR wch1 = 0, wch2 = 0; while (count-- > 0) { wch1 = (FX_WCHAR)FXSYS_tolower(*s1++); @@ -152,7 +152,7 @@ int32_t FXSYS_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t count) { return wch1 - wch2; } int32_t FXSYS_strnicmp(const FX_CHAR* s1, const FX_CHAR* s2, size_t count) { - FXSYS_assert(s1 != NULL && s2 != NULL && count > 0); + FXSYS_assert(s1 && s2 && count > 0); FX_CHAR ch1 = 0, ch2 = 0; while (count-- > 0) { ch1 = (FX_CHAR)FXSYS_tolower(*s1++); @@ -166,7 +166,7 @@ int32_t FXSYS_strnicmp(const FX_CHAR* s1, const FX_CHAR* s2, size_t count) { FX_DWORD FX_HashCode_String_GetA(const FX_CHAR* pStr, int32_t iLength, FX_BOOL bIgnoreCase) { - FXSYS_assert(pStr != NULL); + FXSYS_assert(pStr); if (iLength < 0) { iLength = (int32_t)FXSYS_strlen(pStr); } @@ -186,7 +186,7 @@ FX_DWORD FX_HashCode_String_GetA(const FX_CHAR* pStr, FX_DWORD FX_HashCode_String_GetW(const FX_WCHAR* pStr, int32_t iLength, FX_BOOL bIgnoreCase) { - FXSYS_assert(pStr != NULL); + FXSYS_assert(pStr); if (iLength < 0) { iLength = (int32_t)FXSYS_wcslen(pStr); } @@ -216,7 +216,7 @@ void* FX_Random_MT_Start(FX_DWORD dwSeed) { return pContext; } FX_DWORD FX_Random_MT_Generate(void* pContext) { - FXSYS_assert(pContext != NULL); + FXSYS_assert(pContext); FX_LPMTRANDOMCONTEXT pMTC = (FX_LPMTRANDOMCONTEXT)pContext; FX_DWORD v; static FX_DWORD mag[2] = {0, MT_Matrix_A}; @@ -247,7 +247,7 @@ FX_DWORD FX_Random_MT_Generate(void* pContext) { return v; } void FX_Random_MT_Close(void* pContext) { - FXSYS_assert(pContext != NULL); + FXSYS_assert(pContext); FX_Free(pContext); } void FX_Random_GenerateMT(FX_DWORD* pBuffer, int32_t iCount) { diff --git a/core/src/fxcrt/fx_xml_parser.cpp b/core/src/fxcrt/fx_xml_parser.cpp index dcae0c58c0..56fbada3ad 100644 --- a/core/src/fxcrt/fx_xml_parser.cpp +++ b/core/src/fxcrt/fx_xml_parser.cpp @@ -819,7 +819,6 @@ int CXML_AttrMap::GetSize() const { return m_pMap == NULL ? 0 : m_pMap->GetSize(); } CXML_AttrItem& CXML_AttrMap::GetAt(int index) const { - ASSERT(m_pMap != NULL); return (*m_pMap)[index]; } void CXML_AttrMap::RemoveAll() { diff --git a/core/src/fxcrt/xml_int.h b/core/src/fxcrt/xml_int.h index 39c288afa8..b11a64b505 100644 --- a/core/src/fxcrt/xml_int.h +++ b/core/src/fxcrt/xml_int.h @@ -48,7 +48,7 @@ class CXML_DataStmAcc : public IFX_BufferRead { public: CXML_DataStmAcc(IFX_FileRead* pFileRead) : m_pFileRead(pFileRead), m_pBuffer(NULL), m_nStart(0), m_dwSize(0) { - FXSYS_assert(m_pFileRead != NULL); + FXSYS_assert(m_pFileRead); } ~CXML_DataStmAcc() override { FX_Free(m_pBuffer); } diff --git a/core/src/fxge/dib/fx_dib_main.cpp b/core/src/fxge/dib/fx_dib_main.cpp index 6d37db9680..44d6c5022c 100644 --- a/core/src/fxge/dib/fx_dib_main.cpp +++ b/core/src/fxge/dib/fx_dib_main.cpp @@ -844,7 +844,6 @@ FX_BOOL CFX_DIBitmap::MultiplyAlpha(const CFX_DIBSource* pSrcBitmap) { if (pSrcBitmap->GetWidth() != m_Width || pSrcBitmap->GetHeight() != m_Height) { pSrcClone = pSrcBitmap->StretchTo(m_Width, m_Height); - ASSERT(pSrcClone != NULL); if (pSrcClone == NULL) { return FALSE; } @@ -1340,7 +1339,7 @@ FX_BOOL CFX_DIBitmap::DitherFS(const FX_DWORD* pPalette, if (m_pBuffer == NULL) { return FALSE; } - if (m_bpp != 8 && m_pPalette != NULL && m_AlphaFlag != 0) { + if (m_bpp != 8 && m_pPalette && m_AlphaFlag != 0) { return FALSE; } if (m_Width < 4 && m_Height < 4) { diff --git a/core/src/fxge/ge/fx_ge_device.cpp b/core/src/fxge/ge/fx_ge_device.cpp index 94efd864c0..37204268f2 100644 --- a/core/src/fxge/ge/fx_ge_device.cpp +++ b/core/src/fxge/ge/fx_ge_device.cpp @@ -19,7 +19,6 @@ void CFX_RenderDevice::SetDeviceDriver(IFX_RenderDeviceDriver* pDriver) { InitDeviceInfo(); } void CFX_RenderDevice::InitDeviceInfo() { - ASSERT(m_pDeviceDriver != NULL); m_Width = m_pDeviceDriver->GetDeviceCaps(FXDC_PIXEL_WIDTH); m_Height = m_pDeviceDriver->GetDeviceCaps(FXDC_PIXEL_HEIGHT); m_bpp = m_pDeviceDriver->GetDeviceCaps(FXDC_BITS_PIXEL); diff --git a/core/src/fxge/ge/fx_ge_ps.cpp b/core/src/fxge/ge/fx_ge_ps.cpp index 6ce8f4635b..ceb2acf2bc 100644 --- a/core/src/fxge/ge/fx_ge_ps.cpp +++ b/core/src/fxge/ge/fx_ge_ps.cpp @@ -417,7 +417,7 @@ FX_BOOL CFX_PSRenderer::DrawDIBits(const CFX_DIBSource* pSource, pConverted = pSource->CloneConvert(FXDIB_Rgb); break; case FXDIB_8bppRgb: - if (pSource->GetPalette() != NULL) { + if (pSource->GetPalette()) { pConverted = pSource->CloneConvert(FXDIB_Rgb); } break; @@ -425,7 +425,7 @@ FX_BOOL CFX_PSRenderer::DrawDIBits(const CFX_DIBSource* pSource, pConverted = pSource->CloneConvert(FXDIB_Cmyk); break; case FXDIB_8bppCmyk: - if (pSource->GetPalette() != NULL) { + if (pSource->GetPalette()) { pConverted = pSource->CloneConvert(FXDIB_Cmyk); } break; diff --git a/core/src/fxge/ge/fx_ge_text.cpp b/core/src/fxge/ge/fx_ge_text.cpp index d330576433..cd6b690a12 100644 --- a/core/src/fxge/ge/fx_ge_text.cpp +++ b/core/src/fxge/ge/fx_ge_text.cpp @@ -229,7 +229,7 @@ FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars, if (FXSYS_fabs(char2device.a) + FXSYS_fabs(char2device.b) > 50 * 1.0f || ((m_DeviceClass == FXDC_PRINTER && !m_pDeviceDriver->IsPSPrintDriver()) && !(text_flags & FXTEXT_PRINTIMAGETEXT))) { - if (pFont->GetFace() != NULL || + if (pFont->GetFace() || (pFont->GetSubstFont()->m_SubstFlags & FXFONT_SUBST_GLYPHPATH)) { int nPathFlags = (text_flags & FXTEXT_NOSMOOTH) == 0 ? 0 : FXFILL_NOPATHSMOOTH; diff --git a/core/src/fxge/win32/fx_win32_device.cpp b/core/src/fxge/win32/fx_win32_device.cpp index 4ca4316c2e..6d520468a3 100644 --- a/core/src/fxge/win32/fx_win32_device.cpp +++ b/core/src/fxge/win32/fx_win32_device.cpp @@ -1186,7 +1186,7 @@ FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource, int alpha_flag, void* pIccTransform, int blend_type) { - ASSERT(pSource != NULL && pClipRect != NULL); + ASSERT(pSource && pClipRect); if (flags || dest_width > 10000 || dest_width < -10000 || dest_height > 10000 || dest_height < -10000) { return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, diff --git a/core/src/fxge/win32/fx_win32_dwrite.cpp b/core/src/fxge/win32/fx_win32_dwrite.cpp index ab50f3cf38..83924f23e7 100644 --- a/core/src/fxge/win32/fx_win32_dwrite.cpp +++ b/core/src/fxge/win32/fx_win32_dwrite.cpp @@ -18,14 +18,14 @@ typedef HRESULT(__stdcall* FuncType_DWriteCreateFactory)( __out IUnknown**); template <typename InterfaceType> inline void SafeRelease(InterfaceType** currentObject) { - if (*currentObject != NULL) { + if (*currentObject) { (*currentObject)->Release(); *currentObject = NULL; } } template <typename InterfaceType> inline InterfaceType* SafeAcquire(InterfaceType* newObject) { - if (newObject != NULL) { + if (newObject) { newObject->AddRef(); } return newObject; diff --git a/core/src/fxge/win32/fx_win32_gdipext.cpp b/core/src/fxge/win32/fx_win32_gdipext.cpp index 2886ee81d0..e79a88cb81 100644 --- a/core/src/fxge/win32/fx_win32_gdipext.cpp +++ b/core/src/fxge/win32/fx_win32_gdipext.cpp @@ -1295,7 +1295,7 @@ class GpStream final : public IStream { ULONG* pcbRead) { size_t bytes_left; size_t bytes_out; - if (pcbRead != NULL) { + if (pcbRead) { *pcbRead = 0; } if (m_ReadPos == m_InterStream.GetLength()) { @@ -1305,7 +1305,7 @@ class GpStream final : public IStream { bytes_out = FX_MIN(cb, bytes_left); FXSYS_memcpy(Output, m_InterStream.GetBuffer() + m_ReadPos, bytes_out); m_ReadPos += (int32_t)bytes_out; - if (pcbRead != NULL) { + if (pcbRead) { *pcbRead = (ULONG)bytes_out; } return S_OK; @@ -1314,13 +1314,13 @@ class GpStream final : public IStream { ULONG cb, ULONG* pcbWritten) { if (cb <= 0) { - if (pcbWritten != NULL) { + if (pcbWritten) { *pcbWritten = 0; } return S_OK; } m_InterStream.InsertBlock(m_InterStream.GetLength(), Input, cb); - if (pcbWritten != NULL) { + if (pcbWritten) { *pcbWritten = cb; } return S_OK; @@ -1374,7 +1374,7 @@ class GpStream final : public IStream { return STG_E_SEEKERROR; } m_ReadPos = new_read_position; - if (lpNewFilePointer != NULL) { + if (lpNewFilePointer) { lpNewFilePointer->QuadPart = m_ReadPos; } return S_OK; diff --git a/core/src/fxge/win32/fx_win32_print.cpp b/core/src/fxge/win32/fx_win32_print.cpp index c829a438b9..39828b14d8 100644 --- a/core/src/fxge/win32/fx_win32_print.cpp +++ b/core/src/fxge/win32/fx_win32_print.cpp @@ -49,7 +49,7 @@ FX_BOOL CGdiPrinterDriver::SetDIBits(const CFX_DIBSource* pSource, pSource->GetHeight(), &clip_rect, 0, alpha_flag, pIccTransform, FXDIB_BLEND_NORMAL); } - ASSERT(pSource != NULL && !pSource->IsAlphaMask() && pSrcRect != NULL); + ASSERT(pSource && !pSource->IsAlphaMask() && pSrcRect); ASSERT(blend_type == FXDIB_BLEND_NORMAL); if (pSource->HasAlpha()) { return FALSE; |