Get rid of most instance of 'foo == NULL'
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1520063002 .
diff --git a/core/include/fpdfapi/fpdf_resource.h b/core/include/fpdfapi/fpdf_resource.h
index 1f6c8b0..d6d43ee 100644
--- a/core/include/fpdfapi/fpdf_resource.h
+++ b/core/include/fpdfapi/fpdf_resource.h
@@ -605,7 +605,7 @@
 
   ~CPDF_Color();
 
-  FX_BOOL IsNull() const { return m_pBuffer == NULL; }
+  FX_BOOL IsNull() const { return !m_pBuffer; }
 
   FX_BOOL IsEqual(const CPDF_Color& other) const;
 
diff --git a/core/include/fxcrt/fx_basic.h b/core/include/fxcrt/fx_basic.h
index b712d7b..6e7fbb4 100644
--- a/core/include/fxcrt/fx_basic.h
+++ b/core/include/fxcrt/fx_basic.h
@@ -884,7 +884,7 @@
 
   void operator=(void* p) {
     FXSYS_assert(p == 0);
-    if (m_pObject == NULL) {
+    if (!m_pObject) {
       return;
     }
     m_pObject->m_RefCount--;
@@ -898,12 +898,12 @@
 
   operator const ObjClass*() const { return m_pObject; }
 
-  FX_BOOL IsNull() const { return m_pObject == NULL; }
+  FX_BOOL IsNull() const { return !m_pObject; }
 
-  FX_BOOL NotNull() const { return m_pObject != NULL; }
+  FX_BOOL NotNull() const { return !IsNull(); }
 
   ObjClass* GetModify() {
-    if (m_pObject == NULL) {
+    if (!m_pObject) {
       m_pObject = new CountedObj;
       m_pObject->m_RefCount = 1;
     } else if (m_pObject->m_RefCount > 1) {
@@ -916,7 +916,7 @@
   }
 
   void SetNull() {
-    if (m_pObject == NULL) {
+    if (!m_pObject) {
       return;
     }
     m_pObject->m_RefCount--;
diff --git a/core/src/fdrm/crypto/fx_crypt_sha.cpp b/core/src/fdrm/crypto/fx_crypt_sha.cpp
index ecefdde..c7d1710 100644
--- a/core/src/fdrm/crypto/fx_crypt_sha.cpp
+++ b/core/src/fdrm/crypto/fx_crypt_sha.cpp
@@ -390,7 +390,7 @@
   return ret;
 }
 void CRYPT_SHA384Start(void* context) {
-  if (context == NULL) {
+  if (!context) {
     return;
   }
   sha384_context* ctx = (sha384_context*)context;
@@ -604,7 +604,7 @@
   CRYPT_SHA384Finish(&context, digest);
 }
 void CRYPT_SHA512Start(void* context) {
-  if (context == NULL) {
+  if (!context) {
     return;
   }
   sha384_context* ctx = (sha384_context*)context;
diff --git a/core/src/fpdfapi/fpdf_cmaps/fpdf_cmaps.cpp b/core/src/fpdfapi/fpdf_cmaps/fpdf_cmaps.cpp
index fba3a2b..90091de 100644
--- a/core/src/fpdfapi/fpdf_cmaps/fpdf_cmaps.cpp
+++ b/core/src/fpdfapi/fpdf_cmaps/fpdf_cmaps.cpp
@@ -105,7 +105,7 @@
   }
   FX_WORD code = (FX_WORD)charcode;
   while (1) {
-    if (pMap->m_pWordMap == NULL) {
+    if (!pMap->m_pWordMap) {
       return 0;
     }
     if (pMap->m_WordMapType == FXCMAP_CMap::Single) {
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp
index eda51de..5810da5 100644
--- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp
+++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_content.cpp
@@ -56,13 +56,13 @@
 CFX_ByteString CPDF_PageContentGenerate::RealizeResource(
     CPDF_Object* pResourceObj,
     const FX_CHAR* szType) {
-  if (m_pPage->m_pResources == NULL) {
+  if (!m_pPage->m_pResources) {
     m_pPage->m_pResources = new CPDF_Dictionary;
     int objnum = m_pDocument->AddIndirectObject(m_pPage->m_pResources);
     m_pPage->m_pFormDict->SetAtReference("Resources", m_pDocument, objnum);
   }
   CPDF_Dictionary* pResList = m_pPage->m_pResources->GetDict(szType);
-  if (pResList == NULL) {
+  if (!pResList) {
     pResList = new CPDF_Dictionary;
     m_pPage->m_pResources->SetAt(szType, pResList);
   }
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
index a797332..b200b8d 100644
--- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
+++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp
@@ -17,7 +17,7 @@
                                 CFX_FileBufferArchive* pFile,
                                 FX_FILESIZE& offset) {
   int32_t len = 0;
-  if (pObj == NULL) {
+  if (!pObj) {
     if (pFile->AppendString(" null") < 0) {
       return -1;
     }
@@ -416,7 +416,7 @@
   if (src_size == 0) {
     return TRUE;
   }
-  if (pHandler == NULL) {
+  if (!pHandler) {
     m_pData = (uint8_t*)src_data;
     m_dwSize = src_size;
     m_bNewBuf = FALSE;
@@ -1071,7 +1071,7 @@
                                      const CPDF_Object* pObj,
                                      FX_BOOL bEncrypt) {
   int32_t len = 0;
-  if (pObj == NULL) {
+  if (!pObj) {
     if (m_File.AppendString(" null") < 0) {
       return -1;
     }
@@ -1098,7 +1098,7 @@
     case PDFOBJ_STRING: {
       CFX_ByteString str = pObj->GetString();
       FX_BOOL bHex = pObj->AsString()->IsHex();
-      if (m_pCryptoHandler == NULL || !bEncrypt) {
+      if (!m_pCryptoHandler || !bEncrypt) {
         CFX_ByteString content = PDF_EncodeString(str, bHex);
         if ((len = m_File.AppendString(content)) < 0) {
           return -1;
@@ -1200,7 +1200,7 @@
       break;
     }
     case PDFOBJ_DICTIONARY: {
-      if (m_pCryptoHandler == NULL || pObj == m_pEncryptDict) {
+      if (!m_pCryptoHandler || pObj == m_pEncryptDict) {
         return PDF_CreatorAppendObject(pObj, &m_File, m_Offset);
       }
       if (m_File.AppendString("<<") < 0) {
@@ -1263,7 +1263,7 @@
   if (m_pParser->m_bVersionUpdated || m_bSecurityChanged || bExistInMap ||
       bObjStm) {
     CPDF_Object* pObj = m_pDocument->GetIndirectObject(objnum);
-    if (pObj == NULL) {
+    if (!pObj) {
       m_ObjectOffset[objnum] = 0;
       m_ObjectSize[objnum] = 0;
       return 0;
@@ -1278,7 +1278,7 @@
     uint8_t* pBuffer;
     FX_DWORD size;
     m_pParser->GetIndirectBinary(objnum, pBuffer, size);
-    if (pBuffer == NULL) {
+    if (!pBuffer) {
       return 0;
     }
     if (m_pParser->m_V5Type[objnum] == 2) {
@@ -1477,7 +1477,7 @@
 int32_t CPDF_Creator::WriteDoc_Stage1(IFX_Pause* pPause) {
   FXSYS_assert(m_iStage > -1 || m_iStage < 20);
   if (m_iStage == 0) {
-    if (m_pParser == NULL) {
+    if (!m_pParser) {
       m_dwFlags &= ~FPDFCREATE_INCREMENTAL;
     }
     if (m_bSecurityChanged && (m_dwFlags & FPDFCREATE_NO_ORIGINAL) == 0) {
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp
index 7febc79..9c96a30 100644
--- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp
+++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_doc.cpp
@@ -20,7 +20,7 @@
   m_pDocRender = CPDF_ModuleMgr::Get()->GetRenderModule()->CreateDocData(this);
 }
 void CPDF_Document::CreateNewDoc() {
-  ASSERT(m_pRootDict == NULL && m_pInfoDict == NULL);
+  ASSERT(!m_pRootDict && !m_pInfoDict);
   m_pRootDict = new CPDF_Dictionary;
   m_pRootDict->SetAtName("Type", "Catalog");
   int objnum = AddIndirectObject(m_pRootDict);
@@ -550,7 +550,7 @@
                                      FX_BOOL bTranslateName) {
   CTFontRef font = (CTFontRef)pFont;
   CTFontDescriptorRef descriptor = CTFontCopyFontDescriptor(font);
-  if (descriptor == NULL) {
+  if (!descriptor) {
     return NULL;
   }
   CFX_ByteString basefont;
@@ -560,7 +560,7 @@
   FXSYS_memset(bbox, 0, sizeof(int) * 4);
   CFArrayRef languages = (CFArrayRef)CTFontDescriptorCopyAttribute(
       descriptor, kCTFontLanguagesAttribute);
-  if (languages == NULL) {
+  if (!languages) {
     CFRelease(descriptor);
     return NULL;
   }
@@ -574,7 +574,7 @@
   }
   CFRelease(descriptor);
   CFDictionaryRef traits = (CFDictionaryRef)CTFontCopyTraits(font);
-  if (traits == NULL) {
+  if (!traits) {
     CFRelease(languages);
     return NULL;
   }
@@ -825,7 +825,7 @@
 }
 
 CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert) {
-  if (pFont == NULL) {
+  if (!pFont) {
     return NULL;
   }
   FX_BOOL bCJK = charset == FXFONT_CHINESEBIG5_CHARSET ||
@@ -1118,11 +1118,11 @@
 
 void CPDF_Document::DeletePage(int iPage) {
   CPDF_Dictionary* pRoot = GetRoot();
-  if (pRoot == NULL) {
+  if (!pRoot) {
     return;
   }
   CPDF_Dictionary* pPages = pRoot->GetDict("Pages");
-  if (pPages == NULL) {
+  if (!pPages) {
     return;
   }
   int nPages = pPages->GetInteger("Count");
diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp
index 640e867..10b0272 100644
--- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp
+++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_image.cpp
@@ -51,7 +51,7 @@
   m_bIsMask = FALSE;
   m_Width = width;
   m_Height = height;
-  if (m_pStream == NULL) {
+  if (!m_pStream) {
     m_pStream = new CPDF_Stream(NULL, 0, NULL);
   }
   return pDict;
@@ -367,7 +367,7 @@
       dest_buf = NULL;
     }
   }
-  if (m_pStream == NULL) {
+  if (!m_pStream) {
     m_pStream = new CPDF_Stream(NULL, 0, NULL);
   }
   if (!bStream) {
diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
index 4a71382..3170b55 100644
--- a/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
+++ b/core/src/fpdfapi/fpdf_font/fpdf_font.cpp
@@ -351,7 +351,7 @@
 void CPDF_Font::LoadUnicodeMap() {
   m_bToUnicodeLoaded = TRUE;
   CPDF_Stream* pStream = m_pFontDict->GetStream("ToUnicode");
-  if (pStream == NULL) {
+  if (!pStream) {
     return;
   }
   m_pToUnicodeMap = new CPDF_ToUnicodeMap;
@@ -425,7 +425,7 @@
       }
       if (i < count) {
         CPDF_Dictionary* pFontDesc = pFontDict->GetDict("FontDescriptor");
-        if (pFontDesc == NULL || !pFontDesc->KeyExist("FontFile2")) {
+        if (!pFontDesc || !pFontDesc->KeyExist("FontFile2")) {
           pFont = new CPDF_CIDFont;
           pFont->m_pFontDict = pFontDict;
           pFont->m_pDocument = pDoc;
@@ -455,7 +455,7 @@
   return pFont;
 }
 FX_BOOL CPDF_Font::Load() {
-  if (m_pFontDict == NULL) {
+  if (!m_pFontDict) {
     return FALSE;
   }
   CFX_ByteString type = m_pFontDict->GetString("Subtype");
@@ -488,7 +488,7 @@
     }
     const FX_WCHAR* buf = m_MultiCharBuf.GetBuffer();
     FX_DWORD buf_len = m_MultiCharBuf.GetLength();
-    if (buf == NULL || buf_len == 0) {
+    if (!buf || buf_len == 0) {
       return CFX_WideString();
     }
     FX_DWORD index = value >> 16;
@@ -704,7 +704,7 @@
                                 CFX_ByteString*& pCharNames,
                                 FX_BOOL bEmbedded,
                                 FX_BOOL bTrueType) {
-  if (pEncoding == NULL) {
+  if (!pEncoding) {
     if (m_BaseFont == "Symbol") {
       iBaseEncoding = bTrueType ? PDFFONT_ENCODING_MS_SYMBOL
                                 : PDFFONT_ENCODING_ADOBE_SYMBOL;
@@ -748,7 +748,7 @@
     iBaseEncoding = PDFFONT_ENCODING_STANDARD;
   }
   CPDF_Array* pDiffs = pDict->GetArray("Differences");
-  if (pDiffs == NULL) {
+  if (!pDiffs) {
     return;
   }
   pCharNames = new CFX_ByteString[256];
@@ -879,13 +879,10 @@
   if (pCharNames) {
     name = pCharNames[charcode];
   }
-  if ((name == NULL || name[0] == 0) && iBaseEncoding) {
+  if ((!name || name[0] == 0) && iBaseEncoding) {
     name = PDF_CharNameFromPredefinedCharSet(iBaseEncoding, charcode);
   }
-  if (name == NULL || name[0] == 0) {
-    return NULL;
-  }
-  return name;
+  return name && name[0] ? name : nullptr;
 }
 FX_BOOL CPDF_SimpleFont::LoadCommon() {
   CPDF_Dictionary* pFontDesc = m_pFontDict->GetDict("FontDescriptor");
@@ -1127,7 +1124,7 @@
     for (int charcode = 0; charcode < 256; charcode++) {
       const FX_CHAR* name =
           GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode);
-      if (name == NULL) {
+      if (!name) {
         continue;
       }
       m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
@@ -1228,7 +1225,7 @@
     for (int charcode = 0; charcode < 256; charcode++) {
       const FX_CHAR* name =
           GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode);
-      if (name == NULL) {
+      if (!name) {
         continue;
       }
       m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
@@ -1328,7 +1325,7 @@
   for (int charcode = 0; charcode < 256; charcode++) {
     const FX_CHAR* name =
         GetAdobeCharName(m_BaseEncoding, m_pCharNames, charcode);
-    if (name == NULL) {
+    if (!name) {
       continue;
     }
     m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
@@ -1453,7 +1450,7 @@
   }
   if (((baseEncoding == PDFFONT_ENCODING_MACROMAN ||
         baseEncoding == PDFFONT_ENCODING_WINANSI) &&
-       m_pCharNames == NULL) ||
+       !m_pCharNames) ||
       (m_Flags & PDFFONT_NONSYMBOLIC)) {
     if (!FXFT_Has_Glyph_Names(m_Font.GetFace()) &&
         (!m_Font.GetFace()->num_charmaps || !m_Font.GetFace()->charmaps)) {
@@ -1486,7 +1483,7 @@
     for (int charcode = 0; charcode < 256; charcode++) {
       const FX_CHAR* name =
           GetAdobeCharName(baseEncoding, m_pCharNames, charcode);
-      if (name == NULL) {
+      if (!name) {
         m_GlyphIndex[charcode] =
             m_pFontFile ? FXFT_Get_Char_Index(m_Font.GetFace(), charcode) : -1;
         continue;
@@ -1562,7 +1559,7 @@
         for (int charcode = 0; charcode < 256; charcode++) {
           const FX_CHAR* name =
               GetAdobeCharName(baseEncoding, m_pCharNames, charcode);
-          if (name == NULL) {
+          if (!name) {
             continue;
           }
           m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name);
diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
index 89004fe..6e7a051 100644
--- a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
+++ b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
@@ -848,14 +848,14 @@
   if (m_pEmbedMap) {
     return FPDFAPI_CIDFromCharCode(m_pEmbedMap, charcode);
   }
-  if (m_pMapping == NULL) {
+  if (!m_pMapping) {
     return (FX_WORD)charcode;
   }
   if (charcode >> 16) {
     if (m_pAddMapping) {
       void* found = FXSYS_bsearch(&charcode, m_pAddMapping + 4,
                                   *(FX_DWORD*)m_pAddMapping, 8, CompareCID);
-      if (found == NULL) {
+      if (!found) {
         if (m_pUseMap) {
           return m_pUseMap->CIDFromCharCode(charcode);
         }
@@ -1058,7 +1058,7 @@
   delete m_pTTGSUBTable;
 }
 FX_WORD CPDF_CIDFont::CIDFromCharCode(FX_DWORD charcode) const {
-  if (m_pCMap == NULL) {
+  if (!m_pCMap) {
     return (FX_WORD)charcode;
   }
   return m_pCMap->CIDFromCharCode(charcode);
@@ -1073,12 +1073,12 @@
     case CIDCODING_UTF16:
       return (FX_WCHAR)charcode;
     case CIDCODING_CID:
-      if (m_pCID2UnicodeMap == NULL || !m_pCID2UnicodeMap->IsLoaded()) {
+      if (!m_pCID2UnicodeMap || !m_pCID2UnicodeMap->IsLoaded()) {
         return 0;
       }
       return m_pCID2UnicodeMap->UnicodeFromCID((FX_WORD)charcode);
   }
-  if (!m_pCMap->IsLoaded() || m_pCID2UnicodeMap == NULL ||
+  if (!m_pCMap->IsLoaded() || !m_pCID2UnicodeMap ||
       !m_pCID2UnicodeMap->IsLoaded()) {
 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
     FX_WCHAR unicode;
@@ -1111,7 +1111,7 @@
     case CIDCODING_UTF16:
       return unicode;
     case CIDCODING_CID: {
-      if (m_pCID2UnicodeMap == NULL || !m_pCID2UnicodeMap->IsLoaded()) {
+      if (!m_pCID2UnicodeMap || !m_pCID2UnicodeMap->IsLoaded()) {
         return 0;
       }
       FX_DWORD CID = 0;
@@ -1157,14 +1157,14 @@
     return LoadGB2312();
   }
   CPDF_Array* pFonts = m_pFontDict->GetArray("DescendantFonts");
-  if (pFonts == NULL) {
+  if (!pFonts) {
     return FALSE;
   }
   if (pFonts->GetCount() != 1) {
     return FALSE;
   }
   CPDF_Dictionary* pCIDFontDict = pFonts->GetDict(0);
-  if (pCIDFontDict == NULL) {
+  if (!pCIDFontDict) {
     return FALSE;
   }
   m_BaseFont = pCIDFontDict->GetString("BaseFont");
@@ -1180,7 +1180,7 @@
     LoadFontDescriptor(pFontDesc);
   }
   CPDF_Object* pEncoding = m_pFontDict->GetElementValue("Encoding");
-  if (pEncoding == NULL) {
+  if (!pEncoding) {
     return FALSE;
   }
   CFX_ByteString subtype = pCIDFontDict->GetString("Subtype");
@@ -1201,7 +1201,7 @@
   } else {
     return FALSE;
   }
-  if (m_pCMap == NULL) {
+  if (!m_pCMap) {
     return FALSE;
   }
   m_Charset = m_pCMap->m_Charset;
@@ -1218,8 +1218,8 @@
             ->GetFontGlobals()
             ->m_CMapManager.GetCID2UnicodeMap(
                 m_Charset,
-                m_pFontFile == NULL && (m_pCMap->m_Coding == CIDCODING_CID ||
-                                        pCIDFontDict->KeyExist("W")));
+                !m_pFontFile && (m_pCMap->m_Coding == CIDCODING_CID ||
+                                 pCIDFontDict->KeyExist("W")));
   if (m_Font.GetFace()) {
     if (m_bType1) {
       FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE);
@@ -1333,7 +1333,7 @@
   } else {
     rect = FX_RECT(0, 0, 0, 0);
   }
-  if (m_pFontFile == NULL && m_Charset == CIDSET_JAPAN1) {
+  if (!m_pFontFile && m_Charset == CIDSET_JAPAN1) {
     FX_WORD CID = CIDFromCharCode(charcode);
     const uint8_t* pTransform = GetCIDTransform(CID);
     if (pTransform && !bVert) {
@@ -1458,7 +1458,7 @@
   if (pVertGlyph) {
     *pVertGlyph = FALSE;
   }
-  if (m_pFontFile == NULL && m_pCIDToGIDMap == NULL) {
+  if (!m_pFontFile && !m_pCIDToGIDMap) {
     FX_WORD cid = CIDFromCharCode(charcode);
     FX_WCHAR unicode = 0;
     if (m_bCIDIsGID) {
@@ -1504,7 +1504,7 @@
         iBaseEncoding = PDFFONT_ENCODING_MACROMAN;
       }
       const FX_CHAR* name = GetAdobeCharName(iBaseEncoding, NULL, charcode);
-      if (name == NULL) {
+      if (!name) {
         return charcode == 0 ? -1 : (int)charcode;
       }
       FX_WORD unicode = PDF_UnicodeFromAdobeName(name);
@@ -1616,7 +1616,7 @@
   return m_pCMap->AppendChar(str, charcode);
 }
 FX_BOOL CPDF_CIDFont::IsUnicodeCompatible() const {
-  if (!m_pCMap->IsLoaded() || m_pCID2UnicodeMap == NULL ||
+  if (!m_pCMap->IsLoaded() || !m_pCID2UnicodeMap ||
       !m_pCID2UnicodeMap->IsLoaded()) {
     return m_pCMap->m_Coding != CIDCODING_UNKNOWN;
   }
diff --git a/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp b/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp
index 4786b8b..035ea8a 100644
--- a/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp
+++ b/core/src/fpdfapi/fpdf_font/ttgsubtable.cpp
@@ -47,7 +47,7 @@
   void* pResult = FXSYS_bsearch(&key, m_Buffer.GetBuffer(),
                                 m_Buffer.GetSize() / sizeof(_IntPair),
                                 sizeof(_IntPair), _CompareInt);
-  if (pResult == NULL) {
+  if (!pResult) {
     return FALSE;
   }
   value = ((FX_DWORD*)pResult)[1];
@@ -158,7 +158,7 @@
 int CFX_CTTGSUBTable::GetCoverageIndex(struct TCoverageFormatBase* Coverage,
                                        uint32_t g) {
   int i = 0;
-  if (Coverage == NULL) {
+  if (!Coverage) {
     return -1;
   }
   switch (Coverage->CoverageFormat) {
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
index f37dd77..1fef74b 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page.cpp
@@ -689,7 +689,7 @@
   }
 }
 void CPDF_PageObjects::ContinueParse(IFX_Pause* pPause) {
-  if (m_pParser == NULL) {
+  if (!m_pParser) {
     return;
   }
   m_pParser->Continue(pPause);
@@ -720,10 +720,7 @@
 }
 CPDF_PageObject* CPDF_PageObjects::GetObjectByIndex(int index) const {
   FX_POSITION pos = m_ObjectList.FindIndex(index);
-  if (pos == NULL) {
-    return NULL;
-  }
-  return (CPDF_PageObject*)m_ObjectList.GetAt(pos);
+  return pos ? static_cast<CPDF_PageObject*>(m_ObjectList.GetAt(pos)) : nullptr;
 }
 void CPDF_PageObjects::Transform(const CFX_Matrix& matrix) {
   FX_POSITION pos = m_ObjectList.GetHeadPosition();
@@ -758,11 +755,11 @@
   return CFX_FloatRect(left, bottom, right, top);
 }
 void CPDF_PageObjects::LoadTransInfo() {
-  if (m_pFormDict == NULL) {
+  if (!m_pFormDict) {
     return;
   }
   CPDF_Dictionary* pGroup = m_pFormDict->GetDict("Group");
-  if (pGroup == NULL) {
+  if (!pGroup) {
     return;
   }
   if (pGroup->GetString("S") != "Transparency") {
@@ -800,7 +797,7 @@
     m_pPageRender =
         CPDF_ModuleMgr::Get()->GetRenderModule()->CreatePageCache(this);
   }
-  if (pPageDict == NULL) {
+  if (!pPageDict) {
     m_PageWidth = m_PageHeight = 100 * 1.0f;
     m_pPageResources = m_pResources = NULL;
     return;
@@ -912,10 +909,10 @@
   m_pFormDict = pFormStream ? pFormStream->GetDict() : NULL;
   m_pResources = m_pFormDict->GetDict("Resources");
   m_pPageResources = pPageResources;
-  if (m_pResources == NULL) {
+  if (!m_pResources) {
     m_pResources = pParentResources;
   }
-  if (m_pResources == NULL) {
+  if (!m_pResources) {
     m_pResources = pPageResources;
   }
   m_Transparency = 0;
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp
index 8deeb66..c9eee8e 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_colors.cpp
@@ -688,7 +688,7 @@
 
 FX_BOOL CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) {
   CPDF_Stream* pStream = pArray->GetStream(1);
-  if (pStream == NULL) {
+  if (!pStream) {
     return FALSE;
   }
   m_pProfile = pDoc->LoadIccProfile(pStream);
@@ -699,7 +699,7 @@
       m_pProfile
           ->GetComponents();  // Try using the nComponents from ICC profile
   CPDF_Dictionary* pDict = pStream->GetDict();
-  if (m_pProfile->m_pTransform == NULL) {  // No valid ICC profile or using sRGB
+  if (!m_pProfile->m_pTransform) {  // No valid ICC profile or using sRGB
     CPDF_Object* pAlterCSObj =
         pDict ? pDict->GetElementValue("Alternate") : NULL;
     if (pAlterCSObj) {
@@ -764,7 +764,7 @@
     return TRUE;
   }
   ICodec_IccModule* pIccModule = CPDF_ModuleMgr::Get()->GetIccModule();
-  if (m_pProfile->m_pTransform == NULL || pIccModule == NULL) {
+  if (!m_pProfile->m_pTransform || !pIccModule) {
     if (m_pAlterCS) {
       return m_pAlterCS->GetRGB(pBuf, R, G, B);
     }
@@ -822,7 +822,7 @@
       CPDF_ModuleMgr::Get()->GetIccModule()->TranslateScanline(
           m_pProfile->m_pTransform, pDestBuf, pSrcBuf, pixels);
     } else {
-      if (m_pCache == NULL) {
+      if (!m_pCache) {
         ((CPDF_ICCBasedCS*)this)->m_pCache = FX_Alloc2D(uint8_t, nMaxColors, 3);
         uint8_t* temp_src = FX_Alloc2D(uint8_t, nMaxColors, m_nComponents);
         uint8_t* pSrc = temp_src;
@@ -897,7 +897,7 @@
   }
   CPDF_DocPageData* pDocPageData = pDoc->GetPageData();
   m_pBaseCS = pDocPageData->GetColorSpace(pBaseObj, NULL);
-  if (m_pBaseCS == NULL) {
+  if (!m_pBaseCS) {
     return FALSE;
   }
   m_pCountedBaseCS = pDocPageData->FindColorSpacePtr(m_pBaseCS->GetArray());
@@ -1078,8 +1078,8 @@
   if (m_Type == None) {
     return FALSE;
   }
-  if (m_pFunc == NULL) {
-    if (m_pAltCS == NULL) {
+  if (!m_pFunc) {
+    if (!m_pAltCS) {
       return FALSE;
     }
     int nComps = m_pAltCS->CountComponents();
@@ -1154,7 +1154,7 @@
   }
   m_pAltCS = Load(pDoc, pAltCS);
   m_pFunc = CPDF_Function::Load(pArray->GetElementValue(3));
-  if (m_pAltCS == NULL || m_pFunc == NULL) {
+  if (!m_pAltCS || !m_pFunc) {
     return FALSE;
   }
   if (m_pFunc->CountOutputs() < m_pAltCS->CountComponents()) {
@@ -1166,7 +1166,7 @@
                                FX_FLOAT& R,
                                FX_FLOAT& G,
                                FX_FLOAT& B) const {
-  if (m_pFunc == NULL) {
+  if (!m_pFunc) {
     return FALSE;
   }
   CFX_FixedBufGrow<FX_FLOAT, 16> results(m_pFunc->CountOutputs());
@@ -1331,7 +1331,7 @@
   return SetRGB(pBuf, R, G, B);
 }
 void CPDF_ColorSpace::GetDefaultColor(FX_FLOAT* buf) const {
-  if (buf == NULL || m_Family == PDFCS_PATTERN) {
+  if (!buf || m_Family == PDFCS_PATTERN) {
     return;
   }
   FX_FLOAT min, max;
@@ -1418,7 +1418,7 @@
 }
 void CPDF_Color::SetColorSpace(CPDF_ColorSpace* pCS) {
   if (m_pCS == pCS) {
-    if (m_pBuffer == NULL) {
+    if (!m_pBuffer) {
       m_pBuffer = pCS->CreateBuf();
     }
     ReleaseColorSpace();
@@ -1434,7 +1434,7 @@
   }
 }
 void CPDF_Color::SetValue(FX_FLOAT* comps) {
-  if (m_pBuffer == NULL) {
+  if (!m_pBuffer) {
     return;
   }
   if (m_pCS->GetFamily() != PDFCS_PATTERN) {
@@ -1445,7 +1445,7 @@
   if (ncomps > MAX_PATTERN_COLORCOMPS) {
     return;
   }
-  if (m_pCS == NULL || m_pCS->GetFamily() != PDFCS_PATTERN) {
+  if (!m_pCS || m_pCS->GetFamily() != PDFCS_PATTERN) {
     FX_Free(m_pBuffer);
     m_pCS = CPDF_ColorSpace::GetStockCS(PDFCS_PATTERN);
     m_pBuffer = m_pCS->CreateBuf();
@@ -1482,7 +1482,7 @@
       m_pCS = m_pCS->m_pDocument->GetPageData()->GetCopiedColorSpace(pArray);
     }
   }
-  if (m_pCS == NULL) {
+  if (!m_pCS) {
     return;
   }
   m_pBuffer = m_pCS->CreateBuf();
@@ -1498,7 +1498,7 @@
   }
 }
 FX_BOOL CPDF_Color::GetRGB(int& R, int& G, int& B) const {
-  if (m_pCS == NULL || m_pBuffer == NULL) {
+  if (!m_pCS || !m_pBuffer) {
     return FALSE;
   }
   FX_FLOAT r = 0.0f, g = 0.0f, b = 0.0f;
@@ -1511,28 +1511,26 @@
   return TRUE;
 }
 CPDF_Pattern* CPDF_Color::GetPattern() const {
-  if (m_pBuffer == NULL || m_pCS->GetFamily() != PDFCS_PATTERN) {
+  if (!m_pBuffer || m_pCS->GetFamily() != PDFCS_PATTERN) {
     return NULL;
   }
   PatternValue* pvalue = (PatternValue*)m_pBuffer;
   return pvalue->m_pPattern;
 }
 CPDF_ColorSpace* CPDF_Color::GetPatternCS() const {
-  if (m_pBuffer == NULL || m_pCS->GetFamily() != PDFCS_PATTERN) {
+  if (!m_pBuffer || m_pCS->GetFamily() != PDFCS_PATTERN) {
     return NULL;
   }
   return m_pCS->GetBaseCS();
 }
 FX_FLOAT* CPDF_Color::GetPatternColor() const {
-  if (m_pBuffer == NULL || m_pCS->GetFamily() != PDFCS_PATTERN) {
+  if (!m_pBuffer || m_pCS->GetFamily() != PDFCS_PATTERN) {
     return NULL;
   }
   PatternValue* pvalue = (PatternValue*)m_pBuffer;
   return pvalue->m_nComps ? pvalue->m_Comps : NULL;
 }
 FX_BOOL CPDF_Color::IsEqual(const CPDF_Color& other) const {
-  if (m_pCS != other.m_pCS || m_pCS == NULL) {
-    return FALSE;
-  }
-  return FXSYS_memcmp(m_pBuffer, other.m_pBuffer, m_pCS->GetBufSize()) == 0;
+  return m_pCS && m_pCS == other.m_pCS &&
+         FXSYS_memcmp(m_pBuffer, other.m_pBuffer, m_pCS->GetBufSize()) == 0;
 }
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp
index 5f9d038..118f1cd 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp
@@ -207,7 +207,7 @@
         }
         i++;
       }
-      if (_PDF_PSOpNames[i].name == NULL) {
+      if (!_PDF_PSOpNames[i].name) {
         FX_FLOAT* pd = FX_Alloc(FX_FLOAT, 1);
         *pd = FX_atof(word);
         m_Operators.Add((void*)PSOP_CONST);
@@ -683,7 +683,7 @@
 }
 FX_BOOL CPDF_ExpIntFunc::v_Init(CPDF_Object* pObj) {
   CPDF_Dictionary* pDict = pObj->GetDict();
-  if (pDict == NULL) {
+  if (!pDict) {
     return FALSE;
   }
   CPDF_Array* pArray0 = pDict->GetArray("C0");
@@ -813,7 +813,7 @@
     if (input < m_pBounds[i + 1]) {
       break;
     }
-  if (m_pSubFunctions[i] == NULL) {
+  if (!m_pSubFunctions[i]) {
     return FALSE;
   }
   input = PDF_Interpolate(input, m_pBounds[i], m_pBounds[i + 1],
@@ -823,7 +823,7 @@
   return TRUE;
 }
 CPDF_Function* CPDF_Function::Load(CPDF_Object* pFuncObj) {
-  if (pFuncObj == NULL) {
+  if (!pFuncObj) {
     return NULL;
   }
   CPDF_Function* pFunc = NULL;
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
index 63f957a..d8f21c6 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp
@@ -103,7 +103,7 @@
     FX_BOOL bLayerStarted = FALSE;
     for (int i = 0; i < count; i++) {
       CPDF_TextObject* pTextObj = GetText(i);
-      if (pTextObj == NULL) {
+      if (!pTextObj) {
         if (!bStarted) {
           rect = layer_rect;
           bStarted = TRUE;
@@ -637,7 +637,7 @@
                                    FX_BOOL bDirect) {
   CPDF_ContentMarkItem& item = m_Marks.Add();
   item.SetName(name);
-  if (pDict == NULL) {
+  if (!pDict) {
     return;
   }
   item.SetParam(bDirect ? CPDF_ContentMarkItem::DirectDict
@@ -652,7 +652,7 @@
   m_Marks.RemoveAt(size - 1);
 }
 FX_BOOL CPDF_ContentMark::HasMark(const CFX_ByteStringC& mark) const {
-  if (m_pObject == NULL) {
+  if (!m_pObject) {
     return FALSE;
   }
   for (int i = 0; i < m_pObject->CountItems(); i++) {
@@ -665,7 +665,7 @@
 }
 FX_BOOL CPDF_ContentMark::LookupMark(const CFX_ByteStringC& mark,
                                      CPDF_Dictionary*& pDict) const {
-  if (m_pObject == NULL) {
+  if (!m_pObject) {
     return FALSE;
   }
   for (int i = 0; i < m_pObject->CountItems(); i++) {
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
index 1df0c60..e90c53c 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp
@@ -117,7 +117,7 @@
         CPDF_Name::Create(PDF_NameDecode(CFX_ByteStringC(name, len)));
   } else {
     m_ParamBuf1[index].m_Type = PDFOBJ_NAME;
-    if (FXSYS_memchr(name, '#', len) == NULL) {
+    if (!FXSYS_memchr(name, '#', len)) {
       FXSYS_memcpy(m_ParamBuf1[index].m_Name.m_Buffer, name, len);
       m_ParamBuf1[index].m_Name.m_Len = len;
     } else {
@@ -410,7 +410,7 @@
   }
   CFX_ByteString tag = GetString(1);
   CPDF_Object* pProperty = GetObject(0);
-  if (pProperty == NULL) {
+  if (!pProperty) {
     return;
   }
   FX_BOOL bDirect = TRUE;
@@ -631,7 +631,7 @@
   }
   CFX_ByteString csname = GetString(0);
   CPDF_ColorSpace* pCS = FindColorSpace(csname);
-  if (pCS == NULL) {
+  if (!pCS) {
     return;
   }
   m_pCurStates->m_ColorState.GetModify()->m_FillColor.SetColorSpace(pCS);
@@ -642,7 +642,7 @@
   }
   CFX_ByteString csname = GetString(0);
   CPDF_ColorSpace* pCS = FindColorSpace(csname);
-  if (pCS == NULL) {
+  if (!pCS) {
     return;
   }
   m_pCurStates->m_ColorState.GetModify()->m_StrokeColor.SetColorSpace(pCS);
@@ -652,7 +652,7 @@
     return;
   }
   CPDF_Array* pArray = GetObject(1) ? GetObject(1)->GetArray() : NULL;
-  if (pArray == NULL) {
+  if (!pArray) {
     return;
   }
   m_pCurStates->SetLineDash(pArray, GetNumber(0), 1.0f);
@@ -771,7 +771,7 @@
 CPDF_ImageObject* CPDF_StreamContentParser::AddImage(CPDF_Stream* pStream,
                                                      CPDF_Image* pImage,
                                                      FX_BOOL bInline) {
-  if (pStream == NULL && pImage == NULL) {
+  if (!pStream && !pImage) {
     return NULL;
   }
   CFX_Matrix ImageMatrix;
@@ -1032,7 +1032,7 @@
     return;
   }
   CPDF_Object* pLastParam = GetObject(0);
-  if (pLastParam == NULL) {
+  if (!pLastParam) {
     return;
   }
   int nargs = m_ParamCount;
@@ -1062,7 +1062,7 @@
     return;
   }
   CPDF_Object* pLastParam = GetObject(0);
-  if (pLastParam == NULL) {
+  if (!pLastParam) {
     return;
   }
   int nargs = m_ParamCount;
@@ -1099,7 +1099,7 @@
     return;
   }
   CPDF_Pattern* pPattern = FindPattern(GetString(0), TRUE);
-  if (pPattern == NULL) {
+  if (!pPattern) {
     return;
   }
   if (pPattern->m_PatternType != PATTERN_SHADING) {
@@ -1162,24 +1162,24 @@
 CPDF_Object* CPDF_StreamContentParser::FindResourceObj(
     const CFX_ByteStringC& type,
     const CFX_ByteString& name) {
-  if (m_pResources == NULL) {
+  if (!m_pResources) {
     return NULL;
   }
   if (m_pResources == m_pPageResources) {
     CPDF_Dictionary* pList = m_pResources->GetDict(type);
-    if (pList == NULL) {
+    if (!pList) {
       return NULL;
     }
     CPDF_Object* pRes = pList->GetElementValue(name);
     return pRes;
   }
   CPDF_Dictionary* pList = m_pResources->GetDict(type);
-  if (pList == NULL) {
-    if (m_pPageResources == NULL) {
+  if (!pList) {
+    if (!m_pPageResources) {
       return NULL;
     }
     CPDF_Dictionary* pList = m_pPageResources->GetDict(type);
-    if (pList == NULL) {
+    if (!pList) {
       return NULL;
     }
     CPDF_Object* pRes = pList->GetElementValue(name);
@@ -1211,7 +1211,7 @@
     CFX_ByteString defname = "Default";
     defname += name.Mid(7);
     CPDF_Object* pDefObj = FindResourceObj("ColorSpace", defname);
-    if (pDefObj == NULL) {
+    if (!pDefObj) {
       if (name == "DeviceGray") {
         return CPDF_ColorSpace::GetStockCS(PDFCS_DEVICEGRAY);
       }
@@ -1223,7 +1223,7 @@
     return m_pDocument->LoadColorSpace(pDefObj);
   }
   CPDF_Object* pCSObj = FindResourceObj("ColorSpace", name);
-  if (pCSObj == NULL) {
+  if (!pCSObj) {
     m_bResourceMissing = TRUE;
     return NULL;
   }
@@ -1253,7 +1253,7 @@
                                              FX_FLOAT* pKerning,
                                              int nsegs) {
   CPDF_Font* pFont = m_pCurStates->m_TextState.GetFont();
-  if (pFont == NULL) {
+  if (!pFont) {
     return;
   }
   if (fInitKerning != 0) {
@@ -1324,7 +1324,7 @@
 }
 void CPDF_StreamContentParser::Handle_ShowText_Positioning() {
   CPDF_Array* pArray = GetObject(0) ? GetObject(0)->GetArray() : NULL;
-  if (pArray == NULL) {
+  if (!pArray) {
     return;
   }
   int n = pArray->GetCount();
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 fbe6faa..2f68d78 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
@@ -249,7 +249,7 @@
 FX_DWORD _DecodeAllScanlines(ICodec_ScanlineDecoder* pDecoder,
                              uint8_t*& dest_buf,
                              FX_DWORD& dest_size) {
-  if (pDecoder == NULL) {
+  if (!pDecoder) {
     return (FX_DWORD)-1;
   }
   int ncomps = pDecoder->CountComps();
@@ -353,7 +353,7 @@
     FX_DWORD bpc = pDict->GetInteger("BitsPerComponent");
     FX_DWORD nComponents = 1;
     CPDF_ColorSpace* pCS = pDoc->LoadColorSpace(pCSObj);
-    if (pCS == NULL) {
+    if (!pCS) {
       nComponents = 3;
     } else {
       nComponents = pCS->CountComponents();
@@ -634,7 +634,7 @@
       CFX_ByteString key =
           PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1));
       CPDF_Object* pObj = ReadNextObject(TRUE);
-      if (pObj == NULL) {
+      if (!pObj) {
         if (pDict) {
           pDict->Release();
         }
@@ -655,7 +655,7 @@
     CPDF_Array* pArray = CPDF_Array::Create();
     while (1) {
       CPDF_Object* pObj = ReadNextObject(bAllowNestedArray, TRUE);
-      if (pObj == NULL) {
+      if (!pObj) {
         if (m_WordSize == 0 || m_WordBuffer[0] == ']') {
           return pArray;
         }
@@ -924,8 +924,8 @@
   m_Status = Ready;
 }
 void CPDF_ContentParser::Start(CPDF_Page* pPage, CPDF_ParseOptions* pOptions) {
-  if (m_Status != Ready || pPage == NULL || pPage->m_pDocument == NULL ||
-      pPage->m_pFormDict == NULL) {
+  if (m_Status != Ready || !pPage || !pPage->m_pDocument ||
+      !pPage->m_pFormDict) {
     m_Status = Done;
     return;
   }
@@ -938,7 +938,7 @@
   m_InternalStage = PAGEPARSE_STAGE_GETCONTENT;
   m_CurrentOffset = 0;
   CPDF_Object* pContent = pPage->m_pFormDict->GetElementValue("Contents");
-  if (pContent == NULL) {
+  if (!pContent) {
     m_Status = Done;
     return;
   }
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
index 5ead9a5..fc050b9 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_pattern.cpp
@@ -129,7 +129,7 @@
 
   CPDF_Dictionary* pShadingDict =
       m_pShadingObj ? m_pShadingObj->GetDict() : NULL;
-  if (pShadingDict == NULL) {
+  if (!pShadingDict) {
     return FALSE;
   }
   if (m_nFuncs) {
@@ -151,7 +151,7 @@
     }
   }
   CPDF_Object* pCSObj = pShadingDict->GetElementValue("ColorSpace");
-  if (pCSObj == NULL) {
+  if (!pCSObj) {
     return FALSE;
   }
   CPDF_DocPageData* pDocPageData = m_pDocument->GetPageData();
@@ -199,7 +199,7 @@
   m_CoordMax = m_nCoordBits == 32 ? -1 : (1 << m_nCoordBits) - 1;
   m_CompMax = (1 << m_nCompBits) - 1;
   CPDF_Array* pDecode = pDict->GetArray("Decode");
-  if (pDecode == NULL || pDecode->GetCount() != 4 + m_nComps * 2) {
+  if (!pDecode || pDecode->GetCount() != 4 + m_nComps * 2) {
     return FALSE;
   }
   m_xmin = pDecode->GetNumber(0);
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
index 5fbdcc6..c855a7c 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_decode.cpp
@@ -454,7 +454,7 @@
       }
     }
     result.ReleaseBuffer(dest_pos);
-  } else if (pCharMap == NULL) {
+  } else if (!pCharMap) {
     FX_WCHAR* dest_buf = result.GetBuffer(src_len);
     for (FX_DWORD i = 0; i < src_len; i++) {
       dest_buf[i] = PDFDocEncoding[src_data[i]];
@@ -473,7 +473,7 @@
     len = FXSYS_wcslen(pString);
   }
   CFX_ByteString result;
-  if (pCharMap == NULL) {
+  if (!pCharMap) {
     FX_CHAR* dest_buf1 = result.GetBuffer(len);
     int i;
     for (i = 0; i < len; i++) {
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp
index 6625cce..bf94185 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_document.cpp
@@ -35,11 +35,11 @@
 void CPDF_Document::LoadDoc() {
   m_LastObjNum = m_pParser->GetLastObjNum();
   CPDF_Object* pRootObj = GetIndirectObject(m_pParser->GetRootObjNum());
-  if (pRootObj == NULL) {
+  if (!pRootObj) {
     return;
   }
   m_pRootDict = pRootObj->GetDict();
-  if (m_pRootDict == NULL) {
+  if (!m_pRootDict) {
     return;
   }
   CPDF_Object* pInfoObj = GetIndirectObject(m_pParser->GetInfoObjNum());
@@ -58,7 +58,7 @@
   m_LastObjNum = m_pParser->GetLastObjNum();
   CPDF_Object* indirectObj = GetIndirectObject(m_pParser->GetRootObjNum());
   m_pRootDict = indirectObj ? indirectObj->GetDict() : NULL;
-  if (m_pRootDict == NULL) {
+  if (!m_pRootDict) {
     return;
   }
   indirectObj = GetIndirectObject(m_pParser->GetInfoObjNum());
@@ -100,7 +100,7 @@
                                              int nPagesToGo,
                                              int level) {
   CPDF_Array* pKidList = pPages->GetArray("Kids");
-  if (pKidList == NULL) {
+  if (!pKidList) {
     if (nPagesToGo == 0) {
       return pPages;
     }
@@ -112,7 +112,7 @@
   int nKids = pKidList->GetCount();
   for (int i = 0; i < nKids; i++) {
     CPDF_Dictionary* pKid = pKidList->GetDict(i);
-    if (pKid == NULL) {
+    if (!pKid) {
       nPagesToGo--;
       continue;
     }
@@ -175,7 +175,7 @@
                                   int level) {
   if (pNode->KeyExist("Kids")) {
     CPDF_Array* pKidList = pNode->GetArray("Kids");
-    if (pKidList == NULL) {
+    if (!pKidList) {
       return -1;
     }
     if (level >= FX_MAX_PAGE_LEVEL) {
@@ -199,7 +199,7 @@
     }
     for (FX_DWORD i = 0; i < pKidList->GetCount(); i++) {
       CPDF_Dictionary* pKid = pKidList->GetDict(i);
-      if (pKid == NULL) {
+      if (!pKid) {
         continue;
       }
       if (pKid == pNode) {
@@ -237,11 +237,11 @@
     }
   }
   CPDF_Dictionary* pRoot = GetRoot();
-  if (pRoot == NULL) {
+  if (!pRoot) {
     return -1;
   }
   CPDF_Dictionary* pPages = pRoot->GetDict("Pages");
-  if (pPages == NULL) {
+  if (!pPages) {
     return -1;
   }
   int index = 0;
@@ -259,13 +259,13 @@
     return count;
   }
   CPDF_Array* pKidList = pPages->GetArray("Kids");
-  if (pKidList == NULL) {
+  if (!pKidList) {
     return 0;
   }
   count = 0;
   for (FX_DWORD i = 0; i < pKidList->GetCount(); i++) {
     CPDF_Dictionary* pKid = pKidList->GetDict(i);
-    if (pKid == NULL) {
+    if (!pKid) {
       continue;
     }
     if (!pKid->KeyExist("Kids")) {
@@ -279,11 +279,11 @@
 }
 int CPDF_Document::_GetPageCount() const {
   CPDF_Dictionary* pRoot = GetRoot();
-  if (pRoot == NULL) {
+  if (!pRoot) {
     return 0;
   }
   CPDF_Dictionary* pPages = pRoot->GetDict("Pages");
-  if (pPages == NULL) {
+  if (!pPages) {
     return 0;
   }
   if (!pPages->KeyExist("Kids")) {
@@ -300,7 +300,7 @@
     }
     CPDF_Object* pContents =
         pPageDict ? pPageDict->GetElement("Contents") : NULL;
-    if (pContents == NULL) {
+    if (!pContents) {
       continue;
     }
     if (pContents->GetDirectType() == PDFOBJ_ARRAY) {
@@ -317,16 +317,13 @@
   return FALSE;
 }
 FX_DWORD CPDF_Document::GetUserPermissions(FX_BOOL bCheckRevision) const {
-  if (m_pParser == NULL) {
+  if (!m_pParser) {
     return (FX_DWORD)-1;
   }
   return m_pParser->GetPermissions(bCheckRevision);
 }
 FX_BOOL CPDF_Document::IsOwner() const {
-  if (m_pParser == NULL) {
-    return TRUE;
-  }
-  return m_pParser->IsOwner();
+  return !m_pParser || m_pParser->IsOwner();
 }
 FX_BOOL CPDF_Document::IsFormStream(FX_DWORD objnum, FX_BOOL& bForm) const {
   {
@@ -337,7 +334,7 @@
       return TRUE;
     }
   }
-  if (m_pParser == NULL) {
+  if (!m_pParser) {
     bForm = FALSE;
     return TRUE;
   }
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_encrypt.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_encrypt.cpp
index d2379fe..0ee0d9a 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_encrypt.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_encrypt.cpp
@@ -115,14 +115,14 @@
   keylen = 0;
   if (Version >= 4) {
     CPDF_Dictionary* pCryptFilters = pEncryptDict->GetDict("CF");
-    if (pCryptFilters == NULL) {
+    if (!pCryptFilters) {
       return FALSE;
     }
     if (name == "Identity") {
       cipher = FXCIPHER_NONE;
     } else {
       CPDF_Dictionary* pDefFilter = pCryptFilters->GetDict(name);
-      if (pDefFilter == NULL) {
+      if (!pDefFilter) {
         return FALSE;
       }
       int nKeyBits = 0;
@@ -329,7 +329,7 @@
   if (FXSYS_memcmp(digest, pkey, 32) != 0) {
     return FALSE;
   }
-  if (key == NULL) {
+  if (!key) {
     return TRUE;
   }
   if (m_Revision >= 6) {
@@ -399,7 +399,7 @@
     return AES256_CheckPassword(password, size, bOwner, key);
   }
   uint8_t keybuf[32];
-  if (key == NULL) {
+  if (!key) {
     key = keybuf;
   }
   if (bOwner) {
@@ -541,7 +541,7 @@
   if (!LoadDict(pEncryptDict, type, cipher, key_len)) {
     return;
   }
-  if (bDefault && (owner_pass == NULL || owner_size == 0)) {
+  if (bDefault && (!owner_pass || owner_size == 0)) {
     owner_pass = user_pass;
     owner_size = user_size;
   }
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp
index f61036a..df7b7a3 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_fdf.cpp
@@ -30,7 +30,7 @@
   }
   CFDF_Document* pDoc = new CFDF_Document;
   pDoc->ParseStream(pFile, bOwnFile);
-  if (pDoc->m_pRootDict == NULL) {
+  if (!pDoc->m_pRootDict) {
     delete pDoc;
     return NULL;
   }
@@ -59,7 +59,7 @@
         break;
       }
       CPDF_Object* pObj = parser.GetObject(this, objnum, 0, 0);
-      if (pObj == NULL) {
+      if (!pObj) {
         break;
       }
       InsertIndirectObject(objnum, pObj);
@@ -81,7 +81,7 @@
   }
 }
 FX_BOOL CFDF_Document::WriteBuf(CFX_ByteTextBuf& buf) const {
-  if (m_pRootDict == NULL) {
+  if (!m_pRootDict) {
     return FALSE;
   }
   buf << "%FDF-1.2\r\n";
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
index 58b03c1..c503277 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp
@@ -582,7 +582,7 @@
 }
 CPDF_Object* CPDF_Dictionary::GetNextElement(FX_POSITION& pos,
                                              CFX_ByteString& key) const {
-  if (pos == NULL) {
+  if (!pos) {
     return NULL;
   }
   CPDF_Object* p;
@@ -736,7 +736,7 @@
   ASSERT(m_Type == PDFOBJ_DICTIONARY);
   CPDF_Object* p = NULL;
   m_Map.Lookup(key, (void*&)p);
-  if (p == NULL) {
+  if (!p) {
     return;
   }
   p->Release();
@@ -747,14 +747,14 @@
   ASSERT(m_Type == PDFOBJ_DICTIONARY);
   CPDF_Object* p = NULL;
   m_Map.Lookup(oldkey, (void*&)p);
-  if (p == NULL) {
+  if (!p) {
     return;
   }
   m_Map.RemoveKey(oldkey);
   m_Map.SetAt(newkey, p);
 }
 FX_BOOL CPDF_Dictionary::Identical(CPDF_Dictionary* pOther) const {
-  if (pOther == NULL) {
+  if (!pOther) {
     return FALSE;
   }
   if (m_Map.GetCount() != pOther->m_Map.GetCount()) {
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
index fcb1c2e..f18b733 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
@@ -273,7 +273,7 @@
 FX_DWORD CPDF_Parser::SetEncryptHandler() {
   ReleaseEncryptHandler();
   SetEncryptDictionary(NULL);
-  if (m_pTrailer == NULL) {
+  if (!m_pTrailer) {
     return PDFPARSE_ERROR_FORMAT;
   }
   CPDF_Object* pEncryptObj = m_pTrailer->GetElement("Encrypt");
@@ -348,7 +348,7 @@
     return FALSE;
   }
   m_pTrailer = LoadTrailerV4();
-  if (m_pTrailer == NULL) {
+  if (!m_pTrailer) {
     return FALSE;
   }
   int32_t xrefsize = GetDirectInteger(m_pTrailer, "Size");
@@ -399,7 +399,7 @@
     return FALSE;
   }
   m_pTrailer = LoadTrailerV4();
-  if (m_pTrailer == NULL) {
+  if (!m_pTrailer) {
     return FALSE;
   }
   int32_t xrefsize = GetDirectInteger(m_pTrailer, "Size");
@@ -414,7 +414,7 @@
     CrossRefList.InsertAt(0, xrefpos);
     LoadCrossRefV4(xrefpos, 0, TRUE, FALSE);
     CPDF_Dictionary* pDict = LoadTrailerV4();
-    if (pDict == NULL) {
+    if (!pDict) {
       return FALSE;
     }
     xrefpos = GetDirectInteger(pDict, "Prev");
@@ -434,7 +434,7 @@
   void* pResult =
       FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOffset.GetSize(),
                     sizeof(FX_FILESIZE), CompareFileSize);
-  if (pResult == NULL) {
+  if (!pResult) {
     m_SortedOffset.Add(pos);
   }
   FX_DWORD start_objnum = 0;
@@ -478,7 +478,7 @@
           void* pResult = FXSYS_bsearch(
               &m_CrossRef[objnum], m_SortedOffset.GetData(),
               m_SortedOffset.GetSize(), sizeof(FX_FILESIZE), CompareFileSize);
-          if (pResult == NULL) {
+          if (!pResult) {
             m_SortedOffset.Add(m_CrossRef[objnum]);
           }
         }
@@ -778,7 +778,7 @@
                     FXSYS_bsearch(&obj_pos, m_SortedOffset.GetData(),
                                   m_SortedOffset.GetSize(), sizeof(FX_FILESIZE),
                                   CompareFileSize);
-                if (pResult == NULL) {
+                if (!pResult) {
                   m_SortedOffset.Add(obj_pos);
                 }
                 FX_FILESIZE obj_end = 0;
@@ -980,7 +980,7 @@
   void* pResult =
       FXSYS_bsearch(&offset, m_SortedOffset.GetData(), m_SortedOffset.GetSize(),
                     sizeof(FX_FILESIZE), CompareFileSize);
-  if (pResult == NULL) {
+  if (!pResult) {
     m_SortedOffset.Add(offset);
   }
   FX_Free(buffer);
@@ -1043,7 +1043,7 @@
     arrIndex.push_back(std::make_pair(0, size));
   }
   pArray = pStream->GetDict()->GetArray("W");
-  if (pArray == NULL) {
+  if (!pArray) {
     pStream->Release();
     return FALSE;
   }
@@ -1100,7 +1100,7 @@
         void* pResult = FXSYS_bsearch(&offset, m_SortedOffset.GetData(),
                                       m_SortedOffset.GetSize(),
                                       sizeof(FX_FILESIZE), CompareFileSize);
-        if (pResult == NULL) {
+        if (!pResult) {
           m_SortedOffset.Add(offset);
         }
         continue;
@@ -1119,7 +1119,7 @@
           void* pResult = FXSYS_bsearch(&offset, m_SortedOffset.GetData(),
                                         m_SortedOffset.GetSize(),
                                         sizeof(FX_FILESIZE), CompareFileSize);
-          if (pResult == NULL) {
+          if (!pResult) {
             m_SortedOffset.Add(offset);
           }
         } else {
@@ -1172,7 +1172,7 @@
   void* pResult =
       FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOffset.GetSize(),
                     sizeof(FX_FILESIZE), CompareFileSize);
-  if (pResult == NULL) {
+  if (!pResult) {
     return TRUE;
   }
   if ((FX_FILESIZE*)pResult - (FX_FILESIZE*)m_SortedOffset.GetData() ==
@@ -1261,7 +1261,7 @@
     void* pResult = FXSYS_bsearch(&offset, m_SortedOffset.GetData(),
                                   m_SortedOffset.GetSize(), sizeof(FX_FILESIZE),
                                   CompareFileSize);
-    if (pResult == NULL) {
+    if (!pResult) {
       return 0;
     }
     if ((FX_FILESIZE*)pResult - (FX_FILESIZE*)m_SortedOffset.GetData() ==
@@ -1344,7 +1344,7 @@
   void* pResult =
       FXSYS_bsearch(&pos, m_SortedOffset.GetData(), m_SortedOffset.GetSize(),
                     sizeof(FX_FILESIZE), CompareFileSize);
-  if (pResult == NULL) {
+  if (!pResult) {
     m_Syntax.RestorePos(SavedPos);
     return;
   }
@@ -1490,7 +1490,7 @@
   return dwPermission;
 }
 FX_BOOL CPDF_Parser::IsOwner() {
-  return m_pSecurityHandler == NULL ? TRUE : m_pSecurityHandler->IsOwner();
+  return !m_pSecurityHandler || m_pSecurityHandler->IsOwner();
 }
 void CPDF_Parser::SetSecurityHandler(CPDF_SecurityHandler* pSecurityHandler,
                                      FX_BOOL bForced) {
@@ -1584,7 +1584,7 @@
   }
   if (bLoadV4) {
     m_pTrailer = LoadTrailerV4();
-    if (m_pTrailer == NULL) {
+    if (!m_pTrailer) {
       return FALSE;
     }
     int32_t xrefsize = GetDirectInteger(m_pTrailer, "Size");
@@ -1598,7 +1598,7 @@
     return dwRet;
   }
   m_pDocument->LoadAsynDoc(m_pLinearized->GetDict());
-  if (m_pDocument->GetRoot() == NULL || m_pDocument->GetPageCount() == 0) {
+  if (!m_pDocument->GetRoot() || m_pDocument->GetPageCount() == 0) {
     if (bXRefRebuilt) {
       return PDFPARSE_ERROR_FORMAT;
     }
@@ -1611,7 +1611,7 @@
       return dwRet;
     }
     m_pDocument->LoadAsynDoc(m_pLinearized->GetDict());
-    if (m_pDocument->GetRoot() == NULL) {
+    if (!m_pDocument->GetRoot()) {
       return PDFPARSE_ERROR_FORMAT;
     }
   }
@@ -2984,7 +2984,7 @@
 }
 FX_DWORD CPDF_DataAvail::GetObjectSize(FX_DWORD objnum, FX_FILESIZE& offset) {
   CPDF_Parser* pParser = (CPDF_Parser*)(m_pDocument->GetParser());
-  if (pParser == NULL) {
+  if (!pParser) {
     return 0;
   }
   if (objnum >= (FX_DWORD)pParser->m_CrossRef.GetSize()) {
@@ -3001,7 +3001,7 @@
     void* pResult = FXSYS_bsearch(&offset, pParser->m_SortedOffset.GetData(),
                                   pParser->m_SortedOffset.GetSize(),
                                   sizeof(FX_FILESIZE), CompareFileSize);
-    if (pResult == NULL) {
+    if (!pResult) {
       return 0;
     }
     if ((FX_FILESIZE*)pResult -
@@ -3255,13 +3255,13 @@
   if (pExistInFile)
     *pExistInFile = TRUE;
 
-  if (m_pDocument == NULL) {
+  if (m_pDocument) {
+    size = GetObjectSize(objnum, offset);
+    pParser = (CPDF_Parser*)(m_pDocument->GetParser());
+  } else {
     size = (FX_DWORD)m_parser.GetObjectSize(objnum);
     offset = m_parser.GetObjectOffset(objnum);
     pParser = &m_parser;
-  } else {
-    size = GetObjectSize(objnum, offset);
-    pParser = (CPDF_Parser*)(m_pDocument->GetParser());
   }
   if (!IsDataAvail(offset, size, pHints)) {
     return nullptr;
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
index 121b2f4..6e20b58 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_utility.cpp
@@ -284,7 +284,7 @@
 CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& bstr) {
   int size = bstr.GetLength();
   const FX_CHAR* pSrc = bstr.GetCStr();
-  if (FXSYS_memchr(pSrc, '#', size) == NULL) {
+  if (!FXSYS_memchr(pSrc, '#', size)) {
     return bstr;
   }
   CFX_ByteString result;
@@ -303,7 +303,7 @@
   return result;
 }
 CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig) {
-  if (FXSYS_memchr(orig.c_str(), '#', orig.GetLength()) == NULL) {
+  if (!FXSYS_memchr(orig.c_str(), '#', orig.GetLength())) {
     return orig;
   }
   return PDF_NameDecode(CFX_ByteStringC(orig));
@@ -344,7 +344,7 @@
   return res;
 }
 CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& buf, const CPDF_Object* pObj) {
-  if (pObj == NULL) {
+  if (!pObj) {
     buf << " null";
     return buf;
   }
@@ -444,12 +444,12 @@
     return NULL;
   }
   CPDF_Array* pKids = pNode->GetArray("Kids");
-  if (pKids == NULL) {
+  if (!pKids) {
     return NULL;
   }
   for (FX_DWORD i = 0; i < pKids->GetCount(); i++) {
     CPDF_Dictionary* pKid = pKids->GetDict(i);
-    if (pKid == NULL) {
+    if (!pKid) {
       continue;
     }
     CPDF_Object* pFound = SearchNumberNode(pKid, num);
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
index 801f9e7..bee188e 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
@@ -258,7 +258,7 @@
     if (!pCurObj) {
       continue;
     }
-    if (pCurObj == NULL || pCurObj->m_Left > clip_rect.right ||
+    if (!pCurObj || pCurObj->m_Left > clip_rect.right ||
         pCurObj->m_Right < clip_rect.left ||
         pCurObj->m_Bottom > clip_rect.top ||
         pCurObj->m_Top < clip_rect.bottom) {
@@ -358,7 +358,7 @@
 void CPDF_RenderStatus::DitherObjectArea(const CPDF_PageObject* pObj,
                                          const CFX_Matrix* pObj2Device) {
   CFX_DIBitmap* pBitmap = m_pDevice->GetBitmap();
-  if (pBitmap == NULL) {
+  if (!pBitmap) {
     return;
   }
   FX_RECT rect;
@@ -684,7 +684,7 @@
   int i;
   for (i = 0; i < nClipPath; i++) {
     const CFX_PathData* pPathData = ClipPath.GetPath(i);
-    if (pPathData == NULL) {
+    if (!pPathData) {
       continue;
     }
     CFX_GraphStateData stroke_state;
@@ -780,8 +780,8 @@
       pDocument->GetPageData()->ReleaseColorSpace(pCSObj);
     }
   }
-  if (pSMaskDict == NULL && group_alpha == 1.0f &&
-      blend_type == FXDIB_BLEND_NORMAL && !bTextClip && !bGroupTransparent) {
+  if (!pSMaskDict && group_alpha == 1.0f && blend_type == FXDIB_BLEND_NORMAL &&
+      !bTextClip && !bGroupTransparent) {
     return FALSE;
   }
   FX_BOOL isolated = Transparency & PDFTRANS_ISOLATED;
@@ -838,7 +838,7 @@
     text_device.Attach(pTextMask.get());
     for (FX_DWORD i = 0; i < pPageObj->m_ClipPath.GetTextCount(); i++) {
       CPDF_TextObject* textobj = pPageObj->m_ClipPath.GetText(i);
-      if (textobj == NULL) {
+      if (!textobj) {
         break;
       }
       CFX_Matrix text_matrix;
@@ -1079,7 +1079,7 @@
   for (; m_LayerIndex < nLayers; m_LayerIndex++) {
     _PDF_RenderItem* pItem = m_pContext->m_ContentList.GetDataPtr(m_LayerIndex);
     FX_POSITION LastPos = pItem->m_pObjectList->GetLastObjectPosition();
-    if (m_ObjectPos == NULL) {
+    if (!m_ObjectPos) {
       if (LastPos == m_PrevLastPos) {
         if (!pItem->m_pObjectList->IsParsed()) {
           pItem->m_pObjectList->ContinueParse(pPause);
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp
index 7a28ddc..babf703 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp
@@ -74,7 +74,7 @@
 }
 void CPDF_PageRenderCache::ClearImageCache(CPDF_Stream* pStream) {
   void* value = m_ImageCaches.GetValueAt(pStream);
-  if (value == NULL) {
+  if (!value) {
     m_ImageCaches.RemoveKey(pStream);
     return;
   }
@@ -95,7 +95,7 @@
   return dwSize;
 }
 FX_DWORD CPDF_PageRenderCache::GetCachedSize(CPDF_Stream* pStream) const {
-  if (pStream == NULL) {
+  if (!pStream) {
     return m_nCacheSize;
   }
   CPDF_ImageCache* pImageCache;
@@ -175,7 +175,7 @@
                                        const CFX_DIBitmap* pBitmap) {
   CPDF_ImageCache* pImageCache;
   if (!m_ImageCaches.Lookup(pStream, (void*&)pImageCache)) {
-    if (pBitmap == NULL) {
+    if (!pBitmap) {
       return;
     }
     pImageCache = new CPDF_ImageCache(m_pPage->m_pDocument, pStream);
@@ -220,7 +220,7 @@
   }
 }
 void CPDF_ImageCache::ClearImageData() {
-  if (m_pCachedBitmap && m_pCachedBitmap->GetBuffer() == NULL) {
+  if (m_pCachedBitmap && !m_pCachedBitmap->GetBuffer()) {
     ((CPDF_DIBSource*)m_pCachedBitmap)->ClearImageData();
   }
 }
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp
index 938a495..d339051 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp
@@ -29,7 +29,7 @@
                                           int bitmap_alpha,
                                           int blend_mode,
                                           int Transparency) {
-  if (pDIBitmap == NULL) {
+  if (!pDIBitmap) {
     return;
   }
   FX_BOOL bIsolated = Transparency & PDFTRANS_ISOLATED;
@@ -353,7 +353,7 @@
   return FALSE;
 }
 FX_BOOL CPDF_ImageRenderer::StartRenderDIBSource() {
-  if (m_Loader.m_pBitmap == NULL) {
+  if (!m_Loader.m_pBitmap) {
     return FALSE;
   }
   m_BitmapAlpha = 255;
@@ -363,7 +363,7 @@
   }
   m_pDIBSource = m_Loader.m_pBitmap;
   if (m_pRenderStatus->m_Options.m_ColorMode == RENDER_COLOR_ALPHA &&
-      m_Loader.m_pMask == NULL) {
+      !m_Loader.m_pMask) {
     return StartBitmapAlpha();
   }
   if (pGeneralState && pGeneralState->m_pTR) {
@@ -844,7 +844,7 @@
       return TRUE;
     }
     CFX_DIBitmap* pBitmap = m_pTransformer->m_Storer.Detach();
-    if (pBitmap == NULL) {
+    if (!pBitmap) {
       return FALSE;
     }
     if (pBitmap->IsAlphaMask()) {
@@ -934,11 +934,11 @@
   m_pCS = NULL;
   m_Bpp = 3;
   CPDF_Object* pCSObj = pDict->GetElementValue("ColorSpace");
-  if (pCSObj == NULL) {
+  if (!pCSObj) {
     return FALSE;
   }
   m_pCS = CPDF_ColorSpace::Load(pImageObj->m_pImage->GetDocument(), pCSObj);
-  if (m_pCS == NULL) {
+  if (!m_pCS) {
     return FALSE;
   }
   if (!_IsSupported(m_pCS)) {
@@ -995,12 +995,12 @@
     const uint8_t* src_scan;
     if (m_pDecoder) {
       src_scan = m_pDecoder->GetScanline(src_y);
-      if (src_scan == NULL) {
+      if (!src_scan) {
         break;
       }
     } else {
       src_scan = m_StreamAcc.GetData();
-      if (src_scan == NULL) {
+      if (!src_scan) {
         break;
       }
       src_scan += src_y * src_pitch;
@@ -1011,7 +1011,7 @@
       int src_x = (m_bFlipX ? (m_DestWidth - dest_x - 1) : dest_x) * src_width /
                   m_DestWidth;
       const uint8_t* src_pixel = src_scan + src_x * m_Bpp;
-      if (m_pCS == NULL) {
+      if (!m_pCS) {
         *result_scan = src_pixel[2];
         result_scan++;
         *result_scan = src_pixel[1];
@@ -1040,7 +1040,7 @@
 CFX_DIBitmap* CPDF_RenderStatus::LoadSMask(CPDF_Dictionary* pSMaskDict,
                                            FX_RECT* pClipRect,
                                            const CFX_Matrix* pMatrix) {
-  if (pSMaskDict == NULL) {
+  if (!pSMaskDict) {
     return NULL;
   }
   int width = pClipRect->right - pClipRect->left;
@@ -1048,7 +1048,7 @@
   FX_BOOL bLuminosity = FALSE;
   bLuminosity = pSMaskDict->GetConstString("S") != "Alpha";
   CPDF_Stream* pGroup = pSMaskDict->GetStream("G");
-  if (pGroup == NULL) {
+  if (!pGroup) {
     return NULL;
   }
   nonstd::unique_ptr<CPDF_Function> pFunc;
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
index 521ec16..7b34c57 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
@@ -212,12 +212,12 @@
                              FX_BOOL bStdCS,
                              FX_DWORD GroupFamily,
                              FX_BOOL bLoadMask) {
-  if (pStream == NULL) {
+  if (!pStream) {
     return FALSE;
   }
   m_pDocument = pDoc;
   m_pDict = pStream->GetDict();
-  if (m_pDict == NULL) {
+  if (!m_pDict) {
     return FALSE;
   }
   m_pStream = pStream;
@@ -243,7 +243,7 @@
   }
   m_pStreamAcc = new CPDF_StreamAcc;
   m_pStreamAcc->LoadAllData(pStream, FALSE, src_size.ValueOrDie(), TRUE);
-  if (m_pStreamAcc->GetSize() == 0 || m_pStreamAcc->GetData() == NULL) {
+  if (m_pStreamAcc->GetSize() == 0 || !m_pStreamAcc->GetData()) {
     return FALSE;
   }
   if (!CreateDecoder()) {
@@ -333,7 +333,7 @@
                                        FX_BOOL bStdCS,
                                        FX_DWORD GroupFamily,
                                        FX_BOOL bLoadMask) {
-  if (pStream == NULL) {
+  if (!pStream) {
     return 0;
   }
   m_pDocument = pDoc;
@@ -363,7 +363,7 @@
   }
   m_pStreamAcc = new CPDF_StreamAcc;
   m_pStreamAcc->LoadAllData(pStream, FALSE, src_size.ValueOrDie(), TRUE);
-  if (m_pStreamAcc->GetSize() == 0 || m_pStreamAcc->GetData() == NULL) {
+  if (m_pStreamAcc->GetSize() == 0 || !m_pStreamAcc->GetData()) {
     return 0;
   }
   int ret = CreateDecoder();
@@ -401,7 +401,7 @@
       return 0;
     }
     ICodec_Jbig2Module* pJbig2Module = CPDF_ModuleMgr::Get()->GetJbig2Module();
-    if (m_pJbig2Context == NULL) {
+    if (!m_pJbig2Context) {
       m_pJbig2Context = pJbig2Module->CreateJbig2Context();
       if (m_pStreamAcc->GetImageParam()) {
         CPDF_Stream* pGlobals =
@@ -531,7 +531,7 @@
 
 DIB_COMP_DATA* CPDF_DIBSource::GetDecodeAndMaskArray(FX_BOOL& bDefaultDecode,
                                                      FX_BOOL& bColorKey) {
-  if (m_pColorSpace == NULL) {
+  if (!m_pColorSpace) {
     return NULL;
   }
   DIB_COMP_DATA* pCompData = FX_Alloc(DIB_COMP_DATA, m_nComponents);
@@ -565,7 +565,7 @@
   }
   if (!m_pDict->KeyExist("SMask")) {
     CPDF_Object* pMask = m_pDict->GetElementValue("Mask");
-    if (pMask == NULL) {
+    if (!pMask) {
       return pCompData;
     }
     if (CPDF_Array* pArray = pMask->AsArray()) {
@@ -628,7 +628,7 @@
             return 0;
           }
           m_pCompData = GetDecodeAndMaskArray(m_bDefaultDecode, m_bColorKey);
-          if (m_pCompData == NULL) {
+          if (!m_pCompData) {
             return 0;
           }
         }
@@ -807,7 +807,7 @@
   return m_pMaskStream ? StartLoadMaskDIB() : 1;
 }
 int CPDF_DIBSource::ContinueLoadMaskDIB(IFX_Pause* pPause) {
-  if (m_pMask == NULL) {
+  if (!m_pMask) {
     return 1;
   }
   int ret = m_pMask->ContinueLoadDIBSource(pPause);
@@ -860,7 +860,7 @@
   if (m_bpc * m_nComponents > 8) {
     return;
   }
-  if (m_pColorSpace == NULL) {
+  if (!m_pColorSpace) {
     return;
   }
   if (m_bpc * m_nComponents == 1) {
@@ -1606,7 +1606,7 @@
                                FX_DWORD GroupFamily,
                                FX_BOOL bLoadMask,
                                CPDF_RenderStatus* pRenderStatus) {
-  if (pImage == NULL) {
+  if (!pImage) {
     return FALSE;
   }
   if (pCache) {
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
index 8b6c0d1..9076b7b 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp
@@ -21,7 +21,7 @@
                              int alpha) {
   ASSERT(pBitmap->GetFormat() == FXDIB_Argb);
   CPDF_Array* pCoords = pDict->GetArray("Coords");
-  if (pCoords == NULL) {
+  if (!pCoords) {
     return;
   }
   FX_FLOAT start_x = pCoords->GetNumber(0);
@@ -112,7 +112,7 @@
                               int alpha) {
   ASSERT(pBitmap->GetFormat() == FXDIB_Argb);
   CPDF_Array* pCoords = pDict->GetArray("Coords");
-  if (pCoords == NULL) {
+  if (!pCoords) {
     return;
   }
   FX_FLOAT start_x = pCoords->GetNumber(0);
@@ -834,7 +834,7 @@
   int nFuncs = pPattern->m_nFuncs;
   CPDF_Dictionary* pDict = pPattern->m_pShadingObj->GetDict();
   CPDF_ColorSpace* pColorSpace = pPattern->m_pCS;
-  if (pColorSpace == NULL) {
+  if (!pColorSpace) {
     return;
   }
   FX_ARGB background = 0;
@@ -864,7 +864,7 @@
   CFX_Matrix FinalMatrix = *pMatrix;
   FinalMatrix.Concat(*buffer.GetMatrix());
   CFX_DIBitmap* pBitmap = buffer.GetBitmap();
-  if (pBitmap->GetBuffer() == NULL) {
+  if (!pBitmap->GetBuffer()) {
     return;
   }
   pBitmap->Clear(background);
@@ -1121,7 +1121,7 @@
         m_pContext->m_pDocument, m_pContext->m_pPageCache, pPattern,
         pObj2Device, width, height, m_Options.m_Flags);
   }
-  if (pPatternBitmap == NULL) {
+  if (!pPatternBitmap) {
     m_pDevice->RestoreState();
     return;
   }
@@ -1185,7 +1185,7 @@
                                             CPDF_Color* pColor,
                                             FX_BOOL bStroke) {
   CPDF_Pattern* pattern = pColor->GetPattern();
-  if (pattern == NULL) {
+  if (!pattern) {
     return;
   }
   if (pattern->m_PatternType == PATTERN_TILING) {
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp
index 774e749..05a5e04 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp
@@ -163,11 +163,11 @@
     } else {
     }
   }
-  if (pResBitmap == NULL) {
+  if (!pResBitmap) {
     image_matrix.Scale(retinaScaleX, retinaScaleY);
     pResBitmap = pBitmap->TransformTo(&image_matrix, left, top);
   }
-  if (pResBitmap == NULL) {
+  if (!pResBitmap) {
     return NULL;
   }
   CFX_GlyphBitmap* pGlyph = new CFX_GlyphBitmap;
@@ -212,7 +212,7 @@
         break;
       case 1:
       case 5:
-        if (pFont->GetFace() == NULL &&
+        if (!pFont->GetFace() &&
             !(pFont->GetSubstFont()->m_SubstFlags & FXFONT_SUBST_GLYPHPATH)) {
           bFill = TRUE;
         } else {
@@ -221,7 +221,7 @@
         break;
       case 2:
       case 6:
-        if (pFont->GetFace() == NULL &&
+        if (!pFont->GetFace() &&
             !(pFont->GetSubstFont()->m_SubstFlags & FXFONT_SUBST_GLYPHPATH)) {
           bFill = TRUE;
         } else {
@@ -299,21 +299,21 @@
       pFont, font_size, &text_matrix, fill_argb, &m_Options);
 }
 CPDF_Type3Cache* CPDF_RenderStatus::GetCachedType3(CPDF_Type3Font* pFont) {
-  if (pFont->m_pDocument == NULL) {
+  if (!pFont->m_pDocument) {
     return NULL;
   }
   pFont->m_pDocument->GetPageData()->GetFont(pFont->GetFontDict(), FALSE);
   return pFont->m_pDocument->GetRenderData()->GetCachedType3(pFont);
 }
 static void ReleaseCachedType3(CPDF_Type3Font* pFont) {
-  if (pFont->m_pDocument == NULL) {
+  if (!pFont->m_pDocument) {
     return;
   }
   pFont->m_pDocument->GetRenderData()->ReleaseCachedType3(pFont);
   pFont->m_pDocument->GetPageData()->ReleaseFont(pFont->GetFontDict());
 }
 FX_BOOL CPDF_Type3Char::LoadBitmap(CPDF_RenderContext* pContext) {
-  if (m_pBitmap || m_pForm == NULL) {
+  if (m_pBitmap || !m_pForm) {
     return TRUE;
   }
   if (m_pForm->CountObjects() == 1 && !m_bColored) {
@@ -383,7 +383,7 @@
       continue;
     }
     CPDF_Type3Char* pType3Char = pType3Font->LoadChar(charcode);
-    if (pType3Char == NULL) {
+    if (!pType3Char) {
       continue;
     }
     CFX_Matrix matrix = char_matrix;
@@ -394,7 +394,7 @@
       if (pGlyphAndPos) {
         for (int i = 0; i < iChar; i++) {
           FXTEXT_GLYPHPOS& glyph = pGlyphAndPos[i];
-          if (glyph.m_pGlyph == NULL) {
+          if (!glyph.m_pGlyph) {
             continue;
           }
           m_pDevice->SetBitMask(&glyph.m_pGlyph->m_Bitmap,
@@ -452,7 +452,7 @@
         CPDF_Type3Cache* pCache = GetCachedType3(pType3Font);
         refTypeCache.m_dwCount++;
         CFX_GlyphBitmap* pBitmap = pCache->LoadGlyph(charcode, &matrix, sa, sd);
-        if (pBitmap == NULL) {
+        if (!pBitmap) {
           continue;
         }
         int origin_x = FXSYS_round(matrix.e);
@@ -491,7 +491,7 @@
     bitmap.Clear(0);
     for (int iChar = 0; iChar < textobj->m_nChars; iChar++) {
       FXTEXT_GLYPHPOS& glyph = pGlyphAndPos[iChar];
-      if (glyph.m_pGlyph == NULL) {
+      if (!glyph.m_pGlyph) {
         continue;
       }
       bitmap.TransferBitmap(
@@ -557,7 +557,7 @@
     charpos.m_OriginX = iChar ? pCharPos[iChar - 1] : 0;
     charpos.m_OriginY = 0;
     charpos.m_bGlyphAdjust = FALSE;
-    if (pCIDFont == NULL) {
+    if (!pCIDFont) {
       continue;
     }
     FX_WORD CID = pCIDFont->CIDFromCharCode(CharCode);
@@ -762,7 +762,7 @@
     FXTEXT_CHARPOS& charpos = CharPosList.m_pCharPos[i];
     const CFX_PathData* pPath = pFaceCache->LoadGlyphPath(
         &pFont->m_Font, charpos.m_GlyphIndex, charpos.m_FontCharWidth);
-    if (pPath == NULL) {
+    if (!pPath) {
       continue;
     }
     CPDF_PathObject path;
diff --git a/core/src/fpdfdoc/doc_action.cpp b/core/src/fpdfdoc/doc_action.cpp
index 87cfe7e..e68a8c8 100644
--- a/core/src/fpdfdoc/doc_action.cpp
+++ b/core/src/fpdfdoc/doc_action.cpp
@@ -56,7 +56,7 @@
   }
   CPDF_Object* pFile = m_pDict->GetElementValue("F");
   CFX_WideString path;
-  if (pFile == NULL) {
+  if (!pFile) {
     if (type == "Launch") {
       CPDF_Dictionary* pWinDict = m_pDict->GetDict("Win");
       if (pWinDict) {
@@ -71,7 +71,7 @@
 }
 CFX_ByteString CPDF_Action::GetURI(CPDF_Document* pDoc) const {
   CFX_ByteString csURI;
-  if (m_pDict == NULL) {
+  if (!m_pDict) {
     return csURI;
   }
   if (m_pDict->GetString("S") != "URI") {
@@ -88,11 +88,11 @@
   return csURI;
 }
 FX_DWORD CPDF_ActionFields::GetFieldsCount() const {
-  if (m_pAction == NULL) {
+  if (!m_pAction) {
     return 0;
   }
   CPDF_Dictionary* pDict = m_pAction->GetDict();
-  if (pDict == NULL) {
+  if (!pDict) {
     return 0;
   }
   CFX_ByteString csType = pDict->GetString("S");
@@ -146,11 +146,11 @@
 }
 
 CPDF_Object* CPDF_ActionFields::GetField(FX_DWORD iIndex) const {
-  if (m_pAction == NULL) {
+  if (!m_pAction) {
     return NULL;
   }
   CPDF_Dictionary* pDict = m_pAction->GetDict();
-  if (pDict == NULL) {
+  if (!pDict) {
     return NULL;
   }
   CFX_ByteString csType = pDict->GetString("S");
@@ -160,7 +160,7 @@
   } else {
     pFields = pDict->GetArray("Fields");
   }
-  if (pFields == NULL) {
+  if (!pFields) {
     return NULL;
   }
   CPDF_Object* pFindObj = NULL;
@@ -175,7 +175,7 @@
 
 CFX_WideString CPDF_Action::GetJavaScript() const {
   CFX_WideString csJS;
-  if (m_pDict == NULL) {
+  if (!m_pDict) {
     return csJS;
   }
   CPDF_Object* pJS = m_pDict->GetElementValue("JS");
@@ -195,7 +195,7 @@
   return nullptr;
 }
 int32_t CPDF_Action::GetOperationType() const {
-  if (m_pDict == NULL) {
+  if (!m_pDict) {
     return 0;
   }
   CFX_ByteString csType = m_pDict->GetString("S");
@@ -233,7 +233,7 @@
   return 0;
 }
 CPDF_Action CPDF_Action::GetSubAction(FX_DWORD iIndex) const {
-  if (m_pDict == NULL || !m_pDict->KeyExist("Next")) {
+  if (!m_pDict || !m_pDict->KeyExist("Next")) {
     return CPDF_Action();
   }
   CPDF_Object* pNext = m_pDict->GetElementValue("Next");
@@ -249,10 +249,7 @@
                                "PV", "PI", "O",  "C",  "K",  "F",  "V",  "C",
                                "WC", "WS", "DS", "WP", "DP", ""};
 FX_BOOL CPDF_AAction::ActionExist(AActionType eType) const {
-  if (m_pDict == NULL) {
-    return FALSE;
-  }
-  return m_pDict->KeyExist(g_sAATypes[(int)eType]);
+  return m_pDict && m_pDict->KeyExist(g_sAATypes[(int)eType]);
 }
 CPDF_Action CPDF_AAction::GetAction(AActionType eType) const {
   if (!m_pDict) {
@@ -261,14 +258,14 @@
   return CPDF_Action(m_pDict->GetDict(g_sAATypes[(int)eType]));
 }
 FX_POSITION CPDF_AAction::GetStartPos() const {
-  if (m_pDict == NULL) {
+  if (!m_pDict) {
     return NULL;
   }
   return m_pDict->GetStartPos();
 }
 CPDF_Action CPDF_AAction::GetNextAction(FX_POSITION& pos,
                                         AActionType& eType) const {
-  if (m_pDict == NULL) {
+  if (!m_pDict) {
     return CPDF_Action();
   }
   CFX_ByteString csKey;
diff --git a/core/src/fpdfdoc/doc_annot.cpp b/core/src/fpdfdoc/doc_annot.cpp
index 0871b35..8f3d7f9 100644
--- a/core/src/fpdfdoc/doc_annot.cpp
+++ b/core/src/fpdfdoc/doc_annot.cpp
@@ -133,7 +133,7 @@
 }
 
 void CPDF_Annot::GetRect(CPDF_Rect& rect) const {
-  if (m_pAnnotDict == NULL) {
+  if (!m_pAnnotDict) {
     return;
   }
   rect = m_pAnnotDict->GetRect("Rect");
@@ -147,7 +147,7 @@
 CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict,
                                 CPDF_Annot::AppearanceMode mode) {
   CPDF_Dictionary* pAP = pAnnotDict->GetDict("AP");
-  if (pAP == NULL) {
+  if (!pAP) {
     return NULL;
   }
   const FX_CHAR* ap_entry = "N";
@@ -267,14 +267,14 @@
   char style_char;
   FX_FLOAT width;
   CPDF_Array* pDashArray = NULL;
-  if (pBS == NULL) {
+  if (!pBS) {
     CPDF_Array* pBorderArray = m_pAnnotDict->GetArray("Border");
     style_char = 'S';
     if (pBorderArray) {
       width = pBorderArray->GetNumber(2);
       if (pBorderArray->GetCount() == 4) {
         pDashArray = pBorderArray->GetArray(3);
-        if (pDashArray == NULL) {
+        if (!pDashArray) {
           return;
         }
         int nLen = pDashArray->GetCount();
diff --git a/core/src/fpdfdoc/doc_ap.cpp b/core/src/fpdfdoc/doc_ap.cpp
index 1392ae6..0efaa8c 100644
--- a/core/src/fpdfdoc/doc_ap.cpp
+++ b/core/src/fpdfdoc/doc_ap.cpp
@@ -292,7 +292,7 @@
   FX_BOOL bUseFormRes = FALSE;
   CPDF_Dictionary* pFontDict = NULL;
   CPDF_Dictionary* pDRDict = pAnnotDict->GetDict("DR");
-  if (pDRDict == NULL) {
+  if (!pDRDict) {
     pDRDict = pFormDict->GetDict("DR");
     bUseFormRes = TRUE;
   }
@@ -312,7 +312,7 @@
   }
   if (!pFontDict) {
     pFontDict = CPDF_Dictionary::Create();
-    if (pFontDict == NULL) {
+    if (!pFontDict) {
       return FALSE;
     }
     pFontDict->SetAtName("Type", "Font");
@@ -418,11 +418,8 @@
                 rcBBox.right - fBorderWidth, rcBBox.top - fBorderWidth);
   rcBody.Normalize();
   CPDF_Dictionary* pAPDict = pAnnotDict->GetDict("AP");
-  if (pAPDict == NULL) {
+  if (!pAPDict) {
     pAPDict = CPDF_Dictionary::Create();
-    if (pAPDict == NULL) {
-      return FALSE;
-    }
     pAnnotDict->SetAt("AP", pAPDict);
   }
   CPDF_Stream* pNormalStream = pAPDict->GetStream("N");
@@ -440,7 +437,7 @@
       CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDict("Font");
       if (!pStreamResFontList) {
         pStreamResFontList = CPDF_Dictionary::Create();
-        if (pStreamResFontList == NULL) {
+        if (!pStreamResFontList) {
           return FALSE;
         }
         pStreamResList->SetAt("Font", pStreamResFontList);
@@ -688,7 +685,7 @@
         CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDict("Font");
         if (!pStreamResFontList) {
           pStreamResFontList = CPDF_Dictionary::Create();
-          if (pStreamResFontList == NULL) {
+          if (!pStreamResFontList) {
             return FALSE;
           }
           pStreamResList->SetAt("Font", pStreamResFontList);
diff --git a/core/src/fpdfdoc/doc_basic.cpp b/core/src/fpdfdoc/doc_basic.cpp
index c58e10b..d976650 100644
--- a/core/src/fpdfdoc/doc_basic.cpp
+++ b/core/src/fpdfdoc/doc_basic.cpp
@@ -112,12 +112,12 @@
     return NULL;
   }
   CPDF_Array* pKids = pNode->GetArray("Kids");
-  if (pKids == NULL) {
+  if (!pKids) {
     return NULL;
   }
   for (FX_DWORD i = 0; i < pKids->GetCount(); i++) {
     CPDF_Dictionary* pKid = pKids->GetDict(i);
-    if (pKid == NULL) {
+    if (!pKid) {
       continue;
     }
     CPDF_Object* pFound =
@@ -151,12 +151,12 @@
     return pNames->GetElementValue((nIndex - nCurIndex) * 2 + 1);
   }
   CPDF_Array* pKids = pNode->GetArray("Kids");
-  if (pKids == NULL) {
+  if (!pKids) {
     return NULL;
   }
   for (FX_DWORD i = 0; i < pKids->GetCount(); i++) {
     CPDF_Dictionary* pKid = pKids->GetDict(i);
-    if (pKid == NULL) {
+    if (!pKid) {
       continue;
     }
     CPDF_Object* pFound =
@@ -176,13 +176,13 @@
     return pNames->GetCount() / 2;
   }
   CPDF_Array* pKids = pNode->GetArray("Kids");
-  if (pKids == NULL) {
+  if (!pKids) {
     return 0;
   }
   int nCount = 0;
   for (FX_DWORD i = 0; i < pKids->GetCount(); i++) {
     CPDF_Dictionary* pKid = pKids->GetDict(i);
-    if (pKid == NULL) {
+    if (!pKid) {
       continue;
     }
     nCount += CountNames(pKid, nLevel + 1);
@@ -190,31 +190,31 @@
   return nCount;
 }
 int CPDF_NameTree::GetCount() const {
-  if (m_pRoot == NULL) {
+  if (!m_pRoot) {
     return 0;
   }
   return ::CountNames(m_pRoot);
 }
 int CPDF_NameTree::GetIndex(const CFX_ByteString& csName) const {
-  if (m_pRoot == NULL) {
+  if (!m_pRoot) {
     return -1;
   }
   int nIndex = 0;
-  if (SearchNameNode(m_pRoot, csName, nIndex, NULL) == NULL) {
+  if (!SearchNameNode(m_pRoot, csName, nIndex, NULL)) {
     return -1;
   }
   return nIndex;
 }
 CPDF_Object* CPDF_NameTree::LookupValue(int nIndex,
                                         CFX_ByteString& csName) const {
-  if (m_pRoot == NULL) {
+  if (!m_pRoot) {
     return NULL;
   }
   int nCurIndex = 0;
   return SearchNameNode(m_pRoot, nIndex, nCurIndex, csName, NULL);
 }
 CPDF_Object* CPDF_NameTree::LookupValue(const CFX_ByteString& csName) const {
-  if (m_pRoot == NULL) {
+  if (!m_pRoot) {
     return NULL;
   }
   int nIndex = 0;
@@ -468,11 +468,11 @@
 }
 CFX_WideString CPDF_PageLabel::GetLabel(int nPage) const {
   CFX_WideString wsLabel;
-  if (m_pDocument == NULL) {
+  if (!m_pDocument) {
     return wsLabel;
   }
   CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot();
-  if (pPDFRoot == NULL) {
+  if (!pPDFRoot) {
     return wsLabel;
   }
   CPDF_Dictionary* pLabels = pPDFRoot->GetDict("PageLabels");
@@ -504,11 +504,11 @@
   return wsLabel;
 }
 int32_t CPDF_PageLabel::GetPageByLabel(const CFX_ByteStringC& bsLabel) const {
-  if (m_pDocument == NULL) {
+  if (!m_pDocument) {
     return -1;
   }
   CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot();
-  if (pPDFRoot == NULL) {
+  if (!pPDFRoot) {
     return -1;
   }
   int nPages = m_pDocument->GetPageCount();
diff --git a/core/src/fpdfdoc/doc_form.cpp b/core/src/fpdfdoc/doc_form.cpp
index 80938f4..20b59cd 100644
--- a/core/src/fpdfdoc/doc_form.cpp
+++ b/core/src/fpdfdoc/doc_form.cpp
@@ -95,7 +95,7 @@
 CFieldTree::_Node* CFieldTree::AddChild(_Node* pParent,
                                         const CFX_WideString& short_name,
                                         CPDF_FormField* field_ptr) {
-  if (pParent == NULL) {
+  if (!pParent) {
     return NULL;
   }
   _Node* pNode = new _Node;
@@ -118,7 +118,7 @@
 }
 CFieldTree::_Node* CFieldTree::_Lookup(_Node* pParent,
                                        const CFX_WideString& short_name) {
-  if (pParent == NULL) {
+  if (!pParent) {
     return NULL;
   }
   for (int i = 0; i < pParent->children.GetSize(); i++) {
@@ -150,7 +150,7 @@
     pLast = pNode;
     CFX_WideString name = CFX_WideString(pName, nLength);
     pNode = _Lookup(pLast, name);
-    if (pNode == NULL) {
+    if (!pNode) {
       pNode = AddChild(pLast, name, NULL);
     }
     name_extractor.GetNext(pName, nLength);
@@ -297,11 +297,11 @@
   } else {
     m = iCount;
   }
-  if (pResDict == NULL) {
+  if (!pResDict) {
     return csTmp;
   }
   CPDF_Dictionary* pDict = pResDict->GetDict(csType);
-  if (pDict == NULL) {
+  if (!pDict) {
     return csTmp;
   }
   int num = 0;
@@ -536,7 +536,7 @@
     FX_DWORD dwCount = m_pFieldTree->m_Root.CountFields();
     for (FX_DWORD m = 0; m < dwCount; m++) {
       CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(m);
-      if (pField == NULL) {
+      if (!pField) {
         continue;
       }
       if (pField == pExcludedField) {
@@ -580,15 +580,14 @@
 }
 FX_BOOL CPDF_InterForm::ValidateFieldName(const CPDF_FormField* pField,
                                           CFX_WideString& csNewFieldName) {
-  if (pField == NULL || csNewFieldName.IsEmpty()) {
-    return FALSE;
-  }
-  return ValidateFieldName(
-      csNewFieldName, ((CPDF_FormField*)pField)->GetFieldType(), pField, NULL);
+  return pField && !csNewFieldName.IsEmpty() &&
+         ValidateFieldName(csNewFieldName,
+                           ((CPDF_FormField*)pField)->GetFieldType(), pField,
+                           NULL);
 }
 FX_BOOL CPDF_InterForm::ValidateFieldName(const CPDF_FormControl* pControl,
                                           CFX_WideString& csNewFieldName) {
-  if (pControl == NULL || csNewFieldName.IsEmpty()) {
+  if (!pControl || csNewFieldName.IsEmpty()) {
     return FALSE;
   }
   CPDF_FormField* pField = ((CPDF_FormControl*)pControl)->GetField();
@@ -638,10 +637,7 @@
     return (FX_DWORD)m_pFieldTree->m_Root.CountFields();
   }
   CFieldTree::_Node* pNode = m_pFieldTree->FindNode(csFieldName);
-  if (pNode == NULL) {
-    return 0;
-  }
-  return pNode->CountFields();
+  return pNode ? pNode->CountFields() : 0;
 }
 CPDF_FormField* CPDF_InterForm::GetField(FX_DWORD index,
                                          const CFX_WideString& csFieldName) {
@@ -649,10 +645,7 @@
     return m_pFieldTree->m_Root.GetField(index);
   }
   CFieldTree::_Node* pNode = m_pFieldTree->FindNode(csFieldName);
-  if (pNode == NULL) {
-    return NULL;
-  }
-  return pNode->GetField(index);
+  return pNode ? pNode->GetField(index) : nullptr;
 }
 void CPDF_InterForm::GetAllFieldNames(CFX_WideStringArray& allFieldNames) {
   allFieldNames.RemoveAll();
@@ -668,7 +661,7 @@
 
 CPDF_FormField* CPDF_InterForm::GetFieldByDict(
     CPDF_Dictionary* pFieldDict) const {
-  if (pFieldDict == NULL) {
+  if (!pFieldDict) {
     return NULL;
   }
   CFX_WideString csWName = GetFullName(pFieldDict);
@@ -712,34 +705,28 @@
 }
 
 FX_BOOL CPDF_InterForm::NeedConstructAP() {
-  if (m_pFormDict == NULL) {
-    return FALSE;
-  }
-  return m_pFormDict->GetBoolean("NeedAppearances");
+  return m_pFormDict && m_pFormDict->GetBoolean("NeedAppearances");
 }
 void CPDF_InterForm::NeedConstructAP(FX_BOOL bNeedAP) {
-  if (m_pFormDict == NULL) {
+  if (!m_pFormDict) {
     InitInterFormDict(m_pFormDict, m_pDocument);
   }
   m_pFormDict->SetAtBoolean("NeedAppearances", bNeedAP);
   m_bGenerateAP = bNeedAP;
 }
 int CPDF_InterForm::CountFieldsInCalculationOrder() {
-  if (m_pFormDict == NULL) {
+  if (!m_pFormDict) {
     return 0;
   }
   CPDF_Array* pArray = m_pFormDict->GetArray("CO");
-  if (pArray == NULL) {
-    return 0;
-  }
-  return pArray->GetCount();
+  return pArray ? pArray->GetCount() : 0;
 }
 CPDF_FormField* CPDF_InterForm::GetFieldInCalculationOrder(int index) {
-  if (m_pFormDict == NULL || index < 0) {
+  if (!m_pFormDict || index < 0) {
     return NULL;
   }
   CPDF_Array* pArray = m_pFormDict->GetArray("CO");
-  if (pArray == NULL) {
+  if (!pArray) {
     return NULL;
   }
   if (CPDF_Dictionary* pElement =
@@ -749,11 +736,11 @@
   return NULL;
 }
 int CPDF_InterForm::FindFieldInCalculationOrder(const CPDF_FormField* pField) {
-  if (m_pFormDict == NULL || pField == NULL) {
+  if (!m_pFormDict || !pField) {
     return -1;
   }
   CPDF_Array* pArray = m_pFormDict->GetArray("CO");
-  if (pArray == NULL) {
+  if (!pArray) {
     return -1;
   }
   for (FX_DWORD i = 0; i < pArray->GetCount(); i++) {
@@ -819,7 +806,7 @@
 }
 CPDF_DefaultAppearance CPDF_InterForm::GetDefaultAppearance() {
   CFX_ByteString csDA;
-  if (m_pFormDict == NULL) {
+  if (!m_pFormDict) {
     return csDA;
   }
   csDA = m_pFormDict->GetString("DA");
@@ -829,10 +816,7 @@
   return GetDefaultInterFormFont(m_pFormDict, m_pDocument);
 }
 int CPDF_InterForm::GetFormAlignment() {
-  if (m_pFormDict == NULL) {
-    return 0;
-  }
-  return m_pFormDict->GetInteger("Q", 0);
+  return m_pFormDict ? m_pFormDict->GetInteger("Q", 0) : 0;
 }
 
 bool CPDF_InterForm::ResetForm(const std::vector<CPDF_FormField*>& fields,
@@ -877,7 +861,7 @@
   if (nLevel > nMaxRecursion) {
     return;
   }
-  if (pFieldDict == NULL) {
+  if (!pFieldDict) {
     return;
   }
   FX_DWORD dwParentObjNum = pFieldDict->GetObjNum();
@@ -887,7 +871,7 @@
     return;
   }
   CPDF_Dictionary* pFirstKid = pKids->GetDict(0);
-  if (pFirstKid == NULL) {
+  if (!pFirstKid) {
     return;
   }
   if (pFirstKid->KeyExist("T") || pFirstKid->KeyExist("Kids")) {
@@ -908,11 +892,11 @@
 }
 void CPDF_InterForm::FixPageFields(const CPDF_Page* pPage) {
   CPDF_Dictionary* pPageDict = pPage->m_pFormDict;
-  if (pPageDict == NULL) {
+  if (!pPageDict) {
     return;
   }
   CPDF_Array* pAnnots = pPageDict->GetArray("Annots");
-  if (pAnnots == NULL) {
+  if (!pAnnots) {
     return;
   }
   int iAnnotCount = pAnnots->GetCount();
@@ -934,7 +918,7 @@
   }
   CPDF_FormField* pField = NULL;
   pField = m_pFieldTree->GetField(csWName);
-  if (pField == NULL) {
+  if (!pField) {
     CPDF_Dictionary* pParent = pFieldDict;
     if (!pFieldDict->KeyExist("T") &&
         pFieldDict->GetString("Subtype") == "Widget") {
@@ -969,14 +953,14 @@
     m_pFieldTree->SetField(csWName, pField);
   }
   CPDF_Array* pKids = pFieldDict->GetArray("Kids");
-  if (pKids == NULL) {
+  if (!pKids) {
     if (pFieldDict->GetString("Subtype") == "Widget") {
       AddControl(pField, pFieldDict);
     }
   } else {
     for (FX_DWORD i = 0; i < pKids->GetCount(); i++) {
       CPDF_Dictionary* pKid = pKids->GetDict(i);
-      if (pKid == NULL) {
+      if (!pKid) {
         continue;
       }
       if (pKid->GetString("Subtype") != "Widget") {
@@ -1049,7 +1033,7 @@
     bool bIncludeOrExclude,
     bool bSimpleFileSpec) const {
   CFDF_Document* pDoc = CFDF_Document::CreateNewDoc();
-  if (pDoc == NULL) {
+  if (!pDoc) {
     return NULL;
   }
   CPDF_Dictionary* pMainDict = pDoc->GetRoot()->GetDict("FDF");
@@ -1065,14 +1049,14 @@
     }
   }
   CPDF_Array* pFields = CPDF_Array::Create();
-  if (pFields == NULL) {
+  if (!pFields) {
     return NULL;
   }
   pMainDict->SetAt("Fields", pFields);
   int nCount = m_pFieldTree->m_Root.CountFields();
   for (int i = 0; i < nCount; i++) {
     CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i);
-    if (pField == NULL || pField->GetType() == CPDF_FormField::PushButton) {
+    if (!pField || pField->GetType() == CPDF_FormField::PushButton) {
       continue;
     }
     FX_DWORD dwFlags = pField->GetFieldFlags();
@@ -1160,7 +1144,7 @@
   if (pKids) {
     for (FX_DWORD i = 0; i < pKids->GetCount(); i++) {
       CPDF_Dictionary* pKid = pKids->GetDict(i);
-      if (pKid == NULL) {
+      if (!pKid) {
         continue;
       }
       if (nLevel <= nMaxRecursion) {
@@ -1173,7 +1157,7 @@
     return;
   }
   CPDF_FormField* pField = m_pFieldTree->GetField(name);
-  if (pField == NULL) {
+  if (!pField) {
     return;
   }
   CFX_WideString csWValue;
@@ -1216,15 +1200,15 @@
 }
 FX_BOOL CPDF_InterForm::ImportFromFDF(const CFDF_Document* pFDF,
                                       FX_BOOL bNotify) {
-  if (pFDF == NULL) {
+  if (!pFDF) {
     return FALSE;
   }
   CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDict("FDF");
-  if (pMainDict == NULL) {
+  if (!pMainDict) {
     return FALSE;
   }
   CPDF_Array* pFields = pMainDict->GetArray("Fields");
-  if (pFields == NULL) {
+  if (!pFields) {
     return FALSE;
   }
   m_bsEncoding = pMainDict->GetString("Encoding");
@@ -1236,7 +1220,7 @@
   }
   for (FX_DWORD i = 0; i < pFields->GetCount(); i++) {
     CPDF_Dictionary* pField = pFields->GetDict(i);
-    if (pField == NULL) {
+    if (!pField) {
       continue;
     }
     FDF_ImportField(pField, L"", bNotify);
diff --git a/core/src/fpdfdoc/doc_formcontrol.cpp b/core/src/fpdfdoc/doc_formcontrol.cpp
index 0d2f990..fa0441c 100644
--- a/core/src/fpdfdoc/doc_formcontrol.cpp
+++ b/core/src/fpdfdoc/doc_formcontrol.cpp
@@ -20,11 +20,11 @@
          GetType() == CPDF_FormField::RadioButton);
   CFX_ByteString csOn;
   CPDF_Dictionary* pAP = m_pWidgetDict->GetDict("AP");
-  if (pAP == NULL) {
+  if (!pAP) {
     return csOn;
   }
   CPDF_Dictionary* pN = pAP->GetDict("N");
-  if (pN == NULL) {
+  if (!pN) {
     return csOn;
   }
   FX_POSITION pos = pN->GetStartPos();
@@ -51,14 +51,14 @@
     m_pWidgetDict->SetAtName("AS", csValue);
   }
   CPDF_Dictionary* pAP = m_pWidgetDict->GetDict("AP");
-  if (pAP == NULL) {
+  if (!pAP) {
     return;
   }
   FX_POSITION pos1 = pAP->GetStartPos();
   while (pos1) {
     CFX_ByteString csKey1;
     CPDF_Object* pObj1 = pAP->GetNextElement(pos1, csKey1);
-    if (pObj1 == NULL) {
+    if (!pObj1) {
       continue;
     }
     CPDF_Object* pObjDirect1 = pObj1->GetDirect();
@@ -70,7 +70,7 @@
     while (pos2) {
       CFX_ByteString csKey2;
       CPDF_Object* pObj2 = pSubDict->GetNextElement(pos2, csKey2);
-      if (pObj2 == NULL) {
+      if (!pObj2) {
         continue;
       }
       if (csKey2 != "Off") {
@@ -124,7 +124,7 @@
   ASSERT(GetType() == CPDF_FormField::CheckBox ||
          GetType() == CPDF_FormField::RadioButton);
   CPDF_Object* pDV = FPDF_GetFieldAttr(m_pField->m_pDict, "DV");
-  if (pDV == NULL) {
+  if (!pDV) {
     return FALSE;
   }
   CFX_ByteString csDV = pDV->GetString();
@@ -157,7 +157,7 @@
     return;
   }
   CPDF_Stream* pStream = FPDFDOC_GetAnnotAP(m_pWidgetDict, mode);
-  if (pStream == NULL) {
+  if (!pStream) {
     return;
   }
   CFX_FloatRect form_bbox = pStream->GetDict()->GetRect("BBox");
@@ -176,7 +176,7 @@
 }
 const FX_CHAR* g_sHighlightingMode[] = {"N", "I", "O", "P", "T", ""};
 CPDF_FormControl::HighlightingMode CPDF_FormControl::GetHighlightingMode() {
-  if (m_pWidgetDict == NULL) {
+  if (!m_pWidgetDict) {
     return Invert;
   }
   CFX_ByteString csH = m_pWidgetDict->GetString("H", "I");
@@ -317,10 +317,9 @@
     return m_pWidgetDict->GetInteger("Q", 0);
   }
   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pField->m_pDict, "Q");
-  if (pObj == NULL) {
-    return m_pField->m_pForm->GetFormAlignment();
-  }
-  return pObj->GetInteger();
+  if (pObj)
+    return pObj->GetInteger();
+  return m_pField->m_pForm->GetFormAlignment();
 }
 
 CPDF_ApSettings::CPDF_ApSettings(CPDF_Dictionary* pDict) : m_pDict(pDict) {}
@@ -386,11 +385,11 @@
   for (int i = 0; i < 4; i++) {
     fc[i] = 0;
   }
-  if (m_pDict == NULL) {
+  if (!m_pDict) {
     return;
   }
   CPDF_Array* pEntry = m_pDict->GetArray(csEntry);
-  if (pEntry == NULL) {
+  if (!pEntry) {
     return;
   }
   FX_DWORD dwCount = pEntry->GetCount();
diff --git a/core/src/fpdfdoc/doc_formfield.cpp b/core/src/fpdfdoc/doc_formfield.cpp
index 767b31b..987dbd6 100644
--- a/core/src/fpdfdoc/doc_formfield.cpp
+++ b/core/src/fpdfdoc/doc_formfield.cpp
@@ -184,12 +184,9 @@
           return FALSE;
         }
       }
-      if (pDV == NULL) {
-        m_pDict->RemoveAt("V");
-        m_pDict->RemoveAt("RV");
-      } else {
+      if (pDV) {
         CPDF_Object* pClone = pDV->Clone();
-        if (pClone == NULL) {
+        if (!pClone) {
           return FALSE;
         }
         m_pDict->SetAt("V", pClone);
@@ -197,6 +194,9 @@
           CPDF_Object* pCloneR = pDV->Clone();
           m_pDict->SetAt("RV", pCloneR);
         }
+      } else {
+        m_pDict->RemoveAt("V");
+        m_pDict->RemoveAt("RV");
       }
       if (bNotify && m_pForm->m_pFormNotify) {
         m_pForm->m_pFormNotify->AfterValueChange(this);
@@ -241,42 +241,42 @@
 }
 CPDF_AAction CPDF_FormField::GetAdditionalAction() {
   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "AA");
-  if (pObj == NULL) {
+  if (!pObj) {
     return NULL;
   }
   return pObj->GetDict();
 }
 CFX_WideString CPDF_FormField::GetAlternateName() {
   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TU");
-  if (pObj == NULL) {
+  if (!pObj) {
     return L"";
   }
   return pObj->GetUnicodeText();
 }
 CFX_WideString CPDF_FormField::GetMappingName() {
   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TM");
-  if (pObj == NULL) {
+  if (!pObj) {
     return L"";
   }
   return pObj->GetUnicodeText();
 }
 FX_DWORD CPDF_FormField::GetFieldFlags() {
   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "Ff");
-  if (pObj == NULL) {
+  if (!pObj) {
     return 0;
   }
   return pObj->GetInteger();
 }
 CFX_ByteString CPDF_FormField::GetDefaultStyle() {
   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "DS");
-  if (pObj == NULL) {
+  if (!pObj) {
     return "";
   }
   return pObj->GetString();
 }
 CFX_WideString CPDF_FormField::GetRichTextString() {
   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "RV");
-  if (pObj == NULL) {
+  if (!pObj) {
     return L"";
   }
   return pObj->GetUnicodeText();
@@ -286,16 +286,16 @@
     return GetCheckValue(bDefault);
   }
   CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, bDefault ? "DV" : "V");
-  if (pValue == NULL) {
+  if (!pValue) {
     if (!bDefault) {
       if (m_Type == RichText) {
         pValue = FPDF_GetFieldAttr(m_pDict, "V");
       }
-      if (pValue == NULL && m_Type != Text) {
+      if (!pValue && m_Type != Text) {
         pValue = FPDF_GetFieldAttr(m_pDict, "DV");
       }
     }
-    if (pValue == NULL) {
+    if (!pValue) {
       return CFX_WideString();
     }
   }
@@ -507,9 +507,9 @@
   }
   CFX_WideString opt_value = GetOptionValue(index);
   CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "V");
-  if (pValue == NULL) {
+  if (!pValue) {
     pValue = FPDF_GetFieldAttr(m_pDict, "I");
-    if (pValue == NULL) {
+    if (!pValue) {
       return FALSE;
     }
   }
@@ -599,7 +599,7 @@
         m_pDict->SetAtString("V", PDF_EncodeText(opt_value));
       } else {
         CPDF_Array* pArray = CPDF_Array::Create();
-        if (pArray == NULL) {
+        if (!pArray) {
           return FALSE;
         }
         FX_BOOL bSelected;
@@ -620,7 +620,7 @@
     } else if (m_Type == ComboBox) {
       m_pDict->SetAtString("V", PDF_EncodeText(opt_value));
       CPDF_Array* pI = CPDF_Array::Create();
-      if (pI == NULL) {
+      if (!pI) {
         return FALSE;
       }
       pI->AddInteger(index);
@@ -655,7 +655,7 @@
 int CPDF_FormField::GetDefaultSelectedItem() {
   ASSERT(GetType() == ComboBox || GetType() == ListBox);
   CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict, "DV");
-  if (pValue == NULL) {
+  if (!pValue) {
     return -1;
   }
   CFX_WideString csDV = pValue->GetUnicodeText();
@@ -738,7 +738,7 @@
                                      FX_BOOL bNotify) {
   ASSERT(GetType() == CheckBox || GetType() == RadioButton);
   CPDF_FormControl* pControl = GetControl(iControlIndex);
-  if (pControl == NULL) {
+  if (!pControl) {
     return FALSE;
   }
   if (!bChecked && pControl->IsChecked() == bChecked) {
@@ -850,29 +850,29 @@
 }
 int CPDF_FormField::GetTopVisibleIndex() {
   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TI");
-  if (pObj == NULL) {
+  if (!pObj) {
     return 0;
   }
   return pObj->GetInteger();
 }
 int CPDF_FormField::CountSelectedOptions() {
   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "I");
-  if (pObj == NULL) {
+  if (!pObj) {
     return 0;
   }
   CPDF_Array* pArray = pObj->GetArray();
-  if (pArray == NULL) {
+  if (!pArray) {
     return 0;
   }
   return (int)pArray->GetCount();
 }
 int CPDF_FormField::GetSelectedOptionIndex(int index) {
   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "I");
-  if (pObj == NULL) {
+  if (!pObj) {
     return -1;
   }
   CPDF_Array* pArray = pObj->GetArray();
-  if (pArray == NULL) {
+  if (!pArray) {
     return -1;
   }
   int iCount = (int)pArray->GetCount();
@@ -883,11 +883,11 @@
 }
 FX_BOOL CPDF_FormField::IsOptionSelected(int iOptIndex) {
   CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "I");
-  if (pObj == NULL) {
+  if (!pObj) {
     return FALSE;
   }
   CPDF_Array* pArray = pObj->GetArray();
-  if (pArray == NULL) {
+  if (!pArray) {
     return FALSE;
   }
   int iCount = (int)pArray->GetCount();
@@ -902,12 +902,12 @@
                                      FX_BOOL bSelected,
                                      FX_BOOL bNotify) {
   CPDF_Array* pArray = m_pDict->GetArray("I");
-  if (pArray == NULL) {
+  if (!pArray) {
     if (!bSelected) {
       return TRUE;
     }
     pArray = CPDF_Array::Create();
-    if (pArray == NULL) {
+    if (!pArray) {
       return FALSE;
     }
     m_pDict->SetAt("I", pArray);
@@ -953,7 +953,7 @@
         }
       }
       CPDF_Number* pNum = CPDF_Number::Create(iOptIndex);
-      if (pNum == NULL) {
+      if (!pNum) {
         return FALSE;
       }
       pArray->InsertAt(i, pNum);
@@ -1030,7 +1030,7 @@
     pFontDict = m_pForm->m_pFormDict->GetDict("DR")->GetDict("Font")->GetDict(
         font_name);
 
-  if (pFontDict == NULL) {
+  if (!pFontDict) {
     return;
   }
   m_pFont = m_pForm->m_pDocument->LoadFont(pFontDict);
diff --git a/core/src/fpdfdoc/doc_ocg.cpp b/core/src/fpdfdoc/doc_ocg.cpp
index cfca121..539c038 100644
--- a/core/src/fpdfdoc/doc_ocg.cpp
+++ b/core/src/fpdfdoc/doc_ocg.cpp
@@ -25,7 +25,7 @@
                                      const CFX_ByteStringC& csElement,
                                      const CFX_ByteStringC& csDef = "") {
   CPDF_Object* pIntent = pDict->GetElementValue("Intent");
-  if (pIntent == NULL) {
+  if (!pIntent) {
     return csElement == csDef;
   }
   CFX_ByteString bsIntent;
@@ -189,7 +189,7 @@
   if (nLevel > 32) {
     return FALSE;
   }
-  if (pExpression == NULL) {
+  if (!pExpression) {
     return FALSE;
   }
   int32_t iCount = pExpression->GetCount();
@@ -209,7 +209,7 @@
     FX_BOOL bValue = FALSE;
     for (int32_t i = 1; i < iCount; i++) {
       pOCGObj = pExpression->GetElementValue(1);
-      if (pOCGObj == NULL) {
+      if (!pOCGObj) {
         continue;
       }
       FX_BOOL bItem = FALSE;
diff --git a/core/src/fpdfdoc/doc_tagged.cpp b/core/src/fpdfdoc/doc_tagged.cpp
index 7869834..d51743b 100644
--- a/core/src/fpdfdoc/doc_tagged.cpp
+++ b/core/src/fpdfdoc/doc_tagged.cpp
@@ -35,7 +35,7 @@
 CPDF_StructTreeImpl::CPDF_StructTreeImpl(const CPDF_Document* pDoc) {
   CPDF_Dictionary* pCatalog = pDoc->GetRoot();
   m_pTreeRoot = pCatalog->GetDict("StructTreeRoot");
-  if (m_pTreeRoot == NULL) {
+  if (!m_pTreeRoot) {
     return;
   }
   m_pRoleMap = m_pTreeRoot->GetDict("RoleMap");
@@ -95,7 +95,7 @@
   }
   CFX_MapPtrToPtr element_map;
   CPDF_Dictionary* pParentTree = m_pTreeRoot->GetDict("ParentTree");
-  if (pParentTree == NULL) {
+  if (!pParentTree) {
     return;
   }
   CPDF_NumberTree parent_tree(pParentTree);
@@ -107,7 +107,7 @@
 
     for (i = 0; i < pParentArray->GetCount(); i++) {
       CPDF_Dictionary* pParent = pParentArray->GetDict(i);
-      if (pParent == NULL) {
+      if (!pParent) {
         continue;
       }
       AddPageNode(pParent, element_map);
@@ -127,7 +127,7 @@
   pElement = new CPDF_StructElementImpl(this, NULL, pDict);
   map.SetAt(pDict, pElement);
   CPDF_Dictionary* pParent = pDict->GetDict("P");
-  if (pParent == NULL || pParent->GetString("Type") == "StructTreeRoot") {
+  if (!pParent || pParent->GetString("Type") == "StructTreeRoot") {
     if (!AddTopLevelNode(pDict, pElement)) {
       pElement->Release();
       map.RemoveKey(pDict);
@@ -294,7 +294,7 @@
   } else {
     pKid->m_Type = CPDF_StructKid::Element;
     pKid->m_Element.m_pDict = pKidDict;
-    if (m_pTree->m_pPage == NULL) {
+    if (!m_pTree->m_pPage) {
       pKid->m_Element.m_pElement =
           new CPDF_StructElementImpl(m_pTree, this, pKidDict);
     } else {
@@ -339,7 +339,7 @@
     if (pAttr) {
       return pAttr;
     }
-    if (m_pParent == NULL) {
+    if (!m_pParent) {
       return NULL;
     }
     return m_pParent->GetAttr(owner, name, TRUE, fLevel + 1);
diff --git a/core/src/fpdfdoc/doc_utils.cpp b/core/src/fpdfdoc/doc_utils.cpp
index f26355f..b0705ea 100644
--- a/core/src/fpdfdoc/doc_utils.cpp
+++ b/core/src/fpdfdoc/doc_utils.cpp
@@ -224,14 +224,11 @@
   return tm;
 }
 void InitInterFormDict(CPDF_Dictionary*& pFormDict, CPDF_Document* pDocument) {
-  if (pDocument == NULL) {
+  if (!pDocument) {
     return;
   }
-  if (pFormDict == NULL) {
+  if (!pFormDict) {
     pFormDict = CPDF_Dictionary::Create();
-    if (pFormDict == NULL) {
-      return;
-    }
     FX_DWORD dwObjNum = pDocument->AddIndirectObject(pFormDict);
     CPDF_Dictionary* pRoot = pDocument->GetRoot();
     pRoot->SetAtReference("AcroForm", pDocument, dwObjNum);
@@ -248,7 +245,7 @@
     }
     if (charSet != 0) {
       CFX_ByteString csFontName = CPDF_InterForm::GetNativeFont(charSet, NULL);
-      if (pFont == NULL || csFontName != "Helvetica") {
+      if (!pFont || csFontName != "Helvetica") {
         pFont = CPDF_InterForm::AddNativeFont(pDocument);
         if (pFont) {
           csBaseName = "";
@@ -270,15 +267,15 @@
   }
 }
 FX_DWORD CountInterFormFonts(CPDF_Dictionary* pFormDict) {
-  if (pFormDict == NULL) {
+  if (!pFormDict) {
     return 0;
   }
   CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
-  if (pDR == NULL) {
+  if (!pDR) {
     return 0;
   }
   CPDF_Dictionary* pFonts = pDR->GetDict("Font");
-  if (pFonts == NULL) {
+  if (!pFonts) {
     return 0;
   }
   FX_DWORD dwCount = 0;
@@ -287,7 +284,7 @@
     CPDF_Object* pObj = NULL;
     CFX_ByteString csKey;
     pObj = pFonts->GetNextElement(pos, csKey);
-    if (pObj == NULL) {
+    if (!pObj) {
       continue;
     }
     if (CPDF_Dictionary* pDirect = ToDictionary(pObj->GetDirect())) {
@@ -302,15 +299,15 @@
                             CPDF_Document* pDocument,
                             FX_DWORD index,
                             CFX_ByteString& csNameTag) {
-  if (pFormDict == NULL) {
+  if (!pFormDict) {
     return NULL;
   }
   CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
-  if (pDR == NULL) {
+  if (!pDR) {
     return NULL;
   }
   CPDF_Dictionary* pFonts = pDR->GetDict("Font");
-  if (pFonts == NULL) {
+  if (!pFonts) {
     return NULL;
   }
   FX_DWORD dwCount = 0;
@@ -319,7 +316,7 @@
     CPDF_Object* pObj = NULL;
     CFX_ByteString csKey;
     pObj = pFonts->GetNextElement(pos, csKey);
-    if (pObj == NULL) {
+    if (!pObj) {
       continue;
     }
     CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
@@ -339,19 +336,19 @@
                             CPDF_Document* pDocument,
                             CFX_ByteString csNameTag) {
   CFX_ByteString csAlias = PDF_NameDecode(csNameTag);
-  if (pFormDict == NULL || csAlias.IsEmpty()) {
+  if (!pFormDict || csAlias.IsEmpty()) {
     return NULL;
   }
   CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
-  if (pDR == NULL) {
+  if (!pDR) {
     return NULL;
   }
   CPDF_Dictionary* pFonts = pDR->GetDict("Font");
-  if (pFonts == NULL) {
+  if (!pFonts) {
     return NULL;
   }
   CPDF_Dictionary* pElement = pFonts->GetDict(csAlias);
-  if (pElement == NULL) {
+  if (!pElement) {
     return NULL;
   }
   if (pElement->GetString("Type") == "Font") {
@@ -363,15 +360,15 @@
                             CPDF_Document* pDocument,
                             CFX_ByteString csFontName,
                             CFX_ByteString& csNameTag) {
-  if (pFormDict == NULL || csFontName.IsEmpty()) {
+  if (!pFormDict || csFontName.IsEmpty()) {
     return NULL;
   }
   CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
-  if (pDR == NULL) {
+  if (!pDR) {
     return NULL;
   }
   CPDF_Dictionary* pFonts = pDR->GetDict("Font");
-  if (pFonts == NULL) {
+  if (!pFonts) {
     return NULL;
   }
   FX_POSITION pos = pFonts->GetStartPos();
@@ -379,7 +376,7 @@
     CPDF_Object* pObj = NULL;
     CFX_ByteString csKey;
     pObj = pFonts->GetNextElement(pos, csKey);
-    if (pObj == NULL) {
+    if (!pObj) {
       continue;
     }
     CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
@@ -406,15 +403,15 @@
                                   CPDF_Document* pDocument,
                                   uint8_t charSet,
                                   CFX_ByteString& csNameTag) {
-  if (pFormDict == NULL) {
+  if (!pFormDict) {
     return NULL;
   }
   CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
-  if (pDR == NULL) {
+  if (!pDR) {
     return NULL;
   }
   CPDF_Dictionary* pFonts = pDR->GetDict("Font");
-  if (pFonts == NULL) {
+  if (!pFonts) {
     return NULL;
   }
   FX_POSITION pos = pFonts->GetStartPos();
@@ -422,7 +419,7 @@
     CPDF_Object* pObj = NULL;
     CFX_ByteString csKey;
     pObj = pFonts->GetNextElement(pos, csKey);
-    if (pObj == NULL) {
+    if (!pObj) {
       continue;
     }
     CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
@@ -431,11 +428,11 @@
     if (pElement->GetString("Type") != "Font")
       continue;
     CPDF_Font* pFind = pDocument->LoadFont(pElement);
-    if (pFind == NULL) {
+    if (!pFind) {
       continue;
     }
     CFX_SubstFont* pSubst = (CFX_SubstFont*)pFind->GetSubstFont();
-    if (pSubst == NULL) {
+    if (!pSubst) {
       continue;
     }
     if (pSubst->m_Charset == (int)charSet) {
@@ -464,15 +461,15 @@
 FX_BOOL FindInterFormFont(CPDF_Dictionary* pFormDict,
                           const CPDF_Font* pFont,
                           CFX_ByteString& csNameTag) {
-  if (pFormDict == NULL || pFont == NULL) {
+  if (!pFormDict || !pFont) {
     return FALSE;
   }
   CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
-  if (pDR == NULL) {
+  if (!pDR) {
     return FALSE;
   }
   CPDF_Dictionary* pFonts = pDR->GetDict("Font");
-  if (pFonts == NULL) {
+  if (!pFonts) {
     return FALSE;
   }
   FX_POSITION pos = pFonts->GetStartPos();
@@ -480,7 +477,7 @@
     CPDF_Object* pObj = NULL;
     CFX_ByteString csKey;
     pObj = pFonts->GetNextElement(pos, csKey);
-    if (pObj == NULL) {
+    if (!pObj) {
       continue;
     }
     CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
@@ -501,15 +498,15 @@
                           CFX_ByteString csFontName,
                           CPDF_Font*& pFont,
                           CFX_ByteString& csNameTag) {
-  if (pFormDict == NULL) {
+  if (!pFormDict) {
     return FALSE;
   }
   CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
-  if (pDR == NULL) {
+  if (!pDR) {
     return FALSE;
   }
   CPDF_Dictionary* pFonts = pDR->GetDict("Font");
-  if (pFonts == NULL) {
+  if (!pFonts) {
     return FALSE;
   }
   if (csFontName.GetLength() > 0) {
@@ -520,7 +517,7 @@
     CPDF_Object* pObj = NULL;
     CFX_ByteString csKey, csTmp;
     pObj = pFonts->GetNextElement(pos, csKey);
-    if (pObj == NULL) {
+    if (!pObj) {
       continue;
     }
     CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
@@ -530,7 +527,7 @@
       continue;
     }
     pFont = pDocument->LoadFont(pElement);
-    if (pFont == NULL) {
+    if (!pFont) {
       continue;
     }
     CFX_ByteString csBaseFont;
@@ -547,10 +544,10 @@
                       CPDF_Document* pDocument,
                       const CPDF_Font* pFont,
                       CFX_ByteString& csNameTag) {
-  if (pFont == NULL) {
+  if (!pFont) {
     return;
   }
-  if (pFormDict == NULL) {
+  if (!pFormDict) {
     InitInterFormDict(pFormDict, pDocument);
   }
   CFX_ByteString csTag;
@@ -558,19 +555,16 @@
     csNameTag = csTag;
     return;
   }
-  if (pFormDict == NULL) {
+  if (!pFormDict) {
     InitInterFormDict(pFormDict, pDocument);
   }
   CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
-  if (pDR == NULL) {
+  if (!pDR) {
     pDR = CPDF_Dictionary::Create();
-    if (pDR == NULL) {
-      return;
-    }
     pFormDict->SetAt("DR", pDR);
   }
   CPDF_Dictionary* pFonts = pDR->GetDict("Font");
-  if (pFonts == NULL) {
+  if (!pFonts) {
     pFonts = CPDF_Dictionary::Create();
     pDR->SetAt("Font", pFonts);
   }
@@ -586,7 +580,7 @@
                                   CPDF_Document* pDocument,
                                   uint8_t charSet,
                                   CFX_ByteString& csNameTag) {
-  if (pFormDict == NULL) {
+  if (!pFormDict) {
     InitInterFormDict(pFormDict, pDocument);
   }
   CFX_ByteString csTemp;
@@ -615,7 +609,7 @@
   return AddNativeInterFormFont(pFormDict, pDocument, charSet, csNameTag);
 }
 void RemoveInterFormFont(CPDF_Dictionary* pFormDict, const CPDF_Font* pFont) {
-  if (pFormDict == NULL || pFont == NULL) {
+  if (!pFormDict || !pFont) {
     return;
   }
   CFX_ByteString csTag;
@@ -627,22 +621,22 @@
   pFonts->RemoveAt(csTag);
 }
 void RemoveInterFormFont(CPDF_Dictionary* pFormDict, CFX_ByteString csNameTag) {
-  if (pFormDict == NULL || csNameTag.IsEmpty()) {
+  if (!pFormDict || csNameTag.IsEmpty()) {
     return;
   }
   CPDF_Dictionary* pDR = pFormDict->GetDict("DR");
-  if (pDR == NULL) {
+  if (!pDR) {
     return;
   }
   CPDF_Dictionary* pFonts = pDR->GetDict("Font");
-  if (pFonts == NULL) {
+  if (!pFonts) {
     return;
   }
   pFonts->RemoveAt(csNameTag);
 }
 CPDF_Font* GetDefaultInterFormFont(CPDF_Dictionary* pFormDict,
                                    CPDF_Document* pDocument) {
-  if (pFormDict == NULL) {
+  if (!pFormDict) {
     return NULL;
   }
   CPDF_DefaultAppearance cDA = pFormDict->GetString("DA");
@@ -668,14 +662,14 @@
   return Always;
 }
 FX_BOOL CPDF_IconFit::IsProportionalScale() {
-  if (m_pDict == NULL) {
+  if (!m_pDict) {
     return TRUE;
   }
   return m_pDict->GetString("S", "P") != "A";
 }
 void CPDF_IconFit::GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom) {
   fLeft = fBottom = 0.5;
-  if (m_pDict == NULL) {
+  if (!m_pDict) {
     return;
   }
   CPDF_Array* pA = m_pDict->GetArray("A");
@@ -690,7 +684,7 @@
   }
 }
 FX_BOOL CPDF_IconFit::GetFittingBounds() {
-  if (m_pDict == NULL) {
+  if (!m_pDict) {
     return FALSE;
   }
   return m_pDict->GetBoolean("FB");
@@ -700,7 +694,7 @@
   int iCount = pField->CountControls();
   for (int i = 0; i < iCount; i++) {
     CPDF_FormControl* pControl = pField->GetControl(i);
-    if (pControl == NULL) {
+    if (!pControl) {
       continue;
     }
     statusArray.Add(pControl->IsChecked() ? 1 : 0);
@@ -712,7 +706,7 @@
   if (nLevel > FPDFDOC_UTILS_MAXRECURSION) {
     return NULL;
   }
-  if (pFieldDict == NULL) {
+  if (!pFieldDict) {
     return NULL;
   }
   CPDF_Object* pAttr = pFieldDict->GetElementValue(name);
@@ -720,7 +714,7 @@
     return pAttr;
   }
   CPDF_Dictionary* pParent = pFieldDict->GetDict("Parent");
-  if (pParent == NULL) {
+  if (!pParent) {
     return NULL;
   }
   return FPDF_GetFieldAttr(pParent, name, nLevel + 1);
diff --git a/core/src/fpdftext/fpdf_text.cpp b/core/src/fpdftext/fpdf_text.cpp
index 9a967e6..1e56bf9 100644
--- a/core/src/fpdftext/fpdf_text.cpp
+++ b/core/src/fpdftext/fpdf_text.cpp
@@ -168,7 +168,7 @@
   if (str.GetLength() == 0) {
     return NULL;
   }
-  if (pBaseLine == NULL) {
+  if (!pBaseLine) {
     int i;
     for (i = 0; i < m_BaseLines.GetSize(); i++) {
       CTextBaseLine* pExistLine = m_BaseLines.GetAt(i);
@@ -180,7 +180,7 @@
         break;
       }
     }
-    if (pBaseLine == NULL) {
+    if (!pBaseLine) {
       pBaseLine = new CTextBaseLine;
       pBaseLine->m_BaseLine = basey;
       m_BaseLines.InsertAt(i, pBaseLine);
@@ -448,17 +448,17 @@
     for (int j = 0; j < pBaseLine->m_TextList.GetSize(); j++) {
       CTextBox* pTextBox = pBaseLine->m_TextList.GetAt(j);
       CTextColumn* pColumn = FindColumn(pTextBox->m_Right);
-      if (pColumn == NULL) {
+      if (pColumn) {
+        pColumn->m_AvgPos =
+            (pColumn->m_Count * pColumn->m_AvgPos + pTextBox->m_Right) /
+            (pColumn->m_Count + 1);
+        pColumn->m_Count++;
+      } else {
         pColumn = new CTextColumn;
         pColumn->m_Count = 1;
         pColumn->m_AvgPos = pTextBox->m_Right;
         pColumn->m_TextPos = -1;
         m_TextColumns.Add(pColumn);
-      } else {
-        pColumn->m_AvgPos =
-            (pColumn->m_Count * pColumn->m_AvgPos + pTextBox->m_Right) /
-            (pColumn->m_Count + 1);
-        pColumn->m_Count++;
       }
     }
   }
@@ -726,7 +726,7 @@
                              int iMinWidth,
                              FX_DWORD flags) {
   lines.RemoveAll();
-  if (pPage == NULL) {
+  if (!pPage) {
     return;
   }
   CPDF_Page page;
diff --git a/core/src/fpdftext/fpdf_text_int.cpp b/core/src/fpdftext/fpdf_text_int.cpp
index 8a359fe..1e6d54d 100644
--- a/core/src/fpdftext/fpdf_text_int.cpp
+++ b/core/src/fpdftext/fpdf_text_int.cpp
@@ -2464,12 +2464,12 @@
                                             const FX_WCHAR* lpszFullString,
                                             int iSubString,
                                             FX_WCHAR chSep) {
-  if (lpszFullString == NULL) {
+  if (!lpszFullString) {
     return FALSE;
   }
   while (iSubString--) {
     lpszFullString = FXSYS_wcschr(lpszFullString, chSep);
-    if (lpszFullString == NULL) {
+    if (!lpszFullString) {
       rString.Empty();
       return FALSE;
     }
@@ -2479,8 +2479,8 @@
     }
   }
   const FX_WCHAR* lpchEnd = FXSYS_wcschr(lpszFullString, chSep);
-  int nLen = (lpchEnd == NULL) ? (int)FXSYS_wcslen(lpszFullString)
-                               : (int)(lpchEnd - lpszFullString);
+  int nLen = lpchEnd ? (int)(lpchEnd - lpszFullString)
+                     : (int)FXSYS_wcslen(lpszFullString);
   ASSERT(nLen >= 0);
   FXSYS_memcpy(rString.GetBuffer(nLen), lpszFullString,
                nLen * sizeof(FX_WCHAR));
diff --git a/core/src/fpdftext/fpdf_text_search.cpp b/core/src/fpdftext/fpdf_text_search.cpp
index 43486c7..80bf5ec 100644
--- a/core/src/fpdftext/fpdf_text_search.cpp
+++ b/core/src/fpdftext/fpdf_text_search.cpp
@@ -303,13 +303,8 @@
   FX_POSITION pos = pPage->GetFirstObjectPosition();
   while (pos) {
     CPDF_PageObject* pObject = pPage->GetNextObject(pos);
-    if (pObject == NULL) {
-      continue;
-    }
-    if (pObject->m_Type != PDFPAGE_TEXT) {
-      continue;
-    }
-    textstream.ProcessObject((CPDF_TextObject*)pObject, FALSE);
+    if (pObject && pObject->m_Type == PDFPAGE_TEXT)
+      textstream.ProcessObject((CPDF_TextObject*)pObject, FALSE);
   }
 }
 CFX_WideString PDF_GetFirstTextLine_Unicode(CPDF_Document* pDoc,
diff --git a/core/src/fxcodec/codec/fx_codec.cpp b/core/src/fxcodec/codec/fx_codec.cpp
index ad6fc95..6998114 100644
--- a/core/src/fxcodec/codec/fx_codec.cpp
+++ b/core/src/fxcodec/codec/fx_codec.cpp
@@ -168,7 +168,7 @@
   const char* exp_ptr = NULL;
   int e_number = 0, e_signal = 0, e_point = 0, is_negative = 0;
   int exp_ret = 0, exp_sig = 1, fra_ret = 0, fra_count = 0, fra_base = 1;
-  if (nptr == NULL) {
+  if (!nptr) {
     return 0.0;
   }
   for (;; ptr++) {
diff --git a/core/src/fxcodec/codec/fx_codec_flate.cpp b/core/src/fxcodec/codec/fx_codec_flate.cpp
index f995958..b293781 100644
--- a/core/src/fxcodec/codec/fx_codec_flate.cpp
+++ b/core/src/fxcodec/codec/fx_codec_flate.cpp
@@ -34,7 +34,7 @@
 void* FPDFAPI_FlateInit(void* (*alloc_func)(void*, unsigned int, unsigned int),
                         void (*free_func)(void*, void*)) {
   z_stream* p = (z_stream*)alloc_func(0, 1, sizeof(z_stream));
-  if (p == NULL) {
+  if (!p) {
     return NULL;
   }
   FXSYS_memset(p, 0, sizeof(z_stream));
@@ -835,7 +835,7 @@
     FPDFAPI_FlateEnd(m_pFlate);
   }
   m_pFlate = FPDFAPI_FlateInit(my_alloc_func, my_free_func);
-  if (m_pFlate == NULL) {
+  if (!m_pFlate) {
     return FALSE;
   }
   FPDFAPI_FlateInput(m_pFlate, m_SrcBuf, m_SrcSize);
diff --git a/core/src/fxcodec/codec/fx_codec_icc.cpp b/core/src/fxcodec/codec/fx_codec_icc.cpp
index 8628720..7ae59a6 100644
--- a/core/src/fxcodec/codec/fx_codec_icc.cpp
+++ b/core/src/fxcodec/codec/fx_codec_icc.cpp
@@ -102,16 +102,16 @@
   CLcmsCmm* pCmm = NULL;
   nSrcComponents = 0;
   srcProfile = cmsOpenProfileFromMem((void*)pSrcProfileData, dwSrcProfileSize);
-  if (srcProfile == NULL) {
+  if (!srcProfile) {
     return NULL;
   }
-  if (pDstProfileData == NULL && dwDstProfileSize == 0 && nDstComponents == 3) {
+  if (!pDstProfileData && dwDstProfileSize == 0 && nDstComponents == 3) {
     dstProfile = cmsCreate_sRGBProfile();
   } else {
     dstProfile =
         cmsOpenProfileFromMem((void*)pDstProfileData, dwDstProfileSize);
   }
-  if (dstProfile == NULL) {
+  if (!dstProfile) {
     cmsCloseProfile(srcProfile);
     return NULL;
   }
@@ -153,7 +153,7 @@
     default:
       break;
   }
-  if (hTransform == NULL) {
+  if (!hTransform) {
     cmsCloseProfile(srcProfile);
     cmsCloseProfile(dstProfile);
     return NULL;
@@ -176,7 +176,7 @@
                                 0, 3, intent, dwSrcFormat);
 }
 void IccLib_DestroyTransform(void* pTransform) {
-  if (pTransform == NULL) {
+  if (!pTransform) {
     return;
   }
   cmsDeleteTransform(((CLcmsCmm*)pTransform)->m_hTransform);
@@ -186,7 +186,7 @@
                       FX_DWORD nSrcComponents,
                       FX_FLOAT* pSrcValues,
                       FX_FLOAT* pDestValues) {
-  if (pTransform == NULL) {
+  if (!pTransform) {
     return;
   }
   CLcmsCmm* p = (CLcmsCmm*)pTransform;
@@ -242,7 +242,7 @@
     return NULL;
   }
   cmsToneCurve* curve = cmsBuildGamma(NULL, gamma);
-  if (curve == NULL) {
+  if (!curve) {
     return NULL;
   }
   void* profile = cmsCreateGrayProfile(D50, curve);
@@ -250,7 +250,7 @@
   return profile;
 }
 ICodec_IccModule::IccCS GetProfileCSFromHandle(void* pProfile) {
-  if (pProfile == NULL) {
+  if (!pProfile) {
     return ICodec_IccModule::IccCS_Unknown;
   }
   switch (cmsGetColorSpace(pProfile)) {
@@ -286,7 +286,7 @@
   ICodec_IccModule::IccCS cs;
   cmsHPROFILE hProfile =
       cmsOpenProfileFromMem((void*)pProfileData, dwProfileSize);
-  if (hProfile == NULL) {
+  if (!hProfile) {
     return IccCS_Unknown;
   }
   cs = GetProfileCSFromHandle(hProfile);
@@ -296,7 +296,7 @@
   return cs;
 }
 ICodec_IccModule::IccCS CCodec_IccModule::GetProfileCS(IFX_FileRead* pFile) {
-  if (pFile == NULL) {
+  if (!pFile) {
     return IccCS_Unknown;
   }
   ICodec_IccModule::IccCS cs;
@@ -476,11 +476,11 @@
   ASSERT(pInputParam && pOutputParam);
   CFX_ByteStringKey key;
   void* pInputProfile = CreateProfile(pInputParam, Icc_CLASS_INPUT, &key);
-  if (pInputProfile == NULL) {
+  if (!pInputProfile) {
     return NULL;
   }
   void* pOutputProfile = CreateProfile(pOutputParam, Icc_CLASS_OUTPUT, &key);
-  if (pOutputProfile == NULL) {
+  if (!pOutputProfile) {
     return NULL;
   }
   FX_DWORD dwInputProfileType =
diff --git a/core/src/fxcodec/codec/fx_codec_jpeg.cpp b/core/src/fxcodec/codec/fx_codec_jpeg.cpp
index 7308723..043964f 100644
--- a/core/src/fxcodec/codec/fx_codec_jpeg.cpp
+++ b/core/src/fxcodec/codec/fx_codec_jpeg.cpp
@@ -82,7 +82,7 @@
 static FX_BOOL _JpegEmbedIccProfile(j_compress_ptr cinfo,
                                     const uint8_t* icc_buf_ptr,
                                     FX_DWORD icc_length) {
-  if (icc_buf_ptr == NULL || icc_length == 0) {
+  if (!icc_buf_ptr || icc_length == 0) {
     return FALSE;
   }
   FX_DWORD icc_segment_size = (JPEG_MARKER_MAXSIZE - 2 - JPEG_OVERHEAD_LEN);
@@ -501,7 +501,7 @@
     int height,
     int nComps,
     FX_BOOL ColorTransform) {
-  if (src_buf == NULL || src_size == 0) {
+  if (!src_buf || src_size == 0) {
     return NULL;
   }
   CCodec_JpegDecoder* pDecoder = new CCodec_JpegDecoder;
@@ -531,10 +531,9 @@
                                   int quality,
                                   const uint8_t* icc_buf,
                                   FX_DWORD icc_length) {
-  if (pSource->GetBPP() < 8 || pSource->GetPalette()) {
-    ASSERT(pSource->GetBPP() >= 8 && pSource->GetPalette() == NULL);
+  if (pSource->GetBPP() < 8 || pSource->GetPalette())
     return FALSE;
-  }
+
   _JpegEncode(pSource, dest_buf, dest_size, quality, icc_buf, icc_length);
   return TRUE;
 }
diff --git a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
index cf017ca..21c1e44 100644
--- a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
+++ b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
@@ -438,7 +438,7 @@
   int max;
   cmsHPROFILE in_prof =
       cmsOpenProfileFromMem(image->icc_profile_buf, image->icc_profile_len);
-  if (in_prof == NULL) {
+  if (!in_prof) {
     return;
   }
   cmsColorSpaceSignature out_space = cmsGetColorSpace(in_prof);
@@ -479,7 +479,7 @@
       cmsCreateTransform(in_prof, in_type, out_prof, out_type, intent, 0);
   cmsCloseProfile(in_prof);
   cmsCloseProfile(out_prof);
-  if (transform == NULL) {
+  if (!transform) {
     image->color_space = oldspace;
     return;
   }
@@ -597,7 +597,7 @@
                                    INTENT_PERCEPTUAL, 0);
     cmsCloseProfile(in);
     cmsCloseProfile(out);
-    if (transform == NULL) {
+    if (!transform) {
       return;
     }
     prec0 = (double)image->comps[0].prec;
@@ -708,7 +708,7 @@
   DecodeData srcData(const_cast<unsigned char*>(src_data), src_size);
   l_stream = fx_opj_stream_create_memory_stream(&srcData,
                                                 OPJ_J2K_STREAM_CHUNK_SIZE, 1);
-  if (l_stream == NULL) {
+  if (!l_stream) {
     return FALSE;
   }
   opj_dparameters_t parameters;
diff --git a/core/src/fxcrt/fx_basic_array.cpp b/core/src/fxcrt/fx_basic_array.cpp
index ccb80eb..9c4aa0f 100644
--- a/core/src/fxcrt/fx_basic_array.cpp
+++ b/core/src/fxcrt/fx_basic_array.cpp
@@ -26,7 +26,7 @@
     return 0 == nNewSize;
   }
 
-  if (m_pData == NULL) {
+  if (!m_pData) {
     pdfium::base::CheckedNumeric<int> totalSize = nNewSize;
     totalSize *= m_nUnitSize;
     if (!totalSize.IsValid()) {
@@ -49,7 +49,7 @@
       return FALSE;
     }
     uint8_t* pNewData = FX_Realloc(uint8_t, m_pData, totalSize.ValueOrDie());
-    if (pNewData == NULL) {
+    if (!pNewData) {
       return FALSE;
     }
     FXSYS_memset(pNewData + m_nSize * m_nUnitSize, 0,
@@ -115,7 +115,7 @@
 }
 FX_BOOL CFX_BasicArray::InsertAt(int nStartIndex,
                                  const CFX_BasicArray* pNewArray) {
-  if (pNewArray == NULL) {
+  if (!pNewArray) {
     return FALSE;
   }
   if (pNewArray->m_nSize == 0) {
@@ -129,7 +129,7 @@
   return TRUE;
 }
 const void* CFX_BasicArray::GetDataPtr(int index) const {
-  if (index < 0 || index >= m_nSize || m_pData == NULL) {
+  if (index < 0 || index >= m_nSize || !m_pData) {
     return NULL;
   }
   return m_pData + index * m_nUnitSize;
@@ -159,16 +159,14 @@
     FX_Free(pIndex);
     return;
   }
-  for (int i = 0; i < size; i++) {
-    if (pIndex[i] == NULL) {
-      continue;
-    }
-    _ClearIndex(level - 1, size, (void**)pIndex[i]);
+  for (int i = 0; i < size; ++i) {
+    if (pIndex[i])
+      _ClearIndex(level - 1, size, (void**)pIndex[i]);
   }
   FX_Free(pIndex);
 }
 void CFX_BaseSegmentedArray::RemoveAll() {
-  if (m_pIndex == NULL) {
+  if (!m_pIndex) {
     return;
   }
   _ClearIndex(m_IndexDepth, m_IndexSize, (void**)m_pIndex);
@@ -181,7 +179,7 @@
     return GetAt(m_DataSize++);
   }
   void* pSegment = FX_Alloc2D(uint8_t, m_UnitSize, m_SegmentSize);
-  if (m_pIndex == NULL) {
+  if (!m_pIndex) {
     m_pIndex = pSegment;
     m_DataSize++;
     return pSegment;
@@ -217,7 +215,7 @@
   }
   void** pSpot = (void**)m_pIndex;
   for (i = 1; i < m_IndexDepth; i++) {
-    if (pSpot[seg_index / tree_size] == NULL) {
+    if (!pSpot[seg_index / tree_size]) {
       pSpot[seg_index / tree_size] = FX_Alloc(void*, m_IndexSize);
     }
     pSpot = (void**)pSpot[seg_index / tree_size];
@@ -281,7 +279,7 @@
     return IterateSegment((const uint8_t*)pIndex, count, callback, param);
   }
   for (int i = 0; i < m_IndexSize; i++) {
-    if (pIndex[i] == NULL) {
+    if (!pIndex[i]) {
       continue;
     }
     void* p =
@@ -295,7 +293,7 @@
 void* CFX_BaseSegmentedArray::Iterate(FX_BOOL (*callback)(void* param,
                                                           void* pData),
                                       void* param) const {
-  if (m_pIndex == NULL) {
+  if (!m_pIndex) {
     return NULL;
   }
   int start = 0;
diff --git a/core/src/fxcrt/fx_basic_bstring.cpp b/core/src/fxcrt/fx_basic_bstring.cpp
index cd47702..e0d1146 100644
--- a/core/src/fxcrt/fx_basic_bstring.cpp
+++ b/core/src/fxcrt/fx_basic_bstring.cpp
@@ -108,7 +108,7 @@
   }
 }
 CFX_ByteString::CFX_ByteString(const CFX_ByteString& stringSrc) {
-  if (stringSrc.m_pData == NULL) {
+  if (!stringSrc.m_pData) {
     m_pData = NULL;
     return;
   }
@@ -143,7 +143,7 @@
   }
 }
 const CFX_ByteString& CFX_ByteString::operator=(const FX_CHAR* lpsz) {
-  if (lpsz == NULL || lpsz[0] == 0) {
+  if (!lpsz || lpsz[0] == 0) {
     Empty();
   } else {
     AssignCopy(FXSYS_strlen(lpsz), lpsz);
@@ -203,7 +203,7 @@
   return *this;
 }
 const CFX_ByteString& CFX_ByteString::operator+=(const CFX_ByteString& string) {
-  if (string.m_pData == NULL) {
+  if (!string.m_pData) {
     return *this;
   }
   ConcatInPlace(string.m_pData->m_nDataLength, string.m_pData->m_String);
@@ -228,7 +228,7 @@
          FXSYS_memcmp(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0;
 }
 bool CFX_ByteString::Equal(const CFX_ByteStringC& str) const {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return str.IsEmpty();
   }
   return m_pData->m_nDataLength == str.GetLength() &&
@@ -252,7 +252,7 @@
   }
 }
 bool CFX_ByteString::EqualNoCase(const CFX_ByteStringC& str) const {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return str.IsEmpty();
   }
   FX_STRSIZE len = str.GetLength();
@@ -288,7 +288,7 @@
   m_pData->m_String[nSrcLen] = 0;
 }
 void CFX_ByteString::CopyBeforeWrite() {
-  if (m_pData == NULL || m_pData->m_nRefs <= 1) {
+  if (!m_pData || m_pData->m_nRefs <= 1) {
     return;
   }
   StringData* pData = m_pData;
@@ -307,7 +307,7 @@
   m_pData = StringData::Create(nLen);
 }
 void CFX_ByteString::ReleaseBuffer(FX_STRSIZE nNewLength) {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return;
   }
   CopyBeforeWrite();
@@ -327,14 +327,14 @@
   ReleaseBuffer(GetLength());
 }
 FX_CHAR* CFX_ByteString::GetBuffer(FX_STRSIZE nMinBufLength) {
-  if (m_pData == NULL && nMinBufLength == 0) {
+  if (!m_pData && nMinBufLength == 0) {
     return NULL;
   }
   if (m_pData && m_pData->m_nRefs <= 1 &&
       m_pData->m_nAllocLength >= nMinBufLength) {
     return m_pData->m_String;
   }
-  if (m_pData == NULL) {
+  if (!m_pData) {
     m_pData = StringData::Create(nMinBufLength);
     if (!m_pData) {
       return NULL;
@@ -358,7 +358,7 @@
   return m_pData->m_String;
 }
 FX_STRSIZE CFX_ByteString::Delete(FX_STRSIZE nIndex, FX_STRSIZE nCount) {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return 0;
   }
   if (nIndex < 0) {
@@ -381,10 +381,10 @@
 }
 void CFX_ByteString::ConcatInPlace(FX_STRSIZE nSrcLen,
                                    const FX_CHAR* lpszSrcData) {
-  if (nSrcLen == 0 || lpszSrcData == NULL) {
+  if (nSrcLen == 0 || !lpszSrcData) {
     return;
   }
-  if (m_pData == NULL) {
+  if (!m_pData) {
     m_pData = StringData::Create(nSrcLen);
     if (!m_pData) {
       return;
@@ -420,7 +420,7 @@
   pOldData->Release();
 }
 CFX_ByteString CFX_ByteString::Mid(FX_STRSIZE nFirst) const {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return CFX_ByteString();
   }
   return Mid(nFirst, m_pData->m_nDataLength - nFirst);
@@ -453,7 +453,7 @@
   if (nCopyLen == 0 || nCopyLen < 0) {
     return;
   }
-  ASSERT(dest.m_pData == NULL);
+  ASSERT(!dest.m_pData);
   dest.m_pData = StringData::Create(nCopyLen);
   if (dest.m_pData) {
     FXSYS_memcpy(dest.m_pData->m_String, m_pData->m_String + nCopyIndex,
@@ -558,48 +558,48 @@
         break;
       case 's': {
         const FX_CHAR* pstrNextArg = va_arg(argList, const FX_CHAR*);
-        if (pstrNextArg == NULL) {
-          nItemLen = 6;
-        } else {
+        if (pstrNextArg) {
           nItemLen = FXSYS_strlen(pstrNextArg);
           if (nItemLen < 1) {
             nItemLen = 1;
           }
+        } else {
+          nItemLen = 6;
         }
       } break;
       case 'S': {
         FX_WCHAR* pstrNextArg = va_arg(argList, FX_WCHAR*);
-        if (pstrNextArg == NULL) {
-          nItemLen = 6;
-        } else {
+        if (pstrNextArg) {
           nItemLen = FXSYS_wcslen(pstrNextArg);
           if (nItemLen < 1) {
             nItemLen = 1;
           }
+        } else {
+          nItemLen = 6;
         }
       } break;
       case 's' | FORCE_ANSI:
       case 'S' | FORCE_ANSI: {
         const FX_CHAR* pstrNextArg = va_arg(argList, const FX_CHAR*);
-        if (pstrNextArg == NULL) {
-          nItemLen = 6;
-        } else {
+        if (pstrNextArg) {
           nItemLen = FXSYS_strlen(pstrNextArg);
           if (nItemLen < 1) {
             nItemLen = 1;
           }
+        } else {
+          nItemLen = 6;
         }
       } break;
       case 's' | FORCE_UNICODE:
       case 'S' | FORCE_UNICODE: {
         FX_WCHAR* pstrNextArg = va_arg(argList, FX_WCHAR*);
-        if (pstrNextArg == NULL) {
-          nItemLen = 6;
-        } else {
+        if (pstrNextArg) {
           nItemLen = FXSYS_wcslen(pstrNextArg);
           if (nItemLen < 1) {
             nItemLen = 1;
           }
+        } else {
+          nItemLen = 6;
         }
       } break;
     }
@@ -691,7 +691,7 @@
     nIndex = nNewLength;
   }
   nNewLength++;
-  if (m_pData == NULL || m_pData->m_nAllocLength < nNewLength) {
+  if (!m_pData || m_pData->m_nAllocLength < nNewLength) {
     StringData* pOldData = m_pData;
     const FX_CHAR* pstr = m_pData->m_String;
     m_pData = StringData::Create(nNewLength);
@@ -712,7 +712,7 @@
   return nNewLength;
 }
 CFX_ByteString CFX_ByteString::Right(FX_STRSIZE nCount) const {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return CFX_ByteString();
   }
   if (nCount < 0) {
@@ -726,7 +726,7 @@
   return dest;
 }
 CFX_ByteString CFX_ByteString::Left(FX_STRSIZE nCount) const {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return CFX_ByteString();
   }
   if (nCount < 0) {
@@ -740,7 +740,7 @@
   return dest;
 }
 FX_STRSIZE CFX_ByteString::Find(FX_CHAR ch, FX_STRSIZE nStart) const {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return -1;
   }
   FX_STRSIZE nLength = m_pData->m_nDataLength;
@@ -748,10 +748,10 @@
     return -1;
   }
   const FX_CHAR* lpsz = FXSYS_strchr(m_pData->m_String + nStart, ch);
-  return (lpsz == NULL) ? -1 : (int)(lpsz - m_pData->m_String);
+  return lpsz ? (int)(lpsz - m_pData->m_String) : -1;
 }
 FX_STRSIZE CFX_ByteString::ReverseFind(FX_CHAR ch) const {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return -1;
   }
   FX_STRSIZE nLength = m_pData->m_nDataLength;
@@ -788,7 +788,7 @@
 }
 FX_STRSIZE CFX_ByteString::Find(const CFX_ByteStringC& lpszSub,
                                 FX_STRSIZE nStart) const {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return -1;
   }
   FX_STRSIZE nLength = m_pData->m_nDataLength;
@@ -798,10 +798,10 @@
   const FX_CHAR* lpsz =
       FX_strstr(m_pData->m_String + nStart, m_pData->m_nDataLength - nStart,
                 lpszSub.GetCStr(), lpszSub.GetLength());
-  return (lpsz == NULL) ? -1 : (int)(lpsz - m_pData->m_String);
+  return lpsz ? (int)(lpsz - m_pData->m_String) : -1;
 }
 void CFX_ByteString::MakeLower() {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return;
   }
   CopyBeforeWrite();
@@ -811,7 +811,7 @@
   FXSYS_strlwr(m_pData->m_String);
 }
 void CFX_ByteString::MakeUpper() {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return;
   }
   CopyBeforeWrite();
@@ -821,7 +821,7 @@
   FXSYS_strupr(m_pData->m_String);
 }
 FX_STRSIZE CFX_ByteString::Remove(FX_CHAR chRemove) {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return 0;
   }
   CopyBeforeWrite();
@@ -845,7 +845,7 @@
 }
 FX_STRSIZE CFX_ByteString::Replace(const CFX_ByteStringC& lpszOld,
                                    const CFX_ByteStringC& lpszNew) {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return 0;
   }
   if (lpszOld.IsEmpty()) {
@@ -859,7 +859,7 @@
   while (1) {
     const FX_CHAR* pTarget = FX_strstr(pStart, (FX_STRSIZE)(pEnd - pStart),
                                        lpszOld.GetCStr(), nSourceLen);
-    if (pTarget == NULL) {
+    if (!pTarget) {
       break;
     }
     nCount++;
@@ -895,7 +895,7 @@
   return nCount;
 }
 void CFX_ByteString::SetAt(FX_STRSIZE nIndex, FX_CHAR ch) {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return;
   }
   FXSYS_assert(nIndex >= 0);
@@ -924,13 +924,13 @@
 }
 void CFX_ByteString::ConvertFrom(const CFX_WideString& str,
                                  CFX_CharMap* pCharMap) {
-  if (pCharMap == NULL) {
+  if (!pCharMap) {
     pCharMap = CFX_CharMap::GetDefaultMapper();
   }
   *this = (*pCharMap->m_GetByteString)(pCharMap, str);
 }
 int CFX_ByteString::Compare(const CFX_ByteStringC& str) const {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return str.IsEmpty() ? 0 : -1;
   }
   int this_len = m_pData->m_nDataLength;
@@ -953,7 +953,7 @@
   return 0;
 }
 void CFX_ByteString::TrimRight(const CFX_ByteStringC& lpszTargets) {
-  if (m_pData == NULL || lpszTargets.IsEmpty()) {
+  if (!m_pData || lpszTargets.IsEmpty()) {
     return;
   }
   CopyBeforeWrite();
@@ -984,7 +984,7 @@
   TrimRight("\x09\x0a\x0b\x0c\x0d\x20");
 }
 void CFX_ByteString::TrimLeft(const CFX_ByteStringC& lpszTargets) {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return;
   }
   if (lpszTargets.IsEmpty()) {
diff --git a/core/src/fxcrt/fx_basic_gcc.cpp b/core/src/fxcrt/fx_basic_gcc.cpp
index c352ee3..50499a8 100644
--- a/core/src/fxcrt/fx_basic_gcc.cpp
+++ b/core/src/fxcrt/fx_basic_gcc.cpp
@@ -120,7 +120,7 @@
                                FX_CHAR* buf,
                                FX_CHAR** filepart) {
   int srclen = FXSYS_strlen(filename);
-  if (buf == NULL || (int)buflen < srclen + 1) {
+  if (!buf || (int)buflen < srclen + 1) {
     return srclen + 1;
   }
   FXSYS_strcpy(buf, filename);
@@ -142,7 +142,7 @@
                      CFX_ByteString::FromUnicode(mode));
 }
 char* FXSYS_strlwr(char* str) {
-  if (str == NULL) {
+  if (!str) {
     return NULL;
   }
   char* s = str;
@@ -153,7 +153,7 @@
   return s;
 }
 char* FXSYS_strupr(char* str) {
-  if (str == NULL) {
+  if (!str) {
     return NULL;
   }
   char* s = str;
@@ -164,7 +164,7 @@
   return s;
 }
 FX_WCHAR* FXSYS_wcslwr(FX_WCHAR* str) {
-  if (str == NULL) {
+  if (!str) {
     return NULL;
   }
   FX_WCHAR* s = str;
@@ -175,7 +175,7 @@
   return s;
 }
 FX_WCHAR* FXSYS_wcsupr(FX_WCHAR* str) {
-  if (str == NULL) {
+  if (!str) {
     return NULL;
   }
   FX_WCHAR* s = str;
diff --git a/core/src/fxcrt/fx_basic_list.cpp b/core/src/fxcrt/fx_basic_list.cpp
index 292e2a7..81173d6 100644
--- a/core/src/fxcrt/fx_basic_list.cpp
+++ b/core/src/fxcrt/fx_basic_list.cpp
@@ -37,7 +37,7 @@
   return (FX_POSITION)pNewNode;
 }
 FX_POSITION CFX_PtrList::InsertAfter(FX_POSITION position, void* newElement) {
-  if (position == NULL) {
+  if (!position) {
     return AddTail(newElement);
   }
   CNode* pOldNode = (CNode*)position;
@@ -81,7 +81,7 @@
 }
 CFX_PtrList::CNode* CFX_PtrList::NewNode(CFX_PtrList::CNode* pPrev,
                                          CFX_PtrList::CNode* pNext) {
-  if (m_pNodeFree == NULL) {
+  if (!m_pNodeFree) {
     CFX_Plex* pNewBlock =
         CFX_Plex::Create(m_pBlocks, m_nBlockSize, sizeof(CNode));
     CNode* pNode = (CNode*)pNewBlock->data();
@@ -116,11 +116,7 @@
 }
 FX_POSITION CFX_PtrList::Find(void* searchValue, FX_POSITION startAfter) const {
   CNode* pNode = (CNode*)startAfter;
-  if (pNode == NULL) {
-    pNode = m_pNodeHead;
-  } else {
-    pNode = pNode->pNext;
-  }
+  pNode = pNode ? pNode->pNext : m_pNodeHead;
   for (; pNode; pNode = pNode->pNext) {
     if (pNode->data == searchValue)
       return (FX_POSITION)pNode;
diff --git a/core/src/fxcrt/fx_basic_maps.cpp b/core/src/fxcrt/fx_basic_maps.cpp
index f8751ae..f8a0390 100644
--- a/core/src/fxcrt/fx_basic_maps.cpp
+++ b/core/src/fxcrt/fx_basic_maps.cpp
@@ -60,7 +60,7 @@
 FX_BOOL CFX_MapPtrToPtr::Lookup(void* key, void*& rValue) const {
   FX_DWORD nHash;
   CAssoc* pAssoc = GetAssocAt(key, nHash);
-  if (pAssoc == NULL) {
+  if (!pAssoc) {
     return FALSE;
   }
   rValue = pAssoc->value;
@@ -69,7 +69,7 @@
 void* CFX_MapPtrToPtr::GetValueAt(void* key) const {
   FX_DWORD nHash;
   CAssoc* pAssoc = GetAssocAt(key, nHash);
-  if (pAssoc == NULL) {
+  if (!pAssoc) {
     return NULL;
   }
   return pAssoc->value;
@@ -78,7 +78,7 @@
   FX_DWORD nHash;
   CAssoc* pAssoc;
   if ((pAssoc = GetAssocAt(key, nHash)) == NULL) {
-    if (m_pHashTable == NULL) {
+    if (!m_pHashTable) {
       InitHashTable(m_nHashTableSize);
     }
     pAssoc = NewAssoc();
@@ -91,7 +91,7 @@
 CFX_MapPtrToPtr::CAssoc* CFX_MapPtrToPtr::GetAssocAt(void* key,
                                                      FX_DWORD& nHash) const {
   nHash = HashKey(key) % m_nHashTableSize;
-  if (m_pHashTable == NULL) {
+  if (!m_pHashTable) {
     return NULL;
   }
   CAssoc* pAssoc;
@@ -102,7 +102,7 @@
   return NULL;
 }
 CFX_MapPtrToPtr::CAssoc* CFX_MapPtrToPtr::NewAssoc() {
-  if (m_pFreeList == NULL) {
+  if (!m_pFreeList) {
     CFX_Plex* newBlock = CFX_Plex::Create(m_pBlocks, m_nBlockSize,
                                           sizeof(CFX_MapPtrToPtr::CAssoc));
     CFX_MapPtrToPtr::CAssoc* pAssoc =
@@ -132,7 +132,7 @@
   m_nHashTableSize = nHashSize;
 }
 FX_BOOL CFX_MapPtrToPtr::RemoveKey(void* key) {
-  if (m_pHashTable == NULL) {
+  if (!m_pHashTable) {
     return FALSE;
   }
   CAssoc** ppAssocPrev;
@@ -237,7 +237,7 @@
 void CFX_CMapByteStringToPtr::GetNextAssoc(FX_POSITION& rNextPosition,
                                            CFX_ByteString& rKey,
                                            void*& rValue) const {
-  if (rNextPosition == NULL) {
+  if (!rNextPosition) {
     return;
   }
   int index = (int)(uintptr_t)rNextPosition - 1;
@@ -257,7 +257,7 @@
   rNextPosition = NULL;
 }
 void* CFX_CMapByteStringToPtr::GetNextValue(FX_POSITION& rNextPosition) const {
-  if (rNextPosition == NULL) {
+  if (!rNextPosition) {
     return NULL;
   }
   int index = (int)(uintptr_t)rNextPosition - 1;
diff --git a/core/src/fxcrt/fx_basic_util.cpp b/core/src/fxcrt/fx_basic_util.cpp
index b4c7064..9f32ebe 100644
--- a/core/src/fxcrt/fx_basic_util.cpp
+++ b/core/src/fxcrt/fx_basic_util.cpp
@@ -20,7 +20,7 @@
   ClearAll();
 }
 void FX_PRIVATEDATA::FreeData() {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return;
   }
   if (m_bSelfDestruct) {
@@ -33,7 +33,7 @@
                               void* pData,
                               PD_CALLBACK_FREEDATA callback,
                               FX_BOOL bSelfDestruct) {
-  if (pModuleId == NULL) {
+  if (!pModuleId) {
     return;
   }
   FX_PRIVATEDATA* pList = m_DataList.GetData();
@@ -58,7 +58,7 @@
   AddData(pModuleId, pObj, NULL, TRUE);
 }
 FX_BOOL CFX_PrivateData::RemovePrivateData(void* pModuleId) {
-  if (pModuleId == NULL) {
+  if (!pModuleId) {
     return FALSE;
   }
   FX_PRIVATEDATA* pList = m_DataList.GetData();
@@ -72,7 +72,7 @@
   return FALSE;
 }
 void* CFX_PrivateData::GetPrivateData(void* pModuleId) {
-  if (pModuleId == NULL) {
+  if (!pModuleId) {
     return NULL;
   }
   FX_PRIVATEDATA* pList = m_DataList.GetData();
@@ -93,7 +93,7 @@
   m_DataList.RemoveAll();
 }
 void FX_atonum(const CFX_ByteStringC& strc, FX_BOOL& bInteger, void* pData) {
-  if (FXSYS_memchr(strc.GetPtr(), '.', strc.GetLength()) == NULL) {
+  if (!FXSYS_memchr(strc.GetPtr(), '.', strc.GetLength())) {
     bInteger = TRUE;
     int cc = 0, integer = 0;
     const FX_CHAR* str = strc.GetCStr();
@@ -257,7 +257,7 @@
 FX_BOOL FX_GetNextFile(void* handle,
                        CFX_ByteString& filename,
                        FX_BOOL& bFolder) {
-  if (handle == NULL) {
+  if (!handle) {
     return FALSE;
   }
 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
@@ -289,7 +289,7 @@
   return FALSE;
 #else
   struct dirent* de = readdir((DIR*)handle);
-  if (de == NULL) {
+  if (!de) {
     return FALSE;
   }
   filename = de->d_name;
@@ -300,7 +300,7 @@
 FX_BOOL FX_GetNextFile(void* handle,
                        CFX_WideString& filename,
                        FX_BOOL& bFolder) {
-  if (handle == NULL) {
+  if (!handle) {
     return FALSE;
   }
 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
@@ -319,7 +319,7 @@
   return FALSE;
 #else
   struct dirent* de = readdir((DIR*)handle);
-  if (de == NULL) {
+  if (!de) {
     return FALSE;
   }
   filename = CFX_WideString::FromLocal(de->d_name);
@@ -328,7 +328,7 @@
 #endif
 }
 void FX_CloseFolder(void* handle) {
-  if (handle == NULL) {
+  if (!handle) {
     return;
   }
 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
diff --git a/core/src/fxcrt/fx_basic_wstring.cpp b/core/src/fxcrt/fx_basic_wstring.cpp
index a3de140..119de66 100644
--- a/core/src/fxcrt/fx_basic_wstring.cpp
+++ b/core/src/fxcrt/fx_basic_wstring.cpp
@@ -43,7 +43,7 @@
   }
 }
 CFX_WideString::CFX_WideString(const CFX_WideString& stringSrc) {
-  if (stringSrc.m_pData == NULL) {
+  if (!stringSrc.m_pData) {
     m_pData = NULL;
     return;
   }
@@ -101,7 +101,7 @@
   }
 }
 void CFX_WideString::ReleaseBuffer(FX_STRSIZE nNewLength) {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return;
   }
   CopyBeforeWrite();
@@ -117,7 +117,7 @@
   m_pData->m_String[nNewLength] = 0;
 }
 const CFX_WideString& CFX_WideString::operator=(const FX_WCHAR* lpsz) {
-  if (lpsz == NULL || lpsz[0] == 0) {
+  if (!lpsz || lpsz[0] == 0) {
     Empty();
   } else {
     AssignCopy(FXSYS_wcslen(lpsz), lpsz);
@@ -163,7 +163,7 @@
   return *this;
 }
 const CFX_WideString& CFX_WideString::operator+=(const CFX_WideString& string) {
-  if (string.m_pData == NULL) {
+  if (!string.m_pData) {
     return *this;
   }
   ConcatInPlace(string.m_pData->m_nDataLength, string.m_pData->m_String);
@@ -188,7 +188,7 @@
          wmemcmp(ptr, m_pData->m_String, m_pData->m_nDataLength) == 0;
 }
 bool CFX_WideString::Equal(const CFX_WideStringC& str) const {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return str.IsEmpty();
   }
   return str.GetLength() == m_pData->m_nDataLength &&
@@ -213,10 +213,10 @@
 }
 void CFX_WideString::ConcatInPlace(FX_STRSIZE nSrcLen,
                                    const FX_WCHAR* lpszSrcData) {
-  if (nSrcLen == 0 || lpszSrcData == NULL) {
+  if (nSrcLen == 0 || !lpszSrcData) {
     return;
   }
-  if (m_pData == NULL) {
+  if (!m_pData) {
     m_pData = StringData::Create(nSrcLen);
     if (m_pData) {
       FXSYS_memcpy(m_pData->m_String, lpszSrcData, nSrcLen * sizeof(FX_WCHAR));
@@ -251,7 +251,7 @@
   pOldData->Release();
 }
 void CFX_WideString::CopyBeforeWrite() {
-  if (m_pData == NULL || m_pData->m_nRefs <= 1) {
+  if (!m_pData || m_pData->m_nRefs <= 1) {
     return;
   }
   StringData* pData = m_pData;
@@ -278,16 +278,15 @@
   m_pData->m_String[nSrcLen] = 0;
 }
 int CFX_WideString::Compare(const FX_WCHAR* lpsz) const {
-  if (m_pData == NULL) {
-    return (lpsz == NULL || lpsz[0] == 0) ? 0 : -1;
-  }
-  return FXSYS_wcscmp(m_pData->m_String, lpsz);
+  if (m_pData)
+    return FXSYS_wcscmp(m_pData->m_String, lpsz);
+  return (!lpsz || lpsz[0] == 0) ? 0 : -1;
 }
 CFX_ByteString CFX_WideString::UTF8Encode() const {
   return FX_UTF8Encode(*this);
 }
 CFX_ByteString CFX_WideString::UTF16LE_Encode() const {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return CFX_ByteString("\0\0", 2);
   }
   int len = m_pData->m_nDataLength;
@@ -304,7 +303,7 @@
 }
 void CFX_WideString::ConvertFrom(const CFX_ByteString& str,
                                  CFX_CharMap* pCharMap) {
-  if (pCharMap == NULL) {
+  if (!pCharMap) {
     pCharMap = CFX_CharMap::GetDefaultMapper();
   }
   *this = pCharMap->m_GetWideString(pCharMap, str);
@@ -314,14 +313,14 @@
   ReleaseBuffer(GetLength());
 }
 FX_WCHAR* CFX_WideString::GetBuffer(FX_STRSIZE nMinBufLength) {
-  if (m_pData == NULL && nMinBufLength == 0) {
+  if (!m_pData && nMinBufLength == 0) {
     return NULL;
   }
   if (m_pData && m_pData->m_nRefs <= 1 &&
       m_pData->m_nAllocLength >= nMinBufLength) {
     return m_pData->m_String;
   }
-  if (m_pData == NULL) {
+  if (!m_pData) {
     m_pData = StringData::Create(nMinBufLength);
     if (!m_pData) {
       return NULL;
@@ -394,7 +393,7 @@
   pdfium::base::CheckedNumeric<FX_STRSIZE> iSize =
       static_cast<FX_STRSIZE>(sizeof(FX_WCHAR));
   iSize *= nCopyLen;
-  ASSERT(dest.m_pData == NULL);
+  ASSERT(!dest.m_pData);
   dest.m_pData = StringData::Create(nCopyLen);
   if (dest.m_pData) {
     FXSYS_memcpy(dest.m_pData->m_String, m_pData->m_String + nCopyIndex,
@@ -402,7 +401,7 @@
   }
 }
 CFX_WideString CFX_WideString::Left(FX_STRSIZE nCount) const {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return CFX_WideString();
   }
   if (nCount < 0) {
@@ -419,7 +418,7 @@
   return Mid(nFirst, m_pData->m_nDataLength - nFirst);
 }
 CFX_WideString CFX_WideString::Mid(FX_STRSIZE nFirst, FX_STRSIZE nCount) const {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return CFX_WideString();
   }
   if (nFirst < 0) {
@@ -442,7 +441,7 @@
   return dest;
 }
 CFX_WideString CFX_WideString::Right(FX_STRSIZE nCount) const {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return CFX_WideString();
   }
   if (nCount < 0) {
@@ -456,19 +455,19 @@
   return dest;
 }
 int CFX_WideString::CompareNoCase(const FX_WCHAR* lpsz) const {
-  if (m_pData == NULL) {
-    return (lpsz == NULL || lpsz[0] == 0) ? 0 : -1;
+  if (!m_pData) {
+    return (!lpsz || lpsz[0] == 0) ? 0 : -1;
   }
   return FXSYS_wcsicmp(m_pData->m_String, lpsz);
 }
 int CFX_WideString::Compare(const CFX_WideString& str) const {
-  if (m_pData == NULL) {
-    if (str.m_pData == NULL) {
+  if (!m_pData) {
+    if (!str.m_pData) {
       return 0;
     }
     return -1;
   }
-  if (str.m_pData == NULL) {
+  if (!str.m_pData) {
     return 1;
   }
   int this_len = m_pData->m_nDataLength;
@@ -491,7 +490,7 @@
   return 0;
 }
 void CFX_WideString::SetAt(FX_STRSIZE nIndex, FX_WCHAR ch) {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return;
   }
   ASSERT(nIndex >= 0);
@@ -500,7 +499,7 @@
   m_pData->m_String[nIndex] = ch;
 }
 void CFX_WideString::MakeLower() {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return;
   }
   CopyBeforeWrite();
@@ -510,7 +509,7 @@
   FXSYS_wcslwr(m_pData->m_String);
 }
 void CFX_WideString::MakeUpper() {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return;
   }
   CopyBeforeWrite();
@@ -526,10 +525,10 @@
     return -1;
   }
   const FX_WCHAR* lpsz = FXSYS_wcsstr(m_pData->m_String + nStart, lpszSub);
-  return (lpsz == NULL) ? -1 : (int)(lpsz - m_pData->m_String);
+  return lpsz ? (int)(lpsz - m_pData->m_String) : -1;
 }
 FX_STRSIZE CFX_WideString::Find(FX_WCHAR ch, FX_STRSIZE nStart) const {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return -1;
   }
   FX_STRSIZE nLength = m_pData->m_nDataLength;
@@ -537,11 +536,11 @@
     return -1;
   }
   const FX_WCHAR* lpsz = FXSYS_wcschr(m_pData->m_String + nStart, ch);
-  return (lpsz == NULL) ? -1 : (int)(lpsz - m_pData->m_String);
+  return (lpsz) ? (int)(lpsz - m_pData->m_String) : -1;
 }
 void CFX_WideString::TrimRight(const FX_WCHAR* lpszTargetList) {
   FXSYS_assert(lpszTargetList);
-  if (m_pData == NULL || *lpszTargetList == 0) {
+  if (!m_pData || *lpszTargetList == 0) {
     return;
   }
   CopyBeforeWrite();
@@ -551,7 +550,7 @@
   }
   FX_STRSIZE pos = len;
   while (pos) {
-    if (FXSYS_wcschr(lpszTargetList, m_pData->m_String[pos - 1]) == NULL) {
+    if (!FXSYS_wcschr(lpszTargetList, m_pData->m_String[pos - 1])) {
       break;
     }
     pos--;
@@ -570,7 +569,7 @@
 }
 void CFX_WideString::TrimLeft(const FX_WCHAR* lpszTargets) {
   FXSYS_assert(lpszTargets);
-  if (m_pData == NULL || *lpszTargets == 0) {
+  if (!m_pData || *lpszTargets == 0) {
     return;
   }
   CopyBeforeWrite();
@@ -579,7 +578,7 @@
   }
   const FX_WCHAR* lpsz = m_pData->m_String;
   while (*lpsz != 0) {
-    if (FXSYS_wcschr(lpszTargets, *lpsz) == NULL) {
+    if (!FXSYS_wcschr(lpszTargets, *lpsz)) {
       break;
     }
     lpsz++;
@@ -604,7 +603,7 @@
   if (GetLength() < 1) {
     return 0;
   }
-  if (lpszOld == NULL) {
+  if (!lpszOld) {
     return 0;
   }
   FX_STRSIZE nSourceLen = FXSYS_wcslen(lpszOld);
@@ -671,7 +670,7 @@
     nIndex = nNewLength;
   }
   nNewLength++;
-  if (m_pData == NULL || m_pData->m_nAllocLength < nNewLength) {
+  if (!m_pData || m_pData->m_nAllocLength < nNewLength) {
     StringData* pOldData = m_pData;
     const FX_WCHAR* pstr = m_pData->m_String;
     m_pData = StringData::Create(nNewLength);
@@ -711,7 +710,7 @@
   return m_pData->m_nDataLength;
 }
 FX_STRSIZE CFX_WideString::Remove(FX_WCHAR chRemove) {
-  if (m_pData == NULL) {
+  if (!m_pData) {
     return 0;
   }
   CopyBeforeWrite();
@@ -831,48 +830,48 @@
         break;
       case 's': {
         const FX_WCHAR* pstrNextArg = va_arg(argList, const FX_WCHAR*);
-        if (pstrNextArg == NULL) {
-          nItemLen = 6;
-        } else {
+        if (pstrNextArg) {
           nItemLen = FXSYS_wcslen(pstrNextArg);
           if (nItemLen < 1) {
             nItemLen = 1;
           }
+        } else {
+          nItemLen = 6;
         }
       } break;
       case 'S': {
         const FX_CHAR* pstrNextArg = va_arg(argList, const FX_CHAR*);
-        if (pstrNextArg == NULL) {
-          nItemLen = 6;
-        } else {
+        if (pstrNextArg) {
           nItemLen = FXSYS_strlen(pstrNextArg);
           if (nItemLen < 1) {
             nItemLen = 1;
           }
+        } else {
+          nItemLen = 6;
         }
       } break;
       case 's' | FORCE_ANSI:
       case 'S' | FORCE_ANSI: {
         const FX_CHAR* pstrNextArg = va_arg(argList, const FX_CHAR*);
-        if (pstrNextArg == NULL) {
-          nItemLen = 6;
-        } else {
+        if (pstrNextArg) {
           nItemLen = FXSYS_strlen(pstrNextArg);
           if (nItemLen < 1) {
             nItemLen = 1;
           }
+        } else {
+          nItemLen = 6;
         }
       } break;
       case 's' | FORCE_UNICODE:
       case 'S' | FORCE_UNICODE: {
         FX_WCHAR* pstrNextArg = va_arg(argList, FX_WCHAR*);
-        if (pstrNextArg == NULL) {
-          nItemLen = 6;
-        } else {
+        if (pstrNextArg) {
           nItemLen = FXSYS_wcslen(pstrNextArg);
           if (nItemLen < 1) {
             nItemLen = 1;
           }
+        } else {
+          nItemLen = 6;
         }
       } break;
     }
@@ -987,16 +986,10 @@
   return bNegative ? -fraction : fraction;
 }
 int CFX_WideString::GetInteger() const {
-  if (m_pData == NULL) {
-    return 0;
-  }
-  return FXSYS_wtoi(m_pData->m_String);
+  return m_pData ? FXSYS_wtoi(m_pData->m_String) : 0;
 }
 FX_FLOAT CFX_WideString::GetFloat() const {
-  if (m_pData == NULL) {
-    return 0.0;
-  }
-  return FX_wtof(m_pData->m_String, m_pData->m_nDataLength);
+  return m_pData ? FX_wtof(m_pData->m_String, m_pData->m_nDataLength) : 0.0;
 }
 static CFX_ByteString _DefMap_GetByteString(CFX_CharMap* pCharMap,
                                             const CFX_WideString& widestr) {
diff --git a/core/src/fxcrt/fx_extension.cpp b/core/src/fxcrt/fx_extension.cpp
index da936f3..aa06fe5 100644
--- a/core/src/fxcrt/fx_extension.cpp
+++ b/core/src/fxcrt/fx_extension.cpp
@@ -275,8 +275,7 @@
 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
 FX_BOOL FX_GenerateCryptoRandom(FX_DWORD* pBuffer, int32_t iCount) {
   HCRYPTPROV hCP = NULL;
-  if (!::CryptAcquireContext(&hCP, NULL, NULL, PROV_RSA_FULL, 0) ||
-      hCP == NULL) {
+  if (!::CryptAcquireContext(&hCP, NULL, NULL, PROV_RSA_FULL, 0) || !hCP) {
     return FALSE;
   }
   ::CryptGenRandom(hCP, iCount * sizeof(FX_DWORD), (uint8_t*)pBuffer);
diff --git a/core/src/fxcrt/fx_xml_parser.cpp b/core/src/fxcrt/fx_xml_parser.cpp
index 56fbada..0b71836 100644
--- a/core/src/fxcrt/fx_xml_parser.cpp
+++ b/core/src/fxcrt/fx_xml_parser.cpp
@@ -463,7 +463,7 @@
             iState = 0;
             m_dwIndex--;
             CXML_Element* pSubElement = ParseElement(pElement, TRUE);
-            if (pSubElement == NULL) {
+            if (!pSubElement) {
               break;
             }
             pSubElement->m_pParent = pElement;
@@ -767,7 +767,7 @@
 }
 const CFX_WideString* CXML_AttrMap::Lookup(const CFX_ByteStringC& space,
                                            const CFX_ByteStringC& name) const {
-  if (m_pMap == NULL) {
+  if (!m_pMap) {
     return NULL;
   }
   for (int i = 0; i < m_pMap->GetSize(); i++) {
@@ -803,7 +803,7 @@
 }
 void CXML_AttrMap::RemoveAt(const CFX_ByteStringC& space,
                             const CFX_ByteStringC& name) {
-  if (m_pMap == NULL) {
+  if (!m_pMap) {
     return;
   }
   for (int i = 0; i < m_pMap->GetSize(); i++) {
@@ -816,7 +816,7 @@
   }
 }
 int CXML_AttrMap::GetSize() const {
-  return m_pMap == NULL ? 0 : m_pMap->GetSize();
+  return m_pMap ? m_pMap->GetSize() : 0;
 }
 CXML_AttrItem& CXML_AttrMap::GetAt(int index) const {
   return (*m_pMap)[index];
diff --git a/core/src/fxge/agg/src/fx_agg_driver.cpp b/core/src/fxge/agg/src/fx_agg_driver.cpp
index dfa5c27..ed2e8e4 100644
--- a/core/src/fxge/agg/src/fx_agg_driver.cpp
+++ b/core/src/fxge/agg/src/fx_agg_driver.cpp
@@ -150,14 +150,7 @@
   if (width < unit) {
     width = unit;
   }
-  if (pGraphState->m_DashArray == NULL) {
-    agg::conv_stroke<agg::path_storage> stroke(path_data);
-    stroke.line_join(join);
-    stroke.line_cap(cap);
-    stroke.miter_limit(pGraphState->m_MiterLimit);
-    stroke.width(width);
-    rasterizer.add_path_transformed(stroke, pObject2Device);
-  } else {
+  if (pGraphState->m_DashArray) {
     typedef agg::conv_dash<agg::path_storage> dash_converter;
     dash_converter dash(path_data);
     for (int i = 0; i < (pGraphState->m_DashCount + 1) / 2; i++) {
@@ -181,6 +174,13 @@
     stroke.miter_limit(pGraphState->m_MiterLimit);
     stroke.width(width);
     rasterizer.add_path_transformed(stroke, pObject2Device);
+  } else {
+    agg::conv_stroke<agg::path_storage> stroke(path_data);
+    stroke.line_join(join);
+    stroke.line_cap(cap);
+    stroke.miter_limit(pGraphState->m_MiterLimit);
+    stroke.width(width);
+    rasterizer.add_path_transformed(stroke, pObject2Device);
   }
 }
 IFX_RenderDeviceDriver* IFX_RenderDeviceDriver::CreateFxgeDriver(
@@ -554,13 +554,14 @@
       }
     } else {
       int index = 0;
-      if (m_pDevice->GetPalette() == NULL) {
-        index = ((uint8_t)m_Color == 0xff) ? 1 : 0;
-      } else {
-        for (int i = 0; i < 2; i++)
+      if (m_pDevice->GetPalette()) {
+        for (int i = 0; i < 2; i++) {
           if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color) {
             index = i;
           }
+        }
+      } else {
+        index = ((uint8_t)m_Color == 0xff) ? 1 : 0;
       }
       uint8_t* dest_scan1 = dest_scan;
       for (int col = col_start; col < col_end; col++) {
@@ -598,13 +599,14 @@
                       : (clip_right - span_left);
     dest_scan += col_start / 8;
     int index = 0;
-    if (m_pDevice->GetPalette() == NULL) {
-      index = ((uint8_t)m_Color == 0xff) ? 1 : 0;
-    } else {
-      for (int i = 0; i < 2; i++)
+    if (m_pDevice->GetPalette()) {
+      for (int i = 0; i < 2; i++) {
         if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color) {
           index = i;
         }
+      }
+    } else {
+      index = ((uint8_t)m_Color == 0xff) ? 1 : 0;
     }
     uint8_t* dest_scan1 = dest_scan;
     for (int col = col_start; col < col_end; col++) {
@@ -994,7 +996,7 @@
   }
   template <class Scanline>
   void render(const Scanline& sl) {
-    if (m_pOriDevice == NULL && composite_span == NULL) {
+    if (!m_pOriDevice && !composite_span) {
       return;
     }
     int y = sl.y();
@@ -1212,7 +1214,7 @@
   if (blend_type != FXDIB_BLEND_NORMAL) {
     return FALSE;
   }
-  if (GetBuffer() == NULL) {
+  if (!GetBuffer()) {
     return TRUE;
   }
   m_FillFlags = fill_mode;
@@ -1386,7 +1388,7 @@
                                 const CFX_DIBSource* pSrcBitmap,
                                 int src_left,
                                 int src_top) {
-  if (pBitmap == NULL) {
+  if (!pBitmap) {
     return;
   }
   pBitmap->GetOverlapRect(dest_left, dest_top, width, height,
@@ -1527,14 +1529,14 @@
                                       FX_DWORD color,
                                       int alpha_flag,
                                       void* pIccTransform) {
-  if (m_pBitmap->GetBuffer() == NULL) {
+  if (!m_pBitmap->GetBuffer()) {
     return TRUE;
   }
   if (!CFX_GEModule::Get()->GetCodecModule() ||
       !CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) {
     pIccTransform = NULL;
   }
-  if (m_pClipRgn == NULL) {
+  if (!m_pClipRgn) {
     if (m_bRgbByteOrder) {
       RgbByteOrderSetPixel(m_pBitmap, x, y, color);
     } else {
@@ -1576,7 +1578,7 @@
   if (blend_type != FXDIB_BLEND_NORMAL) {
     return FALSE;
   }
-  if (m_pBitmap->GetBuffer() == NULL) {
+  if (!m_pBitmap->GetBuffer()) {
     return TRUE;
   }
   FX_RECT clip_rect;
@@ -1588,7 +1590,7 @@
   if (draw_rect.IsEmpty()) {
     return TRUE;
   }
-  if (m_pClipRgn == NULL || m_pClipRgn->GetType() == CFX_ClipRgn::RectI) {
+  if (!m_pClipRgn || m_pClipRgn->GetType() == CFX_ClipRgn::RectI) {
     if (m_bRgbByteOrder) {
       RgbByteOrderCompositeRect(m_pBitmap, draw_rect.left, draw_rect.top,
                                 draw_rect.Width(), draw_rect.Height(),
@@ -1608,7 +1610,7 @@
   return TRUE;
 }
 FX_BOOL CFX_AggDeviceDriver::GetClipBox(FX_RECT* pRect) {
-  if (m_pClipRgn == NULL) {
+  if (!m_pClipRgn) {
     pRect->left = pRect->top = 0;
     pRect->right = GetDeviceCaps(FXDC_PIXEL_WIDTH);
     pRect->bottom = GetDeviceCaps(FXDC_PIXEL_HEIGHT);
@@ -1622,7 +1624,7 @@
                                        int top,
                                        void* pIccTransform,
                                        FX_BOOL bDEdge) {
-  if (m_pBitmap->GetBuffer() == NULL) {
+  if (!m_pBitmap->GetBuffer()) {
     return TRUE;
   }
   if (bDEdge) {
@@ -1673,7 +1675,7 @@
                                        int blend_type,
                                        int alpha_flag,
                                        void* pIccTransform) {
-  if (m_pBitmap->GetBuffer() == NULL) {
+  if (!m_pBitmap->GetBuffer()) {
     return TRUE;
   }
   if (pBitmap->IsAlphaMask())
@@ -1696,7 +1698,7 @@
                                            int alpha_flag,
                                            void* pIccTransform,
                                            int blend_type) {
-  if (m_pBitmap->GetBuffer() == NULL) {
+  if (!m_pBitmap->GetBuffer()) {
     return TRUE;
   }
   if (dest_width == pSource->GetWidth() &&
@@ -1731,7 +1733,7 @@
                                          int alpha_flag,
                                          void* pIccTransform,
                                          int blend_type) {
-  if (m_pBitmap->GetBuffer() == NULL) {
+  if (!m_pBitmap->GetBuffer()) {
     return TRUE;
   }
   CFX_ImageRenderer* pRenderer = new CFX_ImageRenderer;
@@ -1741,13 +1743,13 @@
   return TRUE;
 }
 FX_BOOL CFX_AggDeviceDriver::ContinueDIBits(void* pHandle, IFX_Pause* pPause) {
-  if (m_pBitmap->GetBuffer() == NULL) {
+  if (!m_pBitmap->GetBuffer()) {
     return TRUE;
   }
   return ((CFX_ImageRenderer*)pHandle)->Continue(pPause);
 }
 void CFX_AggDeviceDriver::CancelDIBits(void* pHandle) {
-  if (m_pBitmap->GetBuffer() == NULL) {
+  if (!m_pBitmap->GetBuffer()) {
     return;
   }
   delete (CFX_ImageRenderer*)pHandle;
@@ -1760,7 +1762,7 @@
                                FX_BOOL bRgbByteOrder,
                                CFX_DIBitmap* pOriDevice,
                                FX_BOOL bGroupKnockout) {
-  if (pBitmap == NULL) {
+  if (!pBitmap) {
     return FALSE;
   }
   SetBitmap(pBitmap);
diff --git a/core/src/fxge/android/fpf_skiafontmgr.cpp b/core/src/fxge/android/fpf_skiafontmgr.cpp
index 254f806..9dbe35d 100644
--- a/core/src/fxge/android/fpf_skiafontmgr.cpp
+++ b/core/src/fxge/android/fpf_skiafontmgr.cpp
@@ -238,7 +238,7 @@
   }
 }
 FX_BOOL CFPF_SkiaFontMgr::InitFTLibrary() {
-  if (m_FTLibrary == NULL) {
+  if (!m_FTLibrary) {
     FXFT_Init_FreeType(&m_FTLibrary);
   }
   return m_FTLibrary != NULL;
diff --git a/core/src/fxge/dib/fx_dib_composite.cpp b/core/src/fxge/dib/fx_dib_composite.cpp
index e89fdce..e284f62 100644
--- a/core/src/fxge/dib/fx_dib_composite.cpp
+++ b/core/src/fxge/dib/fx_dib_composite.cpp
@@ -737,8 +737,8 @@
                              const uint8_t* src_alpha_scan) {
   int blended_colors[3];
   FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE;
-  if (dest_alpha_scan == NULL) {
-    if (src_alpha_scan == NULL) {
+  if (!dest_alpha_scan) {
+    if (!src_alpha_scan) {
       uint8_t back_alpha = 0;
       for (int col = 0; col < pixel_count; col++) {
         back_alpha = dest_scan[3];
@@ -755,10 +755,10 @@
           continue;
         }
         uint8_t src_alpha;
-        if (clip_scan == NULL) {
-          src_alpha = src_scan[3];
-        } else {
+        if (clip_scan) {
           src_alpha = clip_scan[col] * src_scan[3] / 255;
+        } else {
+          src_alpha = src_scan[3];
         }
         if (src_alpha == 0) {
           dest_scan += 4;
@@ -807,10 +807,10 @@
           continue;
         }
         uint8_t src_alpha;
-        if (clip_scan == NULL) {
-          src_alpha = *src_alpha_scan++;
-        } else {
+        if (clip_scan) {
           src_alpha = clip_scan[col] * (*src_alpha_scan++) / 255;
+        } else {
+          src_alpha = *src_alpha_scan++;
         }
         if (src_alpha == 0) {
           dest_scan += 4;
@@ -862,10 +862,10 @@
           continue;
         }
         uint8_t src_alpha;
-        if (clip_scan == NULL) {
-          src_alpha = *src_alpha_scan++;
-        } else {
+        if (clip_scan) {
           src_alpha = clip_scan[col] * (*src_alpha_scan++) / 255;
+        } else {
+          src_alpha = *src_alpha_scan++;
         }
         if (src_alpha == 0) {
           dest_scan += 3;
@@ -915,10 +915,10 @@
           continue;
         }
         uint8_t src_alpha;
-        if (clip_scan == NULL) {
-          src_alpha = src_scan[3];
-        } else {
+        if (clip_scan) {
           src_alpha = clip_scan[col] * src_scan[3] / 255;
+        } else {
+          src_alpha = src_scan[3];
         }
         if (src_alpha == 0) {
           dest_scan += 3;
@@ -960,7 +960,33 @@
   int blended_colors[3];
   FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE;
   int src_gap = src_Bpp - 3;
-  if (dest_alpha_scan == NULL) {
+  if (dest_alpha_scan) {
+    for (int col = 0; col < width; col++) {
+      uint8_t back_alpha = *dest_alpha_scan;
+      if (back_alpha == 0) {
+        *dest_scan++ = *src_scan++;
+        *dest_scan++ = *src_scan++;
+        *dest_scan++ = *src_scan++;
+        *dest_alpha_scan++ = 0xff;
+        src_scan += src_gap;
+        continue;
+      }
+      *dest_alpha_scan++ = 0xff;
+      if (bNonseparableBlend) {
+        _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors);
+      }
+      for (int color = 0; color < 3; color++) {
+        int src_color = *src_scan;
+        int blended = bNonseparableBlend
+                          ? blended_colors[color]
+                          : _BLEND(blend_type, *dest_scan, src_color);
+        *dest_scan = FXDIB_ALPHA_MERGE(src_color, blended, back_alpha);
+        dest_scan++;
+        src_scan++;
+      }
+      src_scan += src_gap;
+    }
+  } else {
     for (int col = 0; col < width; col++) {
       uint8_t back_alpha = dest_scan[3];
       if (back_alpha == 0) {
@@ -990,32 +1016,6 @@
       dest_scan++;
       src_scan += src_gap;
     }
-  } else {
-    for (int col = 0; col < width; col++) {
-      uint8_t back_alpha = *dest_alpha_scan;
-      if (back_alpha == 0) {
-        *dest_scan++ = *src_scan++;
-        *dest_scan++ = *src_scan++;
-        *dest_scan++ = *src_scan++;
-        *dest_alpha_scan++ = 0xff;
-        src_scan += src_gap;
-        continue;
-      }
-      *dest_alpha_scan++ = 0xff;
-      if (bNonseparableBlend) {
-        _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors);
-      }
-      for (int color = 0; color < 3; color++) {
-        int src_color = *src_scan;
-        int blended = bNonseparableBlend
-                          ? blended_colors[color]
-                          : _BLEND(blend_type, *dest_scan, src_color);
-        *dest_scan = FXDIB_ALPHA_MERGE(src_color, blended, back_alpha);
-        dest_scan++;
-        src_scan++;
-      }
-      src_scan += src_gap;
-    }
   }
 }
 inline void _CompositeRow_Rgb2Argb_Blend_Clip(uint8_t* dest_scan,
@@ -1028,7 +1028,44 @@
   int blended_colors[3];
   FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE;
   int src_gap = src_Bpp - 3;
-  if (dest_alpha_scan == NULL) {
+  if (dest_alpha_scan) {
+    for (int col = 0; col < width; col++) {
+      int src_alpha = *clip_scan++;
+      uint8_t back_alpha = *dest_alpha_scan;
+      if (back_alpha == 0) {
+        *dest_scan++ = *src_scan++;
+        *dest_scan++ = *src_scan++;
+        *dest_scan++ = *src_scan++;
+        src_scan += src_gap;
+        dest_alpha_scan++;
+        continue;
+      }
+      if (src_alpha == 0) {
+        dest_scan += 3;
+        dest_alpha_scan++;
+        src_scan += src_Bpp;
+        continue;
+      }
+      uint8_t dest_alpha =
+          back_alpha + src_alpha - back_alpha * src_alpha / 255;
+      *dest_alpha_scan++ = dest_alpha;
+      int alpha_ratio = src_alpha * 255 / dest_alpha;
+      if (bNonseparableBlend) {
+        _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors);
+      }
+      for (int color = 0; color < 3; color++) {
+        int src_color = *src_scan;
+        int blended = bNonseparableBlend
+                          ? blended_colors[color]
+                          : _BLEND(blend_type, *dest_scan, src_color);
+        blended = FXDIB_ALPHA_MERGE(src_color, blended, back_alpha);
+        *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio);
+        dest_scan++;
+        src_scan++;
+      }
+      src_scan += src_gap;
+    }
+  } else {
     for (int col = 0; col < width; col++) {
       int src_alpha = *clip_scan++;
       uint8_t back_alpha = dest_scan[3];
@@ -1065,43 +1102,6 @@
       dest_scan++;
       src_scan += src_gap;
     }
-  } else {
-    for (int col = 0; col < width; col++) {
-      int src_alpha = *clip_scan++;
-      uint8_t back_alpha = *dest_alpha_scan;
-      if (back_alpha == 0) {
-        *dest_scan++ = *src_scan++;
-        *dest_scan++ = *src_scan++;
-        *dest_scan++ = *src_scan++;
-        src_scan += src_gap;
-        dest_alpha_scan++;
-        continue;
-      }
-      if (src_alpha == 0) {
-        dest_scan += 3;
-        dest_alpha_scan++;
-        src_scan += src_Bpp;
-        continue;
-      }
-      uint8_t dest_alpha =
-          back_alpha + src_alpha - back_alpha * src_alpha / 255;
-      *dest_alpha_scan++ = dest_alpha;
-      int alpha_ratio = src_alpha * 255 / dest_alpha;
-      if (bNonseparableBlend) {
-        _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors);
-      }
-      for (int color = 0; color < 3; color++) {
-        int src_color = *src_scan;
-        int blended = bNonseparableBlend
-                          ? blended_colors[color]
-                          : _BLEND(blend_type, *dest_scan, src_color);
-        blended = FXDIB_ALPHA_MERGE(src_color, blended, back_alpha);
-        *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, blended, alpha_ratio);
-        dest_scan++;
-        src_scan++;
-      }
-      src_scan += src_gap;
-    }
   }
 }
 inline void _CompositeRow_Rgb2Argb_NoBlend_Clip(uint8_t* dest_scan,
@@ -1111,36 +1111,7 @@
                                                 const uint8_t* clip_scan,
                                                 uint8_t* dest_alpha_scan) {
   int src_gap = src_Bpp - 3;
-  if (dest_alpha_scan == NULL) {
-    for (int col = 0; col < width; col++) {
-      int src_alpha = clip_scan[col];
-      if (src_alpha == 255) {
-        *dest_scan++ = *src_scan++;
-        *dest_scan++ = *src_scan++;
-        *dest_scan++ = *src_scan++;
-        *dest_scan++ = 255;
-        src_scan += src_gap;
-        continue;
-      }
-      if (src_alpha == 0) {
-        dest_scan += 4;
-        src_scan += src_Bpp;
-        continue;
-      }
-      int back_alpha = dest_scan[3];
-      uint8_t dest_alpha =
-          back_alpha + src_alpha - back_alpha * src_alpha / 255;
-      dest_scan[3] = dest_alpha;
-      int alpha_ratio = src_alpha * 255 / dest_alpha;
-      for (int color = 0; color < 3; color++) {
-        *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, alpha_ratio);
-        dest_scan++;
-        src_scan++;
-      }
-      dest_scan++;
-      src_scan += src_gap;
-    }
-  } else {
+  if (dest_alpha_scan) {
     for (int col = 0; col < width; col++) {
       int src_alpha = clip_scan[col];
       if (src_alpha == 255) {
@@ -1169,6 +1140,35 @@
       }
       src_scan += src_gap;
     }
+  } else {
+    for (int col = 0; col < width; col++) {
+      int src_alpha = clip_scan[col];
+      if (src_alpha == 255) {
+        *dest_scan++ = *src_scan++;
+        *dest_scan++ = *src_scan++;
+        *dest_scan++ = *src_scan++;
+        *dest_scan++ = 255;
+        src_scan += src_gap;
+        continue;
+      }
+      if (src_alpha == 0) {
+        dest_scan += 4;
+        src_scan += src_Bpp;
+        continue;
+      }
+      int back_alpha = dest_scan[3];
+      uint8_t dest_alpha =
+          back_alpha + src_alpha - back_alpha * src_alpha / 255;
+      dest_scan[3] = dest_alpha;
+      int alpha_ratio = src_alpha * 255 / dest_alpha;
+      for (int color = 0; color < 3; color++) {
+        *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, alpha_ratio);
+        dest_scan++;
+        src_scan++;
+      }
+      dest_scan++;
+      src_scan += src_gap;
+    }
   }
 }
 inline void _CompositeRow_Rgb2Argb_NoBlend_NoClip(uint8_t* dest_scan,
@@ -1176,7 +1176,16 @@
                                                   int width,
                                                   int src_Bpp,
                                                   uint8_t* dest_alpha_scan) {
-  if (dest_alpha_scan == NULL) {
+  if (dest_alpha_scan) {
+    int src_gap = src_Bpp - 3;
+    for (int col = 0; col < width; col++) {
+      *dest_scan++ = *src_scan++;
+      *dest_scan++ = *src_scan++;
+      *dest_scan++ = *src_scan++;
+      *dest_alpha_scan++ = 0xff;
+      src_scan += src_gap;
+    }
+  } else {
     for (int col = 0; col < width; col++) {
       if (src_Bpp == 4) {
         FXARGB_SETDIB(dest_scan, 0xff000000 | FXARGB_GETDIB(src_scan));
@@ -1187,15 +1196,6 @@
       dest_scan += 4;
       src_scan += src_Bpp;
     }
-  } else {
-    int src_gap = src_Bpp - 3;
-    for (int col = 0; col < width; col++) {
-      *dest_scan++ = *src_scan++;
-      *dest_scan++ = *src_scan++;
-      *dest_scan++ = *src_scan++;
-      *dest_alpha_scan++ = 0xff;
-      src_scan += src_gap;
-    }
   }
 }
 inline void _CompositeRow_Argb2Rgb_Blend(uint8_t* dest_scan,
@@ -1208,7 +1208,34 @@
   int blended_colors[3];
   FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE;
   int dest_gap = dest_Bpp - 3;
-  if (src_alpha_scan == NULL) {
+  if (src_alpha_scan) {
+    for (int col = 0; col < width; col++) {
+      uint8_t src_alpha;
+      if (clip_scan) {
+        src_alpha = (*src_alpha_scan++) * (*clip_scan++) / 255;
+      } else {
+        src_alpha = *src_alpha_scan++;
+      }
+      if (src_alpha == 0) {
+        dest_scan += dest_Bpp;
+        src_scan += 3;
+        continue;
+      }
+      if (bNonseparableBlend) {
+        _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors);
+      }
+      for (int color = 0; color < 3; color++) {
+        int back_color = *dest_scan;
+        int blended = bNonseparableBlend
+                          ? blended_colors[color]
+                          : _BLEND(blend_type, back_color, *src_scan);
+        *dest_scan = FXDIB_ALPHA_MERGE(back_color, blended, src_alpha);
+        dest_scan++;
+        src_scan++;
+      }
+      dest_scan += dest_gap;
+    }
+  } else {
     for (int col = 0; col < width; col++) {
       uint8_t src_alpha;
       if (clip_scan) {
@@ -1236,33 +1263,6 @@
       dest_scan += dest_gap;
       src_scan++;
     }
-  } else {
-    for (int col = 0; col < width; col++) {
-      uint8_t src_alpha;
-      if (clip_scan) {
-        src_alpha = (*src_alpha_scan++) * (*clip_scan++) / 255;
-      } else {
-        src_alpha = *src_alpha_scan++;
-      }
-      if (src_alpha == 0) {
-        dest_scan += dest_Bpp;
-        src_scan += 3;
-        continue;
-      }
-      if (bNonseparableBlend) {
-        _RGB_Blend(blend_type, src_scan, dest_scan, blended_colors);
-      }
-      for (int color = 0; color < 3; color++) {
-        int back_color = *dest_scan;
-        int blended = bNonseparableBlend
-                          ? blended_colors[color]
-                          : _BLEND(blend_type, back_color, *src_scan);
-        *dest_scan = FXDIB_ALPHA_MERGE(back_color, blended, src_alpha);
-        dest_scan++;
-        src_scan++;
-      }
-      dest_scan += dest_gap;
-    }
   }
 }
 inline void _CompositeRow_Argb2Rgb_NoBlend(uint8_t* dest_scan,
@@ -1272,7 +1272,34 @@
                                            const uint8_t* clip_scan,
                                            const uint8_t* src_alpha_scan) {
   int dest_gap = dest_Bpp - 3;
-  if (src_alpha_scan == NULL) {
+  if (src_alpha_scan) {
+    for (int col = 0; col < width; col++) {
+      uint8_t src_alpha;
+      if (clip_scan) {
+        src_alpha = (*src_alpha_scan++) * (*clip_scan++) / 255;
+      } else {
+        src_alpha = *src_alpha_scan++;
+      }
+      if (src_alpha == 255) {
+        *dest_scan++ = *src_scan++;
+        *dest_scan++ = *src_scan++;
+        *dest_scan++ = *src_scan++;
+        dest_scan += dest_gap;
+        continue;
+      }
+      if (src_alpha == 0) {
+        dest_scan += dest_Bpp;
+        src_scan += 3;
+        continue;
+      }
+      for (int color = 0; color < 3; color++) {
+        *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, src_alpha);
+        dest_scan++;
+        src_scan++;
+      }
+      dest_scan += dest_gap;
+    }
+  } else {
     for (int col = 0; col < width; col++) {
       uint8_t src_alpha;
       if (clip_scan) {
@@ -1301,33 +1328,6 @@
       dest_scan += dest_gap;
       src_scan++;
     }
-  } else {
-    for (int col = 0; col < width; col++) {
-      uint8_t src_alpha;
-      if (clip_scan) {
-        src_alpha = (*src_alpha_scan++) * (*clip_scan++) / 255;
-      } else {
-        src_alpha = *src_alpha_scan++;
-      }
-      if (src_alpha == 255) {
-        *dest_scan++ = *src_scan++;
-        *dest_scan++ = *src_scan++;
-        *dest_scan++ = *src_scan++;
-        dest_scan += dest_gap;
-        continue;
-      }
-      if (src_alpha == 0) {
-        dest_scan += dest_Bpp;
-        src_scan += 3;
-        continue;
-      }
-      for (int color = 0; color < 3; color++) {
-        *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, *src_scan, src_alpha);
-        dest_scan++;
-        src_scan++;
-      }
-      dest_scan += dest_gap;
-    }
   }
 }
 inline void _CompositeRow_Rgb2Rgb_Blend_NoClip(uint8_t* dest_scan,
@@ -1451,7 +1451,9 @@
   ICodec_IccModule* pIccModule =
       CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
   if (src_alpha_scan) {
-    if (dest_alpha_scan == NULL) {
+    if (dest_alpha_scan) {
+      pIccModule->TranslateScanline(pIccTransform, dp, src_scan, pixel_count);
+    } else {
       for (int col = 0; col < pixel_count; col++) {
         pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1);
         dp[3] = *src_alpha_scan++;
@@ -1459,18 +1461,9 @@
         dp += 4;
       }
       src_alpha_scan = NULL;
-    } else {
-      pIccModule->TranslateScanline(pIccTransform, dp, src_scan, pixel_count);
     }
   } else {
-    if (dest_alpha_scan == NULL) {
-      for (int col = 0; col < pixel_count; col++) {
-        pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1);
-        dp[3] = src_scan[3];
-        src_scan += 4;
-        dp += 4;
-      }
-    } else {
+    if (dest_alpha_scan) {
       int blended_colors[3];
       FX_BOOL bNonseparableBlend = blend_type >= FXDIB_BLEND_NONSEPARABLE;
       for (int col = 0; col < pixel_count; col++) {
@@ -1495,10 +1488,10 @@
           continue;
         }
         uint8_t src_alpha;
-        if (clip_scan == NULL) {
-          src_alpha = src_scan[3];
-        } else {
+        if (clip_scan) {
           src_alpha = clip_scan[col] * src_scan[3] / 255;
+        } else {
+          src_alpha = src_scan[3];
         }
         src_scan += 4;
         if (src_alpha == 0) {
@@ -1531,6 +1524,12 @@
       }
       return;
     }
+    for (int col = 0; col < pixel_count; col++) {
+      pIccModule->TranslateScanline(pIccTransform, dp, src_scan, 1);
+      dp[3] = src_scan[3];
+      src_scan += 4;
+      dp += 4;
+    }
   }
   _CompositeRow_Argb2Argb(dest_scan, src_cache_scan, pixel_count, blend_type,
                           clip_scan, dest_alpha_scan, src_alpha_scan);
@@ -2007,7 +2006,7 @@
       for (int col = 0; col < pixel_count; col++) {
         uint8_t gray = pPalette[*src_scan];
         src_scan++;
-        if (clip_scan == NULL || clip_scan[col] == 255) {
+        if (!clip_scan || clip_scan[col] == 255) {
           *dest_scan++ = gray;
           *dest_alpha_scan++ = 255;
           continue;
@@ -2037,7 +2036,7 @@
     for (int col = 0; col < pixel_count; col++) {
       uint8_t gray = pPalette[*src_scan];
       src_scan++;
-      if (clip_scan == NULL || clip_scan[col] == 255) {
+      if (!clip_scan || clip_scan[col] == 255) {
         *dest_scan++ = gray;
         *dest_alpha_scan++ = 255;
         continue;
@@ -2121,7 +2120,7 @@
           (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8)))
               ? set_gray
               : reset_gray;
-      if (clip_scan == NULL || clip_scan[col] == 255) {
+      if (!clip_scan || clip_scan[col] == 255) {
         *dest_scan++ = gray;
         *dest_alpha_scan++ = 255;
         continue;
@@ -2153,7 +2152,7 @@
         (src_scan[(col + src_left) / 8] & (1 << (7 - (col + src_left) % 8)))
             ? set_gray
             : reset_gray;
-    if (clip_scan == NULL || clip_scan[col] == 255) {
+    if (!clip_scan || clip_scan[col] == 255) {
       *dest_scan++ = gray;
       *dest_alpha_scan++ = 255;
       continue;
@@ -2309,10 +2308,10 @@
         continue;
       }
       uint8_t src_alpha;
-      if (clip_scan == NULL) {
-        src_alpha = *src_alpha_scan++;
-      } else {
+      if (clip_scan) {
         src_alpha = clip_scan[col] * (*src_alpha_scan++) / 255;
+      } else {
+        src_alpha = *src_alpha_scan++;
       }
       if (src_alpha == 0) {
         dest_scan += 4;
@@ -2336,7 +2335,7 @@
       int src_r = FXARGB_R(argb);
       int src_g = FXARGB_G(argb);
       int src_b = FXARGB_B(argb);
-      if (clip_scan == NULL || clip_scan[col] == 255) {
+      if (!clip_scan || clip_scan[col] == 255) {
         *dest_scan++ = src_b;
         *dest_scan++ = src_g;
         *dest_scan++ = src_r;
@@ -2394,10 +2393,10 @@
         continue;
       }
       uint8_t src_alpha;
-      if (clip_scan == NULL) {
-        src_alpha = *src_alpha_scan++;
-      } else {
+      if (clip_scan) {
         src_alpha = clip_scan[col] * (*src_alpha_scan++) / 255;
+      } else {
+        src_alpha = *src_alpha_scan++;
       }
       if (src_alpha == 0) {
         dest_scan += 3;
@@ -2421,7 +2420,7 @@
       int src_r = FXARGB_R(argb);
       int src_g = FXARGB_G(argb);
       int src_b = FXARGB_B(argb);
-      if (clip_scan == NULL || clip_scan[col] == 255) {
+      if (!clip_scan || clip_scan[col] == 255) {
         *dest_scan++ = src_b;
         *dest_scan++ = src_g;
         *dest_scan++ = src_r;
@@ -2475,7 +2474,7 @@
       src_g = reset_g;
       src_b = reset_b;
     }
-    if (clip_scan == NULL || clip_scan[col] == 255) {
+    if (!clip_scan || clip_scan[col] == 255) {
       *dest_scan++ = src_b;
       *dest_scan++ = src_g;
       *dest_scan++ = src_r;
@@ -2526,7 +2525,7 @@
       src_g = reset_g;
       src_b = reset_b;
     }
-    if (clip_scan == NULL || clip_scan[col] == 255) {
+    if (!clip_scan || clip_scan[col] == 255) {
       *dest_scan++ = src_b;
       *dest_scan++ = src_g;
       *dest_scan++ = src_r;
@@ -2823,8 +2822,7 @@
                                 int pixel_count,
                                 int blend_type,
                                 const uint8_t* clip_scan) {
-  if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL &&
-      mask_alpha == 255) {
+  if (blend_type == FXDIB_BLEND_NORMAL && !clip_scan && mask_alpha == 255) {
     FX_ARGB argb = FXARGB_MAKE(0xff, src_r, src_g, src_b);
     for (int col = 0; col < pixel_count; col++) {
       if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) {
@@ -2902,8 +2900,7 @@
                                 int blend_type,
                                 const uint8_t* clip_scan,
                                 uint8_t* dest_alpha_scan) {
-  if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL &&
-      mask_alpha == 255) {
+  if (blend_type == FXDIB_BLEND_NORMAL && !clip_scan && mask_alpha == 255) {
     for (int col = 0; col < pixel_count; col++) {
       if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) {
         dest_scan[0] = src_b;
@@ -2989,8 +2986,7 @@
                                int blend_type,
                                int Bpp,
                                const uint8_t* clip_scan) {
-  if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL &&
-      mask_alpha == 255) {
+  if (blend_type == FXDIB_BLEND_NORMAL && !clip_scan && mask_alpha == 255) {
     for (int col = 0; col < pixel_count; col++) {
       if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) {
         dest_scan[2] = src_r;
@@ -3159,10 +3155,10 @@
       continue;
     }
     uint8_t src_alpha;
-    if (clip_scan == NULL) {
-      src_alpha = src_scan[3];
-    } else {
+    if (clip_scan) {
       src_alpha = clip_scan[col] * src_scan[3] / 255;
+    } else {
+      src_alpha = src_scan[3];
     }
     if (src_alpha == 0) {
       dest_scan += 4;
@@ -3623,7 +3619,7 @@
     } else {
       src_r = src_g = src_b = *src_scan;
     }
-    if (clip_scan == NULL || clip_scan[col] == 255) {
+    if (!clip_scan || clip_scan[col] == 255) {
       dest_scan[2] = FX_GAMMA(src_b);
       dest_scan[1] = FX_GAMMA(src_g);
       dest_scan[0] = FX_GAMMA(src_r);
@@ -3683,7 +3679,7 @@
       src_g = reset_g;
       src_b = reset_b;
     }
-    if (clip_scan == NULL || clip_scan[col] == 255) {
+    if (!clip_scan || clip_scan[col] == 255) {
       dest_scan[2] = FX_GAMMA(src_b);
       dest_scan[1] = FX_GAMMA(src_g);
       dest_scan[0] = FX_GAMMA(src_r);
@@ -3837,8 +3833,7 @@
                                              int pixel_count,
                                              int blend_type,
                                              const uint8_t* clip_scan) {
-  if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL &&
-      mask_alpha == 255) {
+  if (blend_type == FXDIB_BLEND_NORMAL && !clip_scan && mask_alpha == 255) {
     FX_ARGB argb = FXARGB_MAKE(0xff, src_r, src_g, src_b);
     for (int col = 0; col < pixel_count; col++) {
       if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) {
@@ -3915,8 +3910,7 @@
                                             int blend_type,
                                             int Bpp,
                                             const uint8_t* clip_scan) {
-  if (blend_type == FXDIB_BLEND_NORMAL && clip_scan == NULL &&
-      mask_alpha == 255) {
+  if (blend_type == FXDIB_BLEND_NORMAL && !clip_scan && mask_alpha == 255) {
     for (int col = 0; col < pixel_count; col++) {
       if (src_scan[(src_left + col) / 8] & (1 << (7 - (src_left + col) % 8))) {
         dest_scan[2] = src_b;
@@ -4215,7 +4209,7 @@
   if (CFX_GEModule::Get()->GetCodecModule()) {
     pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
   }
-  if (pIccModule == NULL) {
+  if (!pIccModule) {
     pIccTransform = NULL;
   }
   m_pIccTransform = pIccTransform;
@@ -4227,8 +4221,7 @@
         dest_format, alpha_flag, mask_color, m_MaskAlpha, m_MaskRed,
         m_MaskGreen, m_MaskBlue, m_MaskBlack, pIccModule, pIccTransform);
   }
-  if (pIccTransform == NULL && (~src_format & 0x0400) &&
-      (dest_format & 0x0400)) {
+  if (!pIccTransform && (~src_format & 0x0400) && (dest_format & 0x0400)) {
     return FALSE;
   }
   if ((m_SrcFormat & 0xff) <= 8) {
@@ -4662,7 +4655,7 @@
                                       const CFX_ClipRgn* pClipRgn,
                                       FX_BOOL bRgbByteOrder,
                                       void* pIccTransform) {
-  if (m_pBuffer == NULL) {
+  if (!m_pBuffer) {
     return FALSE;
   }
   ASSERT(!pSrcBitmap->IsAlphaMask());
@@ -4735,7 +4728,7 @@
                                     FX_BOOL bRgbByteOrder,
                                     int alpha_flag,
                                     void* pIccTransform) {
-  if (m_pBuffer == NULL) {
+  if (!m_pBuffer) {
     return FALSE;
   }
   ASSERT(pMask->IsAlphaMask());
@@ -4799,7 +4792,7 @@
                                     FX_DWORD color,
                                     int alpha_flag,
                                     void* pIccTransform) {
-  if (m_pBuffer == NULL) {
+  if (!m_pBuffer) {
     return FALSE;
   }
   int src_alpha = (alpha_flag >> 8) ? (alpha_flag & 0xff) : FXARGB_A(color);
@@ -4859,13 +4852,14 @@
     int right_shift = rect.right % 8;
     int width = rect.right / 8 - rect.left / 8;
     int index = 0;
-    if (m_pPalette == NULL) {
-      index = ((uint8_t)color == 0xff) ? 1 : 0;
-    } else {
-      for (int i = 0; i < 2; i++)
+    if (m_pPalette) {
+      for (int i = 0; i < 2; i++) {
         if (m_pPalette[i] == color) {
           index = i;
         }
+      }
+    } else {
+      index = ((uint8_t)color == 0xff) ? 1 : 0;
     }
     for (int row = rect.top; row < rect.bottom; row++) {
       uint8_t* dest_scan_top = (uint8_t*)GetScanline(row) + rect.left / 8;
diff --git a/core/src/fxge/dib/fx_dib_convert.cpp b/core/src/fxge/dib/fx_dib_convert.cpp
index 956ff7c..fb8f77b 100644
--- a/core/src/fxge/dib/fx_dib_convert.cpp
+++ b/core/src/fxge/dib/fx_dib_convert.cpp
@@ -209,7 +209,7 @@
   m_lut = 0;
 }
 FX_BOOL CFX_Palette::BuildPalette(const CFX_DIBSource* pBitmap, int pal_type) {
-  if (pBitmap == NULL) {
+  if (!pBitmap) {
     return FALSE;
   }
   FX_Free(m_pPalette);
@@ -560,7 +560,7 @@
   palette.BuildPalette(pSrcBitmap, FXDIB_PALETTE_LOC);
   FX_DWORD* cLut = palette.GetColorLut();
   FX_DWORD* aLut = palette.GetAmountLut();
-  if (cLut == NULL || aLut == NULL) {
+  if (!cLut || !aLut) {
     return FALSE;
   }
   int lut = palette.Getlut();
@@ -981,7 +981,7 @@
     }
     case FXDIB_8bppRgb:
     case FXDIB_8bppRgba: {
-      if ((src_format & 0xff) == 8 && pSrcBitmap->GetPalette() == NULL) {
+      if ((src_format & 0xff) == 8 && !pSrcBitmap->GetPalette()) {
         return ConvertBuffer(FXDIB_8bppMask, dest_buf, dest_pitch, width,
                              height, pSrcBitmap, src_left, src_top, d_pal,
                              pIccTransform);
@@ -1076,12 +1076,12 @@
 CFX_DIBitmap* CFX_DIBSource::CloneConvert(FXDIB_Format dest_format,
                                           const FX_RECT* pClip,
                                           void* pIccTransform) const {
-  if (dest_format == GetFormat() && pIccTransform == NULL) {
+  if (dest_format == GetFormat() && !pIccTransform) {
     return Clone(pClip);
   }
   if (pClip) {
     CFX_DIBitmap* pClone = Clone(pClip);
-    if (pClone == NULL) {
+    if (!pClone) {
       return NULL;
     }
     if (!pClone->ConvertFormat(dest_format, pIccTransform)) {
@@ -1099,7 +1099,7 @@
   CFX_DIBitmap* pSrcAlpha = NULL;
   if (HasAlpha()) {
     pSrcAlpha = (GetFormat() == FXDIB_Argb) ? GetAlphaMask() : m_pAlphaMask;
-    if (pSrcAlpha == NULL) {
+    if (!pSrcAlpha) {
       delete pClone;
       return NULL;
     }
@@ -1138,16 +1138,16 @@
 FX_BOOL CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format,
                                     void* pIccTransform) {
   FXDIB_Format src_format = GetFormat();
-  if (dest_format == src_format && pIccTransform == NULL) {
+  if (dest_format == src_format && !pIccTransform) {
     return TRUE;
   }
   if (dest_format == FXDIB_8bppMask && src_format == FXDIB_8bppRgb &&
-      m_pPalette == NULL) {
+      !m_pPalette) {
     m_AlphaFlag = 1;
     return TRUE;
   }
   if (dest_format == FXDIB_Argb && src_format == FXDIB_Rgb32 &&
-      pIccTransform == NULL) {
+      !pIccTransform) {
     m_AlphaFlag = 2;
     for (int row = 0; row < m_Height; row++) {
       uint8_t* scanline = m_pBuffer + row * m_Pitch + 3;
@@ -1161,7 +1161,7 @@
   int dest_bpp = dest_format & 0xff;
   int dest_pitch = (dest_bpp * m_Width + 31) / 32 * 4;
   uint8_t* dest_buf = FX_TryAlloc(uint8_t, dest_pitch * m_Height + 4);
-  if (dest_buf == NULL) {
+  if (!dest_buf) {
     return FALSE;
   }
   CFX_DIBitmap* pAlphaMask = NULL;
@@ -1180,12 +1180,12 @@
   } else if (dest_format & 0x0200) {
     if (src_format == FXDIB_Argb) {
       pAlphaMask = GetAlphaMask();
-      if (pAlphaMask == NULL) {
+      if (!pAlphaMask) {
         FX_Free(dest_buf);
         return FALSE;
       }
     } else {
-      if (m_pAlphaMask == NULL) {
+      if (!m_pAlphaMask) {
         if (!BuildAlphaMask()) {
           FX_Free(dest_buf);
           return FALSE;
diff --git a/core/src/fxge/dib/fx_dib_engine.cpp b/core/src/fxge/dib/fx_dib_engine.cpp
index 314b600..16772ed 100644
--- a/core/src/fxge/dib/fx_dib_engine.cpp
+++ b/core/src/fxge/dib/fx_dib_engine.cpp
@@ -36,7 +36,7 @@
   }
   m_pWeightTables =
       FX_TryAlloc(uint8_t, (dest_max - dest_min) * m_ItemSize + 4);
-  if (m_pWeightTables == NULL) {
+  if (!m_pWeightTables) {
     return;
   }
   if ((flags & FXDIB_NOSMOOTH) != 0 || FXSYS_fabs((FX_FLOAT)scale) < 1.0f) {
@@ -242,7 +242,7 @@
   size += 31;
   size = size / 32 * 4;
   m_pDestScanline = FX_TryAlloc(uint8_t, size);
-  if (m_pDestScanline == NULL) {
+  if (!m_pDestScanline) {
     return;
   }
   if (dest_format == FXDIB_Rgb32) {
@@ -339,13 +339,13 @@
   FX_Free(m_pDestMaskScanline);
 }
 FX_BOOL CStretchEngine::StartStretchHorz() {
-  if (m_DestWidth == 0 || m_pDestScanline == NULL ||
+  if (m_DestWidth == 0 || !m_pDestScanline ||
       m_SrcClip.Height() > (int)((1U << 29) / m_InterPitch) ||
       m_SrcClip.Height() == 0) {
     return FALSE;
   }
   m_pInterBuf = FX_TryAlloc(unsigned char, m_SrcClip.Height() * m_InterPitch);
-  if (m_pInterBuf == NULL) {
+  if (!m_pInterBuf) {
     return FALSE;
   }
   if (m_pSource && m_bHasAlpha && m_pSource->m_pAlphaMask) {
@@ -359,7 +359,7 @@
   }
   m_WeightTable.Calc(m_DestWidth, m_DestClip.left, m_DestClip.right, m_SrcWidth,
                      m_SrcClip.left, m_SrcClip.right, m_Flags);
-  if (m_WeightTable.m_pWeightTables == NULL) {
+  if (!m_WeightTable.m_pWeightTables) {
     return FALSE;
   }
   m_CurRow = m_SrcClip.top;
@@ -603,7 +603,7 @@
   CWeightTable table;
   table.Calc(m_DestHeight, m_DestClip.top, m_DestClip.bottom, m_SrcHeight,
              m_SrcClip.top, m_SrcClip.bottom, m_Flags);
-  if (table.m_pWeightTables == NULL) {
+  if (!table.m_pWeightTables) {
     return;
   }
   int DestBpp = m_DestBpp / 8;
@@ -849,10 +849,7 @@
   return TRUE;
 }
 FX_BOOL CFX_ImageStretcher::ContinueStretch(IFX_Pause* pPause) {
-  if (m_pStretchEngine == NULL) {
-    return FALSE;
-  }
-  return m_pStretchEngine->Continue(pPause);
+  return m_pStretchEngine && m_pStretchEngine->Continue(pPause);
 }
 FX_BOOL CFX_ImageStretcher::StartQuickStretch() {
   m_bFlipX = FALSE;
@@ -883,7 +880,7 @@
   return TRUE;
 }
 FX_BOOL CFX_ImageStretcher::ContinueQuickStretch(IFX_Pause* pPause) {
-  if (m_pScanline == NULL) {
+  if (!m_pScanline) {
     return FALSE;
   }
   int result_width = m_ClipRect.Width(), result_height = m_ClipRect.Height();
diff --git a/core/src/fxge/dib/fx_dib_main.cpp b/core/src/fxge/dib/fx_dib_main.cpp
index 44d6c50..87c113d 100644
--- a/core/src/fxge/dib/fx_dib_main.cpp
+++ b/core/src/fxge/dib/fx_dib_main.cpp
@@ -89,7 +89,7 @@
     int oomlimit = _MAX_OOM_LIMIT_;
     if (oomlimit >= 0 && size >= oomlimit) {
       m_pBuffer = FX_TryAlloc(uint8_t, size);
-      if (m_pBuffer == NULL) {
+      if (!m_pBuffer) {
         return FALSE;
       }
     } else {
@@ -250,14 +250,14 @@
 }
 void CFX_DIBSource::SetPaletteEntry(int index, FX_DWORD color) {
   ASSERT((GetBPP() == 1 || GetBPP() == 8) && !IsAlphaMask());
-  if (m_pPalette == NULL) {
+  if (!m_pPalette) {
     BuildPalette();
   }
   m_pPalette[index] = color;
 }
 int CFX_DIBSource::FindPalette(FX_DWORD color) const {
   ASSERT((GetBPP() == 1 || GetBPP() == 8) && !IsAlphaMask());
-  if (m_pPalette == NULL) {
+  if (!m_pPalette) {
     if (IsCmykImage()) {
       if (GetBPP() == 1) {
         return ((uint8_t)color == 0xff) ? 0 : 1;
@@ -277,7 +277,7 @@
   return -1;
 }
 void CFX_DIBitmap::Clear(FX_DWORD color) {
-  if (m_pBuffer == NULL) {
+  if (!m_pBuffer) {
     return;
   }
   switch (GetFormat()) {
@@ -377,7 +377,7 @@
                                      int src_left,
                                      int src_top,
                                      void* pIccTransform) {
-  if (m_pBuffer == NULL) {
+  if (!m_pBuffer) {
     return FALSE;
   }
   GetOverlapRect(dest_left, dest_top, width, height, pSrcBitmap->GetWidth(),
@@ -387,7 +387,7 @@
   }
   FXDIB_Format dest_format = GetFormat();
   FXDIB_Format src_format = pSrcBitmap->GetFormat();
-  if (dest_format == src_format && pIccTransform == NULL) {
+  if (dest_format == src_format && !pIccTransform) {
     if (GetBPP() == 1) {
       for (int row = 0; row < height; row++) {
         uint8_t* dest_scan = m_pBuffer + (dest_top + row) * m_Pitch;
@@ -440,7 +440,7 @@
                                    int src_top,
                                    int alpha_flag,
                                    void* pIccTransform) {
-  if (m_pBuffer == NULL) {
+  if (!m_pBuffer) {
     return FALSE;
   }
   ASSERT(HasAlpha() && (m_bpp >= 24));
@@ -540,12 +540,12 @@
   return TRUE;
 }
 void CFX_DIBSource::CopyPalette(const FX_DWORD* pSrc, FX_DWORD size) {
-  if (pSrc == NULL || GetBPP() > 8) {
+  if (!pSrc || GetBPP() > 8) {
     FX_Free(m_pPalette);
     m_pPalette = NULL;
   } else {
     FX_DWORD pal_size = 1 << GetBPP();
-    if (m_pPalette == NULL) {
+    if (!m_pPalette) {
       m_pPalette = FX_Alloc(FX_DWORD, pal_size);
     }
     if (pal_size > size) {
@@ -628,7 +628,7 @@
 FX_BOOL CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel,
                                   const CFX_DIBSource* pSrcBitmap,
                                   FXDIB_Channel srcChannel) {
-  if (m_pBuffer == NULL) {
+  if (!m_pBuffer) {
     return FALSE;
   }
   CFX_DIBSource* pSrcClone = (CFX_DIBSource*)pSrcBitmap;
@@ -640,7 +640,7 @@
     }
     if (pSrcBitmap->GetBPP() == 1) {
       pSrcClone = pSrcBitmap->CloneConvert(FXDIB_8bppMask);
-      if (pSrcClone == NULL) {
+      if (!pSrcClone) {
         return FALSE;
       }
     }
@@ -661,7 +661,7 @@
         pSrcClone = pSrcBitmap->CloneConvert(
             (FXDIB_Format)((pSrcBitmap->GetFormat() & 0xff00) | 0x18));
       }
-      if (pSrcClone == NULL) {
+      if (!pSrcClone) {
         return FALSE;
       }
     }
@@ -723,7 +723,7 @@
         pSrcClone->GetHeight() != m_Height) {
       if (pAlphaMask) {
         pAlphaMask = pAlphaMask->StretchTo(m_Width, m_Height);
-        if (pAlphaMask == NULL) {
+        if (!pAlphaMask) {
           if (pSrcClone != pSrcBitmap) {
             delete pSrcClone;
           }
@@ -743,7 +743,7 @@
     if (pSrcClone != pSrcBitmap) {
       delete pSrcClone;
     }
-    if (pSrcMatched == NULL) {
+    if (!pSrcMatched) {
       return FALSE;
     }
     pSrcClone = pSrcMatched;
@@ -769,7 +769,7 @@
   return TRUE;
 }
 FX_BOOL CFX_DIBitmap::LoadChannel(FXDIB_Channel destChannel, int value) {
-  if (m_pBuffer == NULL) {
+  if (!m_pBuffer) {
     return FALSE;
   }
   int destOffset;
@@ -830,7 +830,7 @@
   return TRUE;
 }
 FX_BOOL CFX_DIBitmap::MultiplyAlpha(const CFX_DIBSource* pSrcBitmap) {
-  if (m_pBuffer == NULL) {
+  if (!m_pBuffer) {
     return FALSE;
   }
   ASSERT(pSrcBitmap->IsAlphaMask());
@@ -844,7 +844,7 @@
   if (pSrcBitmap->GetWidth() != m_Width ||
       pSrcBitmap->GetHeight() != m_Height) {
     pSrcClone = pSrcBitmap->StretchTo(m_Width, m_Height);
-    if (pSrcClone == NULL) {
+    if (!pSrcClone) {
       return FALSE;
     }
   }
@@ -897,12 +897,12 @@
   return TRUE;
 }
 FX_BOOL CFX_DIBitmap::GetGrayData(void* pIccTransform) {
-  if (m_pBuffer == NULL) {
+  if (!m_pBuffer) {
     return FALSE;
   }
   switch (GetFormat()) {
     case FXDIB_1bppRgb: {
-      if (m_pPalette == NULL) {
+      if (!m_pPalette) {
         return FALSE;
       }
       uint8_t gray[2];
@@ -933,7 +933,7 @@
       break;
     }
     case FXDIB_8bppRgb: {
-      if (m_pPalette == NULL) {
+      if (!m_pPalette) {
         return FALSE;
       }
       uint8_t gray[256];
@@ -1001,7 +1001,7 @@
   return TRUE;
 }
 FX_BOOL CFX_DIBitmap::MultiplyAlpha(int alpha) {
-  if (m_pBuffer == NULL) {
+  if (!m_pBuffer) {
     return FALSE;
   }
   switch (GetFormat()) {
@@ -1049,7 +1049,7 @@
   return TRUE;
 }
 FX_DWORD CFX_DIBitmap::GetPixel(int x, int y) const {
-  if (m_pBuffer == NULL) {
+  if (!m_pBuffer) {
     return 0;
   }
   uint8_t* pos = m_pBuffer + y * m_Pitch + x * GetBPP() / 8;
@@ -1082,7 +1082,7 @@
   return 0;
 }
 void CFX_DIBitmap::SetPixel(int x, int y, FX_DWORD color) {
-  if (m_pBuffer == NULL) {
+  if (!m_pBuffer) {
     return;
   }
   if (x < 0 || x >= m_Width || y < 0 || y >= m_Height) {
@@ -1157,7 +1157,7 @@
                                       FX_BOOL bFlipX,
                                       int clip_left,
                                       int clip_width) const {
-  if (m_pBuffer == NULL) {
+  if (!m_pBuffer) {
     return;
   }
   int src_Bpp = m_bpp / 8;
@@ -1217,7 +1217,7 @@
 FX_BOOL CFX_DIBitmap::ConvertColorScale(FX_DWORD forecolor,
                                         FX_DWORD backcolor) {
   ASSERT(!IsAlphaMask());
-  if (m_pBuffer == NULL || IsAlphaMask()) {
+  if (!m_pBuffer || IsAlphaMask()) {
     return FALSE;
   }
   int fc, fm, fy, fk, bc, bm, by, bk;
@@ -1242,13 +1242,13 @@
   }
   if (m_bpp <= 8) {
     if (isCmykImage) {
-      if (forecolor == 0xff && backcolor == 0 && m_pPalette == NULL) {
+      if (forecolor == 0xff && backcolor == 0 && !m_pPalette) {
         return TRUE;
       }
-    } else if (forecolor == 0 && backcolor == 0xffffff && m_pPalette == NULL) {
+    } else if (forecolor == 0 && backcolor == 0xffffff && !m_pPalette) {
       return TRUE;
     }
-    if (m_pPalette == NULL) {
+    if (!m_pPalette) {
       BuildPalette();
     }
     int size = 1 << m_bpp;
@@ -1336,7 +1336,7 @@
 FX_BOOL CFX_DIBitmap::DitherFS(const FX_DWORD* pPalette,
                                int pal_size,
                                const FX_RECT* pRect) {
-  if (m_pBuffer == NULL) {
+  if (!m_pBuffer) {
     return FALSE;
   }
   if (m_bpp != 8 && m_pPalette && m_AlphaFlag != 0) {
@@ -1490,9 +1490,7 @@
 }
 CFX_DIBExtractor::CFX_DIBExtractor(const CFX_DIBSource* pSrc) {
   m_pBitmap = NULL;
-  if (pSrc->GetBuffer() == NULL) {
-    m_pBitmap = pSrc->Clone();
-  } else {
+  if (pSrc->GetBuffer()) {
     m_pBitmap = new CFX_DIBitmap;
     if (!m_pBitmap->Create(pSrc->GetWidth(), pSrc->GetHeight(),
                            pSrc->GetFormat(), pSrc->GetBuffer())) {
@@ -1502,6 +1500,8 @@
     }
     m_pBitmap->CopyPalette(pSrc->GetPalette());
     m_pBitmap->CopyAlphaMask(pSrc->m_pAlphaMask);
+  } else {
+    m_pBitmap = pSrc->Clone();
   }
 }
 CFX_DIBExtractor::~CFX_DIBExtractor() {
@@ -1640,10 +1640,10 @@
       return TRUE;
     }
     CFX_DIBitmap* pBitmap = m_pTransformer->m_Storer.Detach();
-    if (pBitmap == NULL) {
+    if (!pBitmap) {
       return FALSE;
     }
-    if (pBitmap->GetBuffer() == NULL) {
+    if (!pBitmap->GetBuffer()) {
       delete pBitmap;
       return FALSE;
     }
diff --git a/core/src/fxge/dib/fx_dib_transform.cpp b/core/src/fxge/dib/fx_dib_transform.cpp
index 7ff96d5..d9740e0 100644
--- a/core/src/fxge/dib/fx_dib_transform.cpp
+++ b/core/src/fxge/dib/fx_dib_transform.cpp
@@ -423,7 +423,7 @@
   }
   int stretch_width = m_StretchClip.Width();
   int stretch_height = m_StretchClip.Height();
-  if (m_Storer.GetBitmap() == NULL) {
+  if (!m_Storer.GetBitmap()) {
     return FALSE;
   }
   const uint8_t* stretch_buf = m_Storer.GetBitmap()->GetBuffer();
@@ -446,7 +446,7 @@
                             (FX_FLOAT)(m_ResultTop));
   result2stretch.Concat(m_dest2stretch);
   result2stretch.TranslateI(-m_StretchClip.left, -m_StretchClip.top);
-  if (stretch_buf_mask == NULL && pTransformed->m_pAlphaMask) {
+  if (!stretch_buf_mask && pTransformed->m_pAlphaMask) {
     pTransformed->m_pAlphaMask->Clear(0xff000000);
   } else if (pTransformed->m_pAlphaMask) {
     int stretch_pitch_mask = m_Storer.GetBitmap()->m_pAlphaMask->GetPitch();
diff --git a/core/src/fxge/ge/fx_ge.cpp b/core/src/fxge/ge/fx_ge.cpp
index 138f818..f7787cf 100644
--- a/core/src/fxge/ge/fx_ge.cpp
+++ b/core/src/fxge/ge/fx_ge.cpp
@@ -41,7 +41,7 @@
   g_pGEModule = NULL;
 }
 CFX_FontCache* CFX_GEModule::GetFontCache() {
-  if (m_pFontCache == NULL) {
+  if (!m_pFontCache) {
     m_pFontCache = new CFX_FontCache();
   }
   return m_pFontCache;
diff --git a/core/src/fxge/ge/fx_ge_device.cpp b/core/src/fxge/ge/fx_ge_device.cpp
index 3720426..268001b 100644
--- a/core/src/fxge/ge/fx_ge_device.cpp
+++ b/core/src/fxge/ge/fx_ge_device.cpp
@@ -130,7 +130,7 @@
   if ((fill_mode & 3) == 0) {
     fill_alpha = 0;
   }
-  if (pGraphState == NULL) {
+  if (!pGraphState) {
     stroke_alpha = 0;
   }
   if (stroke_alpha == 0 && pPathData->GetPointCount() == 2) {
diff --git a/core/src/fxge/ge/fx_ge_font.cpp b/core/src/fxge/ge/fx_ge_font.cpp
index f3c63a0..2bed2bd 100644
--- a/core/src/fxge/ge/fx_ge_font.cpp
+++ b/core/src/fxge/ge/fx_ge_font.cpp
@@ -226,7 +226,7 @@
 }
 
 CFX_WideString CFX_Font::GetPsName() const {
-  if (m_Face == NULL) {
+  if (!m_Face) {
     return CFX_WideString();
   }
   CFX_WideString psName =
@@ -237,7 +237,7 @@
   return psName;
 }
 CFX_ByteString CFX_Font::GetFamilyName() const {
-  if (m_Face == NULL && m_pSubstFont == NULL) {
+  if (!m_Face && !m_pSubstFont) {
     return CFX_ByteString();
   }
   if (m_Face) {
@@ -246,7 +246,7 @@
   return m_pSubstFont->m_Family;
 }
 CFX_ByteString CFX_Font::GetFaceName() const {
-  if (m_Face == NULL && m_pSubstFont == NULL) {
+  if (!m_Face && !m_pSubstFont) {
     return CFX_ByteString();
   }
   if (m_Face) {
@@ -264,7 +264,7 @@
   return m_pSubstFont->m_Family;
 }
 FX_BOOL CFX_Font::GetBBox(FX_RECT& bbox) {
-  if (m_Face == NULL) {
+  if (!m_Face) {
     return FALSE;
   }
   int em = FXFT_Get_Face_UnitsPerEM(m_Face);
diff --git a/core/src/fxge/ge/fx_ge_fontmap.cpp b/core/src/fxge/ge/fx_ge_fontmap.cpp
index 92c9fdc..d169081 100644
--- a/core/src/fxge/ge/fx_ge_fontmap.cpp
+++ b/core/src/fxge/ge/fx_ge_fontmap.cpp
@@ -315,10 +315,7 @@
       fontName.c_str(), g_AltFontFamilies,
       sizeof g_AltFontFamilies / sizeof(AltFontFamily), sizeof(AltFontFamily),
       CompareFontFamilyString);
-  if (found == NULL) {
-    return fontName;
-  }
-  return found->m_pFontFamily;
+  return found ? CFX_ByteString(found->m_pFontFamily) : fontName;
 }
 
 CFX_ByteString ParseStyle(const FX_CHAR* pStyle, int iLen, int iIndex) {
@@ -679,7 +676,7 @@
   }
 }
 void CFX_FontMapper::SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo) {
-  if (pFontInfo == NULL) {
+  if (!pFontInfo) {
     return;
   }
   if (m_pFontInfo) {
@@ -721,7 +718,7 @@
 }
 
 void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) {
-  if (m_pFontInfo == NULL) {
+  if (!m_pFontInfo) {
     return;
   }
   if (m_CharsetArray.Find((FX_DWORD)charset) == -1) {
@@ -740,11 +737,11 @@
     }
   if (bLocalized) {
     void* hFont = m_pFontInfo->GetFont(name);
-    if (hFont == NULL) {
+    if (!hFont) {
       int iExact;
       hFont =
           m_pFontInfo->MapFont(0, 0, FXFONT_DEFAULT_CHARSET, 0, name, iExact);
-      if (hFont == NULL) {
+      if (!hFont) {
         return;
       }
     }
@@ -759,7 +756,7 @@
   m_LastFamily = name;
 }
 void CFX_FontMapper::LoadInstalledFonts() {
-  if (m_pFontInfo == NULL) {
+  if (!m_pFontInfo) {
     return;
   }
   if (m_bListLoaded) {
@@ -1019,7 +1016,7 @@
       Charset == FXFONT_CHINESEBIG5_CHARSET) {
     bCJK = TRUE;
   }
-  if (m_pFontInfo == NULL) {
+  if (!m_pFontInfo) {
     pSubstFont->m_SubstFlags |= FXFONT_SUBST_STANDARD;
     return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight,
                             PitchFamily);
@@ -1088,7 +1085,7 @@
   if (iExact) {
     pSubstFont->m_SubstFlags |= FXFONT_SUBST_EXACT;
   }
-  if (hFont == NULL) {
+  if (!hFont) {
     if (bCJK) {
       if (italic_angle != 0) {
         bItalic = TRUE;
@@ -1099,7 +1096,7 @@
     }
     if (!match.IsEmpty()) {
       hFont = m_pFontInfo->GetFont(match);
-      if (hFont == NULL) {
+      if (!hFont) {
         return UseInternalSubst(pSubstFont, iBaseFont, italic_angle, old_weight,
                                 PitchFamily);
       }
@@ -1163,7 +1160,7 @@
     uint8_t* pFontData;
     face = m_pFontMgr->GetCachedTTCFace(ttc_size, checksum,
                                         ttc_size - font_size, pFontData);
-    if (face == NULL) {
+    if (!face) {
       pFontData = FX_Alloc(uint8_t, ttc_size);
       m_pFontInfo->GetFontData(hFont, kTableTTCF, pFontData, ttc_size);
       face = m_pFontMgr->AddCachedTTCFace(ttc_size, checksum, pFontData,
@@ -1172,7 +1169,7 @@
   } else {
     uint8_t* pFontData;
     face = m_pFontMgr->GetCachedFace(SubstName, weight, bItalic, pFontData);
-    if (face == NULL) {
+    if (!face) {
       pFontData = FX_Alloc(uint8_t, font_size);
       m_pFontInfo->GetFontData(hFont, 0, pFontData, font_size);
       face = m_pFontMgr->AddCachedFace(SubstName, weight, bItalic, pFontData,
@@ -1180,7 +1177,7 @@
                                        m_pFontInfo->GetFaceIndex(hFont));
     }
   }
-  if (face == NULL) {
+  if (!face) {
     m_pFontInfo->DeleteFont(hFont);
     return NULL;
   }
@@ -1258,7 +1255,7 @@
 }
 void CFX_FolderFontInfo::ScanPath(CFX_ByteString& path) {
   void* handle = FX_OpenFolder(path);
-  if (handle == NULL) {
+  if (!handle) {
     return;
   }
   CFX_ByteString filename;
@@ -1292,7 +1289,7 @@
 }
 void CFX_FolderFontInfo::ScanFile(CFX_ByteString& path) {
   FXSYS_FILE* pFile = FXSYS_fopen(path, "rb");
-  if (pFile == NULL) {
+  if (!pFile) {
     return;
   }
   FXSYS_fseek(pFile, 0, FXSYS_SEEK_END);
@@ -1493,7 +1490,7 @@
 
 void CFX_FolderFontInfo::DeleteFont(void* hFont) {}
 FX_BOOL CFX_FolderFontInfo::GetFaceName(void* hFont, CFX_ByteString& name) {
-  if (hFont == NULL) {
+  if (!hFont) {
     return FALSE;
   }
   CFX_FontFaceInfo* pFont = (CFX_FontFaceInfo*)hFont;
diff --git a/core/src/fxge/ge/fx_ge_path.cpp b/core/src/fxge/ge/fx_ge_path.cpp
index 543c33b..23b1c2f 100644
--- a/core/src/fxge/ge/fx_ge_path.cpp
+++ b/core/src/fxge/ge/fx_ge_path.cpp
@@ -384,7 +384,7 @@
   return rect;
 }
 void CFX_PathData::Transform(const CFX_Matrix* pMatrix) {
-  if (pMatrix == NULL) {
+  if (!pMatrix) {
     return;
   }
   for (int i = 0; i < m_PointCount; i++) {
@@ -564,7 +564,7 @@
 }
 FX_BOOL CFX_PathData::IsRect(const CFX_Matrix* pMatrix,
                              CFX_FloatRect* pRect) const {
-  if (pMatrix == NULL) {
+  if (!pMatrix) {
     if (!IsRect()) {
       return FALSE;
     }
diff --git a/core/src/fxge/ge/fx_ge_ps.cpp b/core/src/fxge/ge/fx_ge_ps.cpp
index ceb2acf..f9fd8de 100644
--- a/core/src/fxge/ge/fx_ge_ps.cpp
+++ b/core/src/fxge/ge/fx_ge_ps.cpp
@@ -374,7 +374,7 @@
   int width = pSource->GetWidth();
   int height = pSource->GetHeight();
   buf << width << " " << height;
-  if (pSource->GetBPP() == 1 && pSource->GetPalette() == NULL) {
+  if (pSource->GetBPP() == 1 && !pSource->GetPalette()) {
     int pitch = (width + 7) / 8;
     FX_DWORD src_size = height * pitch;
     uint8_t* src_buf = FX_Alloc(uint8_t, src_size);
@@ -433,7 +433,7 @@
           break;
       }
     }
-    if (pConverted == NULL) {
+    if (!pConverted) {
       OUTPUT_PS("\nQ\n");
       return FALSE;
     }
@@ -449,7 +449,7 @@
         filter = "/DCTDecode filter ";
       }
     }
-    if (filter == NULL) {
+    if (!filter) {
       int src_pitch = width * Bpp;
       output_size = height * src_pitch;
       output_buf = FX_Alloc(uint8_t, output_size);
@@ -603,7 +603,7 @@
   matrix.Concat(1.0f, 0, 0, 1.0f, 0, 0);
   const CFX_PathData* pPathData = pFaceCache->LoadGlyphPath(
       pFont, charpos.m_GlyphIndex, charpos.m_FontCharWidth);
-  if (pPathData == NULL) {
+  if (!pPathData) {
     return;
   }
   CFX_PathData TransformedPath(*pPathData);
@@ -663,7 +663,7 @@
   buf << "q[" << pObject2Device->a << " " << pObject2Device->b << " "
       << pObject2Device->c << " " << pObject2Device->d << " "
       << pObject2Device->e << " " << pObject2Device->f << "]cm\n";
-  if (pCache == NULL) {
+  if (!pCache) {
     pCache = CFX_GEModule::Get()->GetFontCache();
   }
   CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont);
diff --git a/core/src/fxge/ge/fx_ge_text.cpp b/core/src/fxge/ge/fx_ge_text.cpp
index cd6b690..0ed0bbb 100644
--- a/core/src/fxge/ge/fx_ge_text.cpp
+++ b/core/src/fxge/ge/fx_ge_text.cpp
@@ -51,7 +51,7 @@
   for (int iChar = 0; iChar < nChars; iChar++) {
     FXTEXT_GLYPHPOS& glyph = pGlyphAndPos[iChar];
     const CFX_GlyphBitmap* pGlyph = glyph.m_pGlyph;
-    if (pGlyph == NULL) {
+    if (!pGlyph) {
       continue;
     }
     int char_left = glyph.m_OriginX + pGlyph->m_Left;
@@ -141,7 +141,7 @@
                  FX_DWORD color,
                  int alpha_flag,
                  void* pIccTransform) {
-  if (pIccTransform == NULL && !FXGETFLAG_COLORTYPE(alpha_flag)) {
+  if (!pIccTransform && !FXGETFLAG_COLORTYPE(alpha_flag)) {
     argb = color;
     return;
   }
@@ -243,7 +243,7 @@
   if ((text_flags & FXTEXT_NOSMOOTH) == 0) {
     if (m_DeviceClass == FXDC_DISPLAY && m_bpp > 1) {
       FX_BOOL bClearType;
-      if (pFont->GetFace() == NULL &&
+      if (!pFont->GetFace() &&
           !(pFont->GetSubstFont()->m_SubstFlags & FXFONT_SUBST_CLEARTYPE)) {
         bClearType = FALSE;
       } else {
@@ -264,7 +264,7 @@
       }
     }
   }
-  if (pCache == NULL) {
+  if (!pCache) {
     pCache = CFX_GEModule::Get()->GetFontCache();
   }
   CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont);
@@ -335,7 +335,7 @@
     bitmap.Clear(0);
     for (iChar = 0; iChar < nChars; iChar++) {
       FXTEXT_GLYPHPOS& glyph = pGlyphAndPos[iChar];
-      if (glyph.m_pGlyph == NULL) {
+      if (!glyph.m_pGlyph) {
         continue;
       }
       const CFX_DIBitmap* pGlyph = &glyph.m_pGlyph->m_Bitmap;
@@ -385,7 +385,7 @@
   }
   for (iChar = 0; iChar < nChars; iChar++) {
     FXTEXT_GLYPHPOS& glyph = pGlyphAndPos[iChar];
-    if (glyph.m_pGlyph == NULL) {
+    if (!glyph.m_pGlyph) {
       continue;
     }
     const CFX_DIBitmap* pGlyph = &glyph.m_pGlyph->m_Bitmap;
@@ -1118,7 +1118,7 @@
                                        int alpha_flag,
                                        void* pIccTransform,
                                        int blend_type) {
-  if (pCache == NULL) {
+  if (!pCache) {
     pCache = CFX_GEModule::Get()->GetFontCache();
   }
   CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont);
@@ -1133,7 +1133,7 @@
                   charpos.m_OriginY);
     const CFX_PathData* pPath = pFaceCache->LoadGlyphPath(
         pFont, charpos.m_GlyphIndex, charpos.m_FontCharWidth);
-    if (pPath == NULL) {
+    if (!pPath) {
       continue;
     }
     matrix.Concat(*pText2User);
@@ -1378,7 +1378,7 @@
 void CFX_Font::AdjustMMParams(int glyph_index, int dest_width, int weight) {
   FXFT_MM_Var pMasters = NULL;
   FXFT_Get_MM_Var(m_Face, &pMasters);
-  if (pMasters == NULL) {
+  if (!pMasters) {
     return;
   }
   long coords[2];
@@ -1511,7 +1511,7 @@
                                             const CFX_Matrix* pMatrix,
                                             int dest_width,
                                             int anti_alias) {
-  if (m_Face == NULL) {
+  if (!m_Face) {
     return NULL;
   }
   FXFT_Matrix ft_matrix;
@@ -1787,7 +1787,7 @@
 }
 };
 CFX_PathData* CFX_Font::LoadGlyphPath(FX_DWORD glyph_index, int dest_width) {
-  if (m_Face == NULL) {
+  if (!m_Face) {
     return NULL;
   }
   FXFT_Set_Pixel_Sizes(m_Face, 0, 64);
diff --git a/core/src/fxge/skia/fx_skia_blitter_new.cpp b/core/src/fxge/skia/fx_skia_blitter_new.cpp
index ed7b1c7..85391cb 100644
--- a/core/src/fxge/skia/fx_skia_blitter_new.cpp
+++ b/core/src/fxge/skia/fx_skia_blitter_new.cpp
@@ -16,7 +16,7 @@
                                  const SkAlpha antialias[],
                                  const int16_t runs[]) {
   FXSYS_assert(m_Alpha);
-  if (m_pOriDevice == NULL && composite_span == NULL)
+  if (!m_pOriDevice && !composite_span)
     return;
   if (y < m_ClipBox.top || y >= m_ClipBox.bottom)
     return;
@@ -106,12 +106,13 @@
   dest_scan += col_start / 8;
 
   int index = 0;
-  if (m_pDevice->GetPalette() == NULL)
-    index = ((uint8_t)m_Color == 0xff) ? 1 : 0;
-  else {
-    for (int i = 0; i < 2; i++)
+  if (m_pDevice->GetPalette()) {
+    for (int i = 0; i < 2; i++) {
       if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color)
         index = i;
+    }
+  } else {
+    index = ((uint8_t)m_Color == 0xff) ? 1 : 0;
   }
   uint8_t* dest_scan1 = dest_scan;
   int src_alpha = m_Alpha * cover_scan / 255;
@@ -150,12 +151,13 @@
   dest_scan += col_start / 8;
 
   int index = 0;
-  if (m_pDevice->GetPalette() == NULL)
-    index = ((uint8_t)m_Color == 0xff) ? 1 : 0;
-  else {
-    for (int i = 0; i < 2; i++)
+  if (m_pDevice->GetPalette()) {
+    for (int i = 0; i < 2; i++) {
       if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color)
         index = i;
+    }
+  } else {
+    index = ((uint8_t)m_Color == 0xff) ? 1 : 0;
   }
   uint8_t* dest_scan1 = dest_scan;
   int src_alpha = m_Alpha * cover_scan / 255;
@@ -1736,9 +1738,7 @@
       composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_14;
       break;
   }
-  if (composite_span == NULL)
-    return FALSE;
-  return TRUE;
+  return !!composite_span;
 }
 
 /*----------------------------------------------------------------------------------------------------*/
diff --git a/core/src/fxge/skia/fx_skia_device.cpp b/core/src/fxge/skia/fx_skia_device.cpp
index 8e012c8..2e0371f 100644
--- a/core/src/fxge/skia/fx_skia_device.cpp
+++ b/core/src/fxge/skia/fx_skia_device.cpp
@@ -212,20 +212,7 @@
   if (width <= unit)
     width = unit;
 
-  if (pGraphState->m_DashArray == NULL) {
-    SkStroke stroker;
-    stroker.setCap(cap);
-    stroker.setJoin(join);
-    stroker.setMiterLimit(pGraphState->m_MiterLimit);
-    stroker.setWidth(width);
-    stroker.setDoFill(FALSE);
-    stroker.strokePath(path_data, dstPathData);
-    SkMatrix smatrix;
-    smatrix.setAll(pObject2Device->a, pObject2Device->c, pObject2Device->e,
-                   pObject2Device->b, pObject2Device->d, pObject2Device->f, 0,
-                   0, 1);
-    dstPathData->transform(smatrix);
-  } else {
+  if (pGraphState->m_DashArray) {
     int count = (pGraphState->m_DashCount + 1) / 2;
     SkScalar* intervals = FX_Alloc2D(SkScalar, count, sizeof(SkScalar));
     // Set dash pattern
@@ -255,6 +242,19 @@
                    0, 1);
     dstPathData->transform(smatrix);
     FX_Free(intervals);
+  } else {
+    SkStroke stroker;
+    stroker.setCap(cap);
+    stroker.setJoin(join);
+    stroker.setMiterLimit(pGraphState->m_MiterLimit);
+    stroker.setWidth(width);
+    stroker.setDoFill(FALSE);
+    stroker.strokePath(path_data, dstPathData);
+    SkMatrix smatrix;
+    smatrix.setAll(pObject2Device->a, pObject2Device->c, pObject2Device->e,
+                   pObject2Device->b, pObject2Device->d, pObject2Device->f, 0,
+                   0, 1);
+    dstPathData->transform(smatrix);
   }
 }
 
@@ -331,9 +331,10 @@
     const CFX_Matrix* pObject2Device,  // optional transformation
     int fill_mode                      // fill mode, WINDING or ALTERNATE
     ) {
-  if (m_pAggDriver->m_pClipRgn == NULL)
+  if (!m_pAggDriver->m_pClipRgn) {
     m_pAggDriver->m_pClipRgn = new CFX_ClipRgn(
         GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT));
+  }
 
   if (pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) {
     CFX_FloatRect rectf;
@@ -368,9 +369,10 @@
     const CFX_Matrix* pObject2Device,      // optional transformation
     const CFX_GraphStateData* pGraphState  // graphic state, for pen attributes
     ) {
-  if (m_pAggDriver->m_pClipRgn == NULL)
+  if (!m_pAggDriver->m_pClipRgn) {
     m_pAggDriver->m_pClipRgn = new CFX_ClipRgn(
         GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT));
+  }
 
   // build path data
   CSkia_PathData path_data;
@@ -432,7 +434,7 @@
     int fill_mode,  // fill mode, WINDING or ALTERNATE. 0 for not filled
     int alpha_flag,
     void* pIccTransform) {
-  if (GetBuffer() == NULL)
+  if (!GetBuffer())
     return TRUE;
   FOXIT_DEBUG1("CFX_SkiaDeviceDriver::DrawPath: entering");
   SkIRect rect;
@@ -592,7 +594,7 @@
                                FX_BOOL bRgbByteOrder,
                                CFX_DIBitmap* pOriDevice,
                                FX_BOOL bGroupKnockout) {
-  if (pBitmap == NULL)
+  if (!pBitmap)
     return FALSE;
   SetBitmap(pBitmap);
   CFX_SkiaDeviceDriver* pDriver = new CFX_SkiaDeviceDriver(
diff --git a/core/src/fxge/win32/fx_win32_device.cpp b/core/src/fxge/win32/fx_win32_device.cpp
index 6d52046..c346d1b 100644
--- a/core/src/fxge/win32/fx_win32_device.cpp
+++ b/core/src/fxge/win32/fx_win32_device.cpp
@@ -192,7 +192,7 @@
     {"Times-Italic", "Times New Roman", FALSE, TRUE},
 };
 CFX_ByteString CFX_Win32FontInfo::FindFont(const CFX_ByteString& name) {
-  if (m_pMapper == NULL) {
+  if (!m_pMapper) {
     return name;
   }
   int nFonts = m_pMapper->m_InstalledTTFonts.GetSize();
@@ -251,7 +251,7 @@
   _FontNameMap* found = (_FontNameMap*)FXSYS_bsearch(
       name.c_str(), pFontnameMap, size / sizeof(_FontNameMap),
       sizeof(_FontNameMap), compareString);
-  if (found == NULL) {
+  if (!found) {
     return FALSE;
   }
   name = found->m_pSubFontName;
@@ -528,7 +528,7 @@
                                         void* pIccTransform) {
   if (m_DeviceClass == FXDC_PRINTER) {
     CFX_DIBitmap* pBitmap = pBitmap1->FlipImage(FALSE, TRUE);
-    if (pBitmap == NULL) {
+    if (!pBitmap) {
       return FALSE;
     }
     if ((pBitmap->IsCmykImage() || pIccTransform) &&
@@ -575,7 +575,7 @@
                                             FX_DWORD flags,
                                             void* pIccTransform) {
   CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1;
-  if (pBitmap == NULL || dest_width == 0 || dest_height == 0) {
+  if (!pBitmap || dest_width == 0 || dest_height == 0) {
     return FALSE;
   }
   if ((pBitmap->IsCmykImage() || pIccTransform) &&
@@ -620,7 +620,7 @@
                                              int alpha_flag,
                                              void* pIccTransform) {
   CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1;
-  if (pBitmap == NULL || dest_width == 0 || dest_height == 0) {
+  if (!pBitmap || dest_width == 0 || dest_height == 0) {
     return FALSE;
   }
   _Color2Argb(bitmap_color, bitmap_color, alpha_flag | (1 << 24),
@@ -855,7 +855,7 @@
   _Color2Argb(stroke_color, stroke_color, alpha_flag, pIccTransform);
   CWin32Platform* pPlatform =
       (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData();
-  if ((pGraphState == NULL || stroke_color == 0) &&
+  if (!(pGraphState || stroke_color == 0) &&
       !pPlatform->m_GdiplusExt.IsAvailable()) {
     CFX_FloatRect bbox_f = pPathData->GetBoundingBox();
     if (pMatrix) {
@@ -1066,8 +1066,7 @@
       !CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) {
     pIccTransform = NULL;
   }
-  if (pBitmap->GetBPP() > 8 && !pBitmap->IsCmykImage() &&
-      pIccTransform == NULL) {
+  if (pBitmap->GetBPP() > 8 && !pBitmap->IsCmykImage() && !pIccTransform) {
     ret = ::GetDIBits(hDCMemory, hbmp, 0, height, pBitmap->GetBuffer(), &bmi,
                       DIB_RGB_COLORS) == height;
   } else {
@@ -1165,7 +1164,7 @@
   bitmap_clip.Offset(-dest_left, -dest_top);
   CFX_DIBitmap* pStretched =
       pSource->StretchTo(dest_width, dest_height, render_flags, &bitmap_clip);
-  if (pStretched == NULL) {
+  if (!pStretched) {
     return TRUE;
   }
   FX_RECT src_rect(0, 0, pStretched->GetWidth(), pStretched->GetHeight());
@@ -1205,7 +1204,7 @@
     int clip_width = clip_rect.Width(), clip_height = clip_rect.Height();
     CFX_DIBitmap* pStretched =
         pSource->StretchTo(dest_width, dest_height, flags, &clip_rect);
-    if (pStretched == NULL) {
+    if (!pStretched) {
       return TRUE;
     }
     CFX_DIBitmap background;
@@ -1228,11 +1227,11 @@
   if (pSource->HasAlpha()) {
     CWin32Platform* pPlatform =
         (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData();
-    if (pPlatform->m_GdiplusExt.IsAvailable() && pIccTransform == NULL &&
+    if (pPlatform->m_GdiplusExt.IsAvailable() && !pIccTransform &&
         !pSource->IsCmykImage()) {
       CFX_DIBExtractor temp(pSource);
       CFX_DIBitmap* pBitmap = temp;
-      if (pBitmap == NULL) {
+      if (!pBitmap) {
         return FALSE;
       }
       return pPlatform->m_GdiplusExt.StretchDIBits(
@@ -1340,7 +1339,7 @@
   uint8_t* pBuffer;
   m_hBitmap = CreateDIBSection(NULL, (BITMAPINFO*)&bmih, DIB_RGB_COLORS,
                                (void**)&pBuffer, NULL, 0);
-  if (m_hBitmap == NULL) {
+  if (!m_hBitmap) {
     return;
   }
   CFX_DIBitmap* pBitmap = new CFX_DIBitmap;
diff --git a/core/src/fxge/win32/fx_win32_dib.cpp b/core/src/fxge/win32/fx_win32_dib.cpp
index 1aa60f0..1fdf3ae 100644
--- a/core/src/fxge/win32/fx_win32_dib.cpp
+++ b/core/src/fxge/win32/fx_win32_dib.cpp
@@ -28,24 +28,24 @@
   pbmih->biWidth = pBitmap->GetWidth();
   if (pBitmap->GetBPP() == 8) {
     FX_DWORD* pPalette = (FX_DWORD*)(pbmih + 1);
-    if (pBitmap->GetPalette() == NULL) {
+    if (pBitmap->GetPalette()) {
       for (int i = 0; i < 256; i++) {
-        pPalette[i] = i * 0x010101;
+        pPalette[i] = pBitmap->GetPalette()[i];
       }
     } else {
       for (int i = 0; i < 256; i++) {
-        pPalette[i] = pBitmap->GetPalette()[i];
+        pPalette[i] = i * 0x010101;
       }
     }
   }
   if (pBitmap->GetBPP() == 1) {
     FX_DWORD* pPalette = (FX_DWORD*)(pbmih + 1);
-    if (pBitmap->GetPalette() == NULL) {
-      pPalette[0] = 0;
-      pPalette[1] = 0xffffff;
-    } else {
+    if (pBitmap->GetPalette()) {
       pPalette[0] = pBitmap->GetPalette()[0];
       pPalette[1] = pBitmap->GetPalette()[1];
+    } else {
+      pPalette[0] = 0;
+      pPalette[1] = 0xffffff;
     }
   }
   result.ReleaseBuffer(len);
@@ -125,7 +125,7 @@
   }
   HBITMAP hBitmap = (HBITMAP)LoadImageW(NULL, (wchar_t*)filename, IMAGE_BITMAP,
                                         0, 0, LR_LOADFROMFILE);
-  if (hBitmap == NULL) {
+  if (!hBitmap) {
     return NULL;
   }
   HDC hDC = CreateCompatibleDC(NULL);
@@ -158,7 +158,7 @@
   }
   HBITMAP hBitmap = (HBITMAP)LoadImageW(NULL, (wchar_t*)args.path_name,
                                         IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
-  if (hBitmap == NULL) {
+  if (!hBitmap) {
     return NULL;
   }
   HDC hDC = CreateCompatibleDC(NULL);
@@ -184,8 +184,8 @@
                                           HBITMAP hBitmap,
                                           FX_DWORD* pPalette,
                                           FX_DWORD palsize) {
-  FX_BOOL bCreatedDC = hDC == NULL;
-  if (hDC == NULL) {
+  FX_BOOL bCreatedDC = !hDC;
+  if (bCreatedDC) {
     hDC = CreateCompatibleDC(NULL);
   }
   BITMAPINFOHEADER bmih;
diff --git a/core/src/fxge/win32/fx_win32_dwrite.cpp b/core/src/fxge/win32/fx_win32_dwrite.cpp
index 83924f2..9e56ee7 100644
--- a/core/src/fxge/win32/fx_win32_dwrite.cpp
+++ b/core/src/fxge/win32/fx_win32_dwrite.cpp
@@ -65,7 +65,7 @@
                       OUT IDWriteFontFileStream** fontFileStream);
 
   static IDWriteFontFileLoader* GetLoader() {
-    if (instance_ == NULL) {
+    if (!instance_) {
       instance_ = new CDwFontFileLoader();
     }
     return instance_;
@@ -216,7 +216,7 @@
                                     FX_FLOAT baselineOriginY,
                                     void* glyph_offsets,
                                     FX_FLOAT* glyph_advances) {
-  if (renderTarget == NULL) {
+  if (!renderTarget) {
     return TRUE;
   }
   CDwGdiTextRenderer* pTextRenderer = (CDwGdiTextRenderer*)renderTarget;
diff --git a/core/src/fxge/win32/fx_win32_gdipext.cpp b/core/src/fxge/win32/fx_win32_gdipext.cpp
index e79a88c..1e4f895 100644
--- a/core/src/fxge/win32/fx_win32_gdipext.cpp
+++ b/core/src/fxge/win32/fx_win32_gdipext.cpp
@@ -686,12 +686,12 @@
   strPlusPath += "\\";
   strPlusPath += "GDIPLUS.DLL";
   m_hModule = LoadLibraryA(strPlusPath);
-  if (m_hModule == NULL) {
+  if (!m_hModule) {
     return;
   }
   for (int i = 0; i < sizeof g_GdipFuncNames / sizeof(LPCSTR); i++) {
     m_Functions[i] = GetProcAddress(m_hModule, g_GdipFuncNames[i]);
-    if (m_Functions[i] == NULL) {
+    if (!m_Functions[i]) {
       m_hModule = NULL;
       return;
     }
@@ -701,7 +701,7 @@
   ((FuncType_GdiplusStartup)m_Functions[FuncId_GdiplusStartup])(
       &gdiplusToken, &gdiplusStartupInput, NULL);
   m_GdiModule = LoadLibraryA("GDI32.DLL");
-  if (m_GdiModule == NULL) {
+  if (!m_GdiModule) {
     return;
   }
   m_pGdiAddFontMemResourceEx =
@@ -973,9 +973,9 @@
   FX_FLOAT width = pGraphState ? pGraphState->m_LineWidth : 1.0f;
   if (!bTextMode) {
     FX_FLOAT unit =
-        pMatrix == NULL
-            ? 1.0f
-            : FXSYS_Div(1.0f, (pMatrix->GetXUnit() + pMatrix->GetYUnit()) / 2);
+        pMatrix
+            ? FXSYS_Div(1.0f, (pMatrix->GetXUnit() + pMatrix->GetYUnit()) / 2)
+            : 1.0f;
     if (width < unit) {
       width = unit;
     }
@@ -1198,7 +1198,7 @@
     }
   }
   int new_fill_mode = fill_mode & 3;
-  if (nPoints == 4 && pGraphState == NULL) {
+  if (nPoints == 4 && !pGraphState) {
     int v1, v2;
     if (IsSmallTriangle(points, pObject2Device, v1, v2)) {
       GpPen* pPen = NULL;
@@ -1380,7 +1380,7 @@
     return S_OK;
   }
   virtual HRESULT STDMETHODCALLTYPE Stat(STATSTG* pStatstg, DWORD grfStatFlag) {
-    if (pStatstg == NULL) {
+    if (!pStatstg) {
       return STG_E_INVALIDFUNCTION;
     }
     ZeroMemory(pStatstg, sizeof(STATSTG));
@@ -1492,7 +1492,7 @@
                                          FX_BOOL bAlpha);
 CFX_DIBitmap* CGdiplusExt::LoadDIBitmap(WINDIB_Open_Args_ args) {
   PREVIEW3_DIBITMAP* pInfo = ::LoadDIBitmap(args);
-  if (pInfo == NULL) {
+  if (!pInfo) {
     return NULL;
   }
   int height = abs(pInfo->pbmi->bmiHeader.biHeight);
diff --git a/core/src/fxge/win32/fx_win32_print.cpp b/core/src/fxge/win32/fx_win32_print.cpp
index 39828b1..0c00a7b 100644
--- a/core/src/fxge/win32/fx_win32_print.cpp
+++ b/core/src/fxge/win32/fx_win32_print.cpp
@@ -56,7 +56,7 @@
   }
   CFX_DIBExtractor temp(pSource);
   CFX_DIBitmap* pBitmap = temp;
-  if (pBitmap == NULL) {
+  if (!pBitmap) {
     return FALSE;
   }
   return GDI_SetDIBits(pBitmap, pSrcRect, left, top, pIccTransform);
@@ -82,7 +82,7 @@
     if (dest_width < 0 || dest_height < 0) {
       CFX_DIBitmap* pFlipped =
           pSource->FlipImage(dest_width < 0, dest_height < 0);
-      if (pFlipped == NULL) {
+      if (!pFlipped) {
         return FALSE;
       }
       if (dest_width < 0) {
@@ -99,7 +99,7 @@
     }
     CFX_DIBExtractor temp(pSource);
     CFX_DIBitmap* pBitmap = temp;
-    if (pBitmap == NULL) {
+    if (!pBitmap) {
       return FALSE;
     }
     return GDI_StretchBitMask(pBitmap, dest_left, dest_top, dest_width,
@@ -112,7 +112,7 @@
   if (dest_width < 0 || dest_height < 0) {
     CFX_DIBitmap* pFlipped =
         pSource->FlipImage(dest_width < 0, dest_height < 0);
-    if (pFlipped == NULL) {
+    if (!pFlipped) {
       return FALSE;
     }
     if (dest_width < 0) {
@@ -129,7 +129,7 @@
   }
   CFX_DIBExtractor temp(pSource);
   CFX_DIBitmap* pBitmap = temp;
-  if (pBitmap == NULL) {
+  if (!pBitmap) {
     return FALSE;
   }
   return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width,
@@ -142,7 +142,7 @@
          pSrc->GetFormat() == FXDIB_1bppCmyk);
   CFX_DIBExtractor src_bitmap(pSrc);
   CFX_DIBitmap* pSrcBitmap = src_bitmap;
-  if (pSrcBitmap == NULL) {
+  if (!pSrcBitmap) {
     return NULL;
   }
   int src_width = pSrcBitmap->GetWidth(), src_height = pSrcBitmap->GetHeight();
@@ -250,7 +250,7 @@
   if (FXSYS_fabs(pMatrix->a) < 0.5f && FXSYS_fabs(pMatrix->d) < 0.5f) {
     CFX_DIBitmap* pTransformed =
         pSource->SwapXY(pMatrix->c > 0, pMatrix->b < 0);
-    if (pTransformed == NULL) {
+    if (!pTransformed) {
       return FALSE;
     }
     FX_BOOL ret = StretchDIBits(
@@ -261,7 +261,7 @@
   }
   if (pSource->GetBPP() == 1) {
     CFX_DIBitmap* pTransformed = Transform1bppBitmap(pSource, pMatrix);
-    if (pIccTransform == NULL) {
+    if (!pIccTransform) {
       return FALSE;
     }
     SaveState();
diff --git a/fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp b/fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp
index 743c90e..dd58180 100644
--- a/fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp
+++ b/fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp
@@ -122,7 +122,7 @@
   ASSERT(pDocument != NULL);
 
   CPDF_Dictionary* pFonts = pResDict->GetDict("Font");
-  if (pFonts == NULL)
+  if (!pFonts)
     return NULL;
 
   CPDF_Font* pFind = NULL;
@@ -132,7 +132,7 @@
     CPDF_Object* pObj = NULL;
     CFX_ByteString csKey;
     pObj = pFonts->GetNextElement(pos, csKey);
-    if (pObj == NULL)
+    if (!pObj)
       continue;
 
     CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect());
@@ -142,10 +142,10 @@
       continue;
 
     CPDF_Font* pFont = pDocument->LoadFont(pElement);
-    if (pFont == NULL)
+    if (!pFont)
       continue;
     const CFX_SubstFont* pSubst = pFont->GetSubstFont();
-    if (pSubst == NULL)
+    if (!pSubst)
       continue;
     if (pSubst->m_Charset == nCharset) {
       sFontAlias = csKey;
@@ -170,7 +170,7 @@
 
   CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDict("AP");
 
-  if (pAPDict == NULL) {
+  if (!pAPDict) {
     pAPDict = new CPDF_Dictionary;
     m_pAnnotDict->SetAt("AP", pAPDict);
   }
@@ -181,7 +181,7 @@
     return;
 
   CPDF_Stream* pStream = pAPDict->GetStream(m_sAPType);
-  if (pStream == NULL) {
+  if (!pStream) {
     pStream = new CPDF_Stream(NULL, 0, NULL);
     int32_t objnum = m_pDocument->AddIndirectObject(pStream);
     pAPDict->SetAtReference(m_sAPType, m_pDocument, objnum);
diff --git a/fpdfsdk/src/fpdf_dataavail.cpp b/fpdfsdk/src/fpdf_dataavail.cpp
index 9fe2fa8..f4e235c 100644
--- a/fpdfsdk/src/fpdf_dataavail.cpp
+++ b/fpdfsdk/src/fpdf_dataavail.cpp
@@ -122,7 +122,7 @@
 
 DLLEXPORT FPDF_DOCUMENT STDCALL
 FPDFAvail_GetDocument(FPDF_AVAIL avail, FPDF_BYTESTRING password) {
-  if (avail == NULL)
+  if (!avail)
     return NULL;
   CPDF_Parser* pParser = new CPDF_Parser;
   pParser->SetPassword(password);
diff --git a/fpdfsdk/src/fpdf_sysfontinfo.cpp b/fpdfsdk/src/fpdf_sysfontinfo.cpp
index 71fa944..655c4a2 100644
--- a/fpdfsdk/src/fpdf_sysfontinfo.cpp
+++ b/fpdfsdk/src/fpdf_sysfontinfo.cpp
@@ -55,7 +55,7 @@
   }
 
   FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) override {
-    if (m_pInfo->GetFaceName == NULL)
+    if (!m_pInfo->GetFaceName)
       return FALSE;
     FX_DWORD size = m_pInfo->GetFaceName(m_pInfo, hFont, NULL, 0);
     if (size == 0)
@@ -170,7 +170,7 @@
 
 DLLEXPORT FPDF_SYSFONTINFO* STDCALL FPDF_GetDefaultSystemFontInfo() {
   IFX_SystemFontInfo* pFontInfo = IFX_SystemFontInfo::CreateDefault(nullptr);
-  if (pFontInfo == NULL)
+  if (!pFontInfo)
     return NULL;
 
   FPDF_SYSFONTINFO_DEFAULT* pFontInfoExt =
diff --git a/fpdfsdk/src/fpdf_transformpage.cpp b/fpdfsdk/src/fpdf_transformpage.cpp
index b465b83..3f6ab97 100644
--- a/fpdfsdk/src/fpdf_transformpage.cpp
+++ b/fpdfsdk/src/fpdf_transformpage.cpp
@@ -195,7 +195,7 @@
                               double e,
                               double f) {
   CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_object;
-  if (pPageObj == NULL)
+  if (!pPageObj)
     return;
   CFX_Matrix matrix((FX_FLOAT)a, (FX_FLOAT)b, (FX_FLOAT)c, (FX_FLOAT)d,
                     (FX_FLOAT)e, (FX_FLOAT)f);
@@ -226,7 +226,7 @@
 
 void OutputPath(CFX_ByteTextBuf& buf, CPDF_Path path) {
   const CFX_PathData* pPathData = path;
-  if (pPathData == NULL)
+  if (!pPathData)
     return;
 
   FX_PATHPOINT* pPoints = pPathData->GetPoints();
diff --git a/fpdfsdk/src/fpdftext.cpp b/fpdfsdk/src/fpdftext.cpp
index c8998ae..ed34ecd 100644
--- a/fpdfsdk/src/fpdftext.cpp
+++ b/fpdfsdk/src/fpdftext.cpp
@@ -155,7 +155,7 @@
                      (FX_FLOAT)top);
   CFX_WideString str = textpage->GetTextByRect(rect);
 
-  if (buflen <= 0 || buffer == NULL) {
+  if (buflen <= 0 || !buffer) {
     return str.GetLength();
   }
 
@@ -242,7 +242,7 @@
 
   CFX_ByteString cbUTF16URL = url.UTF16LE_Encode();
   int len = cbUTF16URL.GetLength() / sizeof(unsigned short);
-  if (buffer == NULL || buflen <= 0)
+  if (!buffer || buflen <= 0)
     return len;
   int size = len < buflen ? len : buflen;
   if (size > 0) {
diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp
index 2f360ec..c719cea 100644
--- a/fpdfsdk/src/fpdfview.cpp
+++ b/fpdfsdk/src/fpdfview.cpp
@@ -292,7 +292,7 @@
     return nullptr;
 
   CPDF_Dictionary* pDict = pDoc->GetPage(page_index);
-  if (pDict == NULL)
+  if (!pDict)
     return NULL;
   CPDF_Page* pPage = new CPDF_Page;
   pPage->Load(pDoc, pDict);
@@ -405,7 +405,7 @@
   bmih.biWidth = width;
   pContext->m_hBitmap = CreateDIBSection(dc, (BITMAPINFO*)&bmih, DIB_RGB_COLORS,
                                          &pBuffer, NULL, 0);
-  if (pContext->m_hBitmap == NULL) {
+  if (!pContext->m_hBitmap) {
 #if defined(DEBUG) || defined(_DEBUG)
     char str[128];
     memset(str, 0, sizeof(str));
@@ -443,7 +443,7 @@
 
   // Now output to real device
   HDC hMemDC = CreateCompatibleDC(dc);
-  if (hMemDC == NULL) {
+  if (!hMemDC) {
 #if defined(DEBUG) || defined(_DEBUG)
     char str[128];
     memset(str, 0, sizeof(str));
@@ -558,7 +558,7 @@
                                          int device_y,
                                          double* page_x,
                                          double* page_y) {
-  if (page == NULL || page_x == NULL || page_y == NULL)
+  if (!page || !page_x || !page_y)
     return;
   UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
 
@@ -646,7 +646,7 @@
                                            int width,
                                            int height,
                                            FPDF_DWORD color) {
-  if (bitmap == NULL)
+  if (!bitmap)
     return;
 #ifdef _SKIA_SUPPORT_
   CFX_SkiaDevice device;
@@ -661,27 +661,19 @@
 }
 
 DLLEXPORT void* STDCALL FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap) {
-  if (bitmap == NULL)
-    return NULL;
-  return ((CFX_DIBitmap*)bitmap)->GetBuffer();
+  return bitmap ? ((CFX_DIBitmap*)bitmap)->GetBuffer() : nullptr;
 }
 
 DLLEXPORT int STDCALL FPDFBitmap_GetWidth(FPDF_BITMAP bitmap) {
-  if (bitmap == NULL)
-    return 0;
-  return ((CFX_DIBitmap*)bitmap)->GetWidth();
+  return bitmap ? ((CFX_DIBitmap*)bitmap)->GetWidth() : 0;
 }
 
 DLLEXPORT int STDCALL FPDFBitmap_GetHeight(FPDF_BITMAP bitmap) {
-  if (bitmap == NULL)
-    return 0;
-  return ((CFX_DIBitmap*)bitmap)->GetHeight();
+  return bitmap ? ((CFX_DIBitmap*)bitmap)->GetHeight() : 0;
 }
 
 DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap) {
-  if (bitmap == NULL)
-    return 0;
-  return ((CFX_DIBitmap*)bitmap)->GetPitch();
+  return bitmap ? ((CFX_DIBitmap*)bitmap)->GetPitch() : 0;
 }
 
 DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap) {
diff --git a/fpdfsdk/src/fsdk_baseannot.cpp b/fpdfsdk/src/fsdk_baseannot.cpp
index 734b982..ef7ab0c 100644
--- a/fpdfsdk/src/fsdk_baseannot.cpp
+++ b/fpdfsdk/src/fsdk_baseannot.cpp
@@ -566,7 +566,7 @@
 
 FX_BOOL CPDFSDK_BAAnnot::IsAppearanceValid(CPDF_Annot::AppearanceMode mode) {
   CPDF_Dictionary* pAP = m_pAnnot->GetAnnotDict()->GetDict("AP");
-  if (pAP == NULL)
+  if (!pAP)
     return FALSE;
 
   // Choose the right sub-ap
@@ -580,10 +580,7 @@
 
   // Get the AP stream or subdirectory
   CPDF_Object* psub = pAP->GetElementValue(ap_entry);
-  if (psub == NULL)
-    return FALSE;
-
-  return TRUE;
+  return !!psub;
 }
 
 void CPDFSDK_BAAnnot::DrawBorder(CFX_RenderDevice* pDevice,
diff --git a/fpdfsdk/src/fxedit/fxet_edit.cpp b/fpdfsdk/src/fxedit/fxet_edit.cpp
index 573a572..b048787 100644
--- a/fpdfsdk/src/fxedit/fxet_edit.cpp
+++ b/fpdfsdk/src/fxedit/fxet_edit.cpp
@@ -814,7 +814,7 @@
   m_pVTProvide = NULL;
   delete m_pIterator;
   m_pIterator = NULL;
-  ASSERT(m_pGroupUndoItem == NULL);
+  ASSERT(!m_pGroupUndoItem);
 }
 
 // public methods
@@ -3089,7 +3089,7 @@
 }
 
 void CFX_Edit::BeginGroupUndo(const CFX_WideString& sTitle) {
-  ASSERT(m_pGroupUndoItem == NULL);
+  ASSERT(!m_pGroupUndoItem);
 
   m_pGroupUndoItem = new CFX_Edit_GroupUndoItem(sTitle);
 }
diff --git a/fpdfsdk/src/javascript/Document.cpp b/fpdfsdk/src/javascript/Document.cpp
index b0ca69b..f4a1090 100644
--- a/fpdfsdk/src/javascript/Document.cpp
+++ b/fpdfsdk/src/javascript/Document.cpp
@@ -1259,14 +1259,14 @@
   if (!pNewIcon)
     return;
 
-  if (m_pHead == NULL && m_pEnd == NULL) {
-    m_pHead = m_pEnd = pNewIcon;
-    m_iLength++;
-  } else {
+  if (m_pHead || m_pEnd) {
     m_pEnd->NextIcon = pNewIcon;
     m_pEnd = pNewIcon;
-    m_iLength++;
+  } else {
+    m_pHead = pNewIcon;
+    m_pEnd = pNewIcon;
   }
+  m_iLength++;
 }
 
 void IconTree::DeleteIconTree() {
diff --git a/fpdfsdk/src/javascript/JS_Value.cpp b/fpdfsdk/src/javascript/JS_Value.cpp
index a5844c1..ea7bfda 100644
--- a/fpdfsdk/src/javascript/JS_Value.cpp
+++ b/fpdfsdk/src/javascript/JS_Value.cpp
@@ -611,7 +611,7 @@
     return 0;
   time_t t = (time_t)(d / 1000);
   struct tm* tmp = localtime(&t);
-  if (tmp == NULL)
+  if (!tmp)
     return 0;
   if (tmp->tm_isdst > 0)
     // One hour.