From b45324bfb414acc595e478dc7dc63ac43c792580 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 22 May 2017 17:05:40 -0700 Subject: Use NOTREACHED() in more places. Change-Id: I88466943171f19259f84add69679741d44c8e123 Reviewed-on: https://pdfium-review.googlesource.com/5551 Commit-Queue: Lei Zhang Reviewed-by: Tom Sepez --- core/fpdfapi/font/cpdf_font.cpp | 3 ++- core/fpdfapi/page/cpdf_streamcontentparser.cpp | 3 ++- core/fpdfapi/page/fpdf_page_colors.cpp | 9 +++++---- core/fpdfapi/page/fpdf_page_func.cpp | 5 +++-- core/fpdfapi/parser/cpdf_array.cpp | 2 +- core/fpdfapi/parser/cpdf_object.cpp | 3 ++- core/fpdfapi/parser/fpdf_parser_utility.cpp | 3 ++- core/fpdfapi/render/cpdf_renderstatus.cpp | 3 ++- core/fpdfdoc/cpvt_fontmap.cpp | 7 ++++--- core/fxcodec/codec/ccodec_tiffmodule.cpp | 3 ++- core/fxcodec/codec/fx_codec_jpeg.cpp | 3 ++- core/fxcodec/codec/fx_codec_progress.cpp | 11 ++++++----- core/fxge/dib/cfx_dibsource.cpp | 3 ++- core/fxge/ge/cfx_cliprgn.cpp | 3 ++- core/fxge/skia/fx_skia_device.cpp | 15 +++++++-------- 15 files changed, 44 insertions(+), 32 deletions(-) (limited to 'core') diff --git a/core/fpdfapi/font/cpdf_font.cpp b/core/fpdfapi/font/cpdf_font.cpp index 193ee4a331..1a7fb60b0b 100644 --- a/core/fpdfapi/font/cpdf_font.cpp +++ b/core/fpdfapi/font/cpdf_font.cpp @@ -25,6 +25,7 @@ #include "core/fpdfapi/parser/cpdf_stream_acc.h" #include "core/fxcrt/fx_memory.h" #include "core/fxge/fx_freetype.h" +#include "third_party/base/logging.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" @@ -434,7 +435,7 @@ const char* CPDF_Font::GetAdobeCharName( const std::vector& charnames, int charcode) { if (charcode < 0 || charcode >= 256) { - ASSERT(false); + NOTREACHED(); return nullptr; } diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp index a5af1dbee0..e8594b927b 100644 --- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp +++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp @@ -36,6 +36,7 @@ #include "core/fpdfapi/parser/fpdf_parser_decode.h" #include "core/fxcrt/fx_safe_types.h" #include "core/fxge/cfx_graphstatedata.h" +#include "third_party/base/logging.h" #include "third_party/base/ptr_util.h" namespace { @@ -389,7 +390,7 @@ CPDF_Object* CPDF_StreamContentParser::GetObject(uint32_t index) { if (param.m_Type == ContentParam::OBJECT) return param.m_pObject.get(); - ASSERT(false); + NOTREACHED(); return nullptr; } diff --git a/core/fpdfapi/page/fpdf_page_colors.cpp b/core/fpdfapi/page/fpdf_page_colors.cpp index 3ba833f1ef..1526b75041 100644 --- a/core/fpdfapi/page/fpdf_page_colors.cpp +++ b/core/fpdfapi/page/fpdf_page_colors.cpp @@ -18,6 +18,7 @@ #include "core/fpdfapi/parser/cpdf_stream_acc.h" #include "core/fpdfapi/parser/cpdf_string.h" #include "core/fxcodec/fx_codec.h" +#include "third_party/base/logging.h" #include "third_party/base/stl_util.h" namespace { @@ -105,7 +106,7 @@ bool CPDF_DeviceCS::GetRGB(float* pBuf, float* R, float* G, float* B) const { } return true; default: - ASSERT(false); + NOTREACHED(); return false; } } @@ -141,7 +142,7 @@ bool CPDF_DeviceCS::SetRGB(float* pBuf, float R, float G, float B) const { sRGB_to_AdobeCMYK(R, G, B, pBuf[0], pBuf[1], pBuf[2], pBuf[3]); return true; default: - ASSERT(false); + NOTREACHED(); return false; } } @@ -164,7 +165,7 @@ bool CPDF_DeviceCS::v_SetCMYK(float* pBuf, pBuf[3] = k; return true; default: - ASSERT(false); + NOTREACHED(); return false; } } @@ -213,7 +214,7 @@ void CPDF_DeviceCS::TranslateImageLine(uint8_t* pDestBuf, } break; default: - ASSERT(false); + NOTREACHED(); break; } } diff --git a/core/fpdfapi/page/fpdf_page_func.cpp b/core/fpdfapi/page/fpdf_page_func.cpp index bc66adf726..48cd41c090 100644 --- a/core/fpdfapi/page/fpdf_page_func.cpp +++ b/core/fpdfapi/page/fpdf_page_func.cpp @@ -20,6 +20,7 @@ #include "core/fpdfapi/parser/cpdf_stream.h" #include "core/fpdfapi/parser/cpdf_stream_acc.h" #include "core/fxcrt/fx_safe_types.h" +#include "third_party/base/logging.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" @@ -127,13 +128,13 @@ class CPDF_PSOP { if (m_op == PSOP_CONST) return m_value; - ASSERT(false); + NOTREACHED(); return 0; } CPDF_PSProc* GetProc() const { if (m_op == PSOP_PROC) return m_proc.get(); - ASSERT(false); + NOTREACHED(); return nullptr; } diff --git a/core/fpdfapi/parser/cpdf_array.cpp b/core/fpdfapi/parser/cpdf_array.cpp index 698cd6d0d0..4caad10631 100644 --- a/core/fpdfapi/parser/cpdf_array.cpp +++ b/core/fpdfapi/parser/cpdf_array.cpp @@ -162,7 +162,7 @@ CPDF_Object* CPDF_Array::SetAt(size_t i, std::unique_ptr pObj) { ASSERT(IsArray()); ASSERT(!pObj || pObj->IsInline()); if (i >= m_Objects.size()) { - ASSERT(false); + NOTREACHED(); return nullptr; } CPDF_Object* pRet = pObj.get(); diff --git a/core/fpdfapi/parser/cpdf_object.cpp b/core/fpdfapi/parser/cpdf_object.cpp index f0ff81eeed..82c3b09416 100644 --- a/core/fpdfapi/parser/cpdf_object.cpp +++ b/core/fpdfapi/parser/cpdf_object.cpp @@ -14,6 +14,7 @@ #include "core/fpdfapi/parser/cpdf_parser.h" #include "core/fpdfapi/parser/fpdf_parser_decode.h" #include "core/fxcrt/fx_string.h" +#include "third_party/base/logging.h" #include "third_party/base/stl_util.h" CPDF_Object::~CPDF_Object() {} @@ -59,7 +60,7 @@ CPDF_Dictionary* CPDF_Object::GetDict() const { } void CPDF_Object::SetString(const CFX_ByteString& str) { - ASSERT(false); + NOTREACHED(); } bool CPDF_Object::IsArray() const { diff --git a/core/fpdfapi/parser/fpdf_parser_utility.cpp b/core/fpdfapi/parser/fpdf_parser_utility.cpp index af109e35aa..0cd4ca9225 100644 --- a/core/fpdfapi/parser/fpdf_parser_utility.cpp +++ b/core/fpdfapi/parser/fpdf_parser_utility.cpp @@ -16,6 +16,7 @@ #include "core/fpdfapi/parser/cpdf_string.h" #include "core/fpdfapi/parser/fpdf_parser_decode.h" #include "core/fxcrt/fx_extension.h" +#include "third_party/base/logging.h" // Indexed by 8-bit character code, contains either: // 'W' - for whitespace: NUL, TAB, CR, LF, FF, SPACE, 0x80, 0xff @@ -215,7 +216,7 @@ CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& buf, const CPDF_Object* pObj) { break; } default: - ASSERT(false); + NOTREACHED(); break; } return buf; diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp index e6b01eff3b..9f4bda1409 100644 --- a/core/fpdfapi/render/cpdf_renderstatus.cpp +++ b/core/fpdfapi/render/cpdf_renderstatus.cpp @@ -53,6 +53,7 @@ #include "core/fxge/cfx_pathdata.h" #include "core/fxge/cfx_renderdevice.h" #include "core/fxge/ifx_renderdevicedriver.h" +#include "third_party/base/logging.h" #include "third_party/base/numerics/safe_math.h" #include "third_party/base/ptr_util.h" #include "third_party/base/stl_util.h" @@ -1733,7 +1734,7 @@ bool CPDF_RenderStatus::ProcessText(CPDF_TextObject* textobj, case TextRenderingMode::MODE_INVISIBLE: // Already handled above, but the compiler is not smart enough to // realize it. Fall through. - ASSERT(false); + NOTREACHED(); case TextRenderingMode::MODE_CLIP: return true; } diff --git a/core/fpdfdoc/cpvt_fontmap.cpp b/core/fpdfdoc/cpvt_fontmap.cpp index 42774d43d2..c6e1a85dae 100644 --- a/core/fpdfdoc/cpvt_fontmap.cpp +++ b/core/fpdfdoc/cpvt_fontmap.cpp @@ -12,6 +12,7 @@ #include "core/fpdfapi/parser/cpdf_reference.h" #include "core/fpdfdoc/cpdf_interform.h" #include "core/fxcrt/fx_codepage.h" +#include "third_party/base/logging.h" CPVT_FontMap::CPVT_FontMap(CPDF_Document* pDoc, CPDF_Dictionary* pResDict, @@ -78,16 +79,16 @@ CFX_ByteString CPVT_FontMap::GetPDFFontAlias(int32_t nFontIndex) { int32_t CPVT_FontMap::GetWordFontIndex(uint16_t word, int32_t charset, int32_t nFontIndex) { - ASSERT(false); + NOTREACHED(); return 0; } int32_t CPVT_FontMap::CharCodeFromUnicode(int32_t nFontIndex, uint16_t word) { - ASSERT(false); + NOTREACHED(); return 0; } int32_t CPVT_FontMap::CharSetFromUnicode(uint16_t word, int32_t nOldCharset) { - ASSERT(false); + NOTREACHED(); return FX_CHARSET_ANSI; } diff --git a/core/fxcodec/codec/ccodec_tiffmodule.cpp b/core/fxcodec/codec/ccodec_tiffmodule.cpp index 09eddf6076..6ead576ce8 100644 --- a/core/fxcodec/codec/ccodec_tiffmodule.cpp +++ b/core/fxcodec/codec/ccodec_tiffmodule.cpp @@ -14,6 +14,7 @@ #include "core/fxcrt/fx_safe_types.h" #include "core/fxge/dib/cfx_dibitmap.h" #include "core/fxge/fx_dib.h" +#include "third_party/base/logging.h" #include "third_party/base/ptr_util.h" extern "C" { @@ -119,7 +120,7 @@ tsize_t tiff_read(thandle_t context, tdata_t buf, tsize_t length) { } tsize_t tiff_write(thandle_t context, tdata_t buf, tsize_t length) { - ASSERT(false); + NOTREACHED(); return 0; } diff --git a/core/fxcodec/codec/fx_codec_jpeg.cpp b/core/fxcodec/codec/fx_codec_jpeg.cpp index 907d15f3fb..2211e79522 100644 --- a/core/fxcodec/codec/fx_codec_jpeg.cpp +++ b/core/fxcodec/codec/fx_codec_jpeg.cpp @@ -14,6 +14,7 @@ #include "core/fxcrt/fx_safe_types.h" #include "core/fxge/dib/cfx_dibsource.h" #include "core/fxge/fx_dib.h" +#include "third_party/base/logging.h" #include "third_party/base/ptr_util.h" extern "C" { @@ -297,7 +298,7 @@ bool CCodec_JpegDecoder::v_Rewind() { return false; } if ((int)cinfo.output_width > m_OrigWidth) { - ASSERT(false); + NOTREACHED(); return false; } m_bStarted = true; diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp index 84ab6a14c8..9e470f3f14 100644 --- a/core/fxcodec/codec/fx_codec_progress.cpp +++ b/core/fxcodec/codec/fx_codec_progress.cpp @@ -12,6 +12,7 @@ #include "core/fxcodec/fx_codec.h" #include "core/fxge/dib/cfx_dibitmap.h" #include "core/fxge/fx_dib.h" +#include "third_party/base/logging.h" #include "third_party/base/numerics/safe_math.h" #include "third_party/base/ptr_util.h" @@ -380,7 +381,7 @@ bool CCodec_ProgressiveDecoder::PngReadHeader(int width, switch (format) { case FXDIB_1bppMask: case FXDIB_1bppRgb: - ASSERT(false); + NOTREACHED(); return false; case FXDIB_8bppMask: case FXDIB_8bppRgb: @@ -394,7 +395,7 @@ bool CCodec_ProgressiveDecoder::PngReadHeader(int width, *color_type = 6; break; default: - ASSERT(false); + NOTREACHED(); return false; } *gamma = kPngGamma; @@ -404,7 +405,7 @@ bool CCodec_ProgressiveDecoder::PngReadHeader(int width, bool CCodec_ProgressiveDecoder::PngAskScanlineBuf(int line, uint8_t*& src_buf) { CFX_RetainPtr pDIBitmap = m_pDeviceBitmap; if (!pDIBitmap) { - ASSERT(false); + NOTREACHED(); return false; } if (line >= m_clipBox.top && line < m_clipBox.bottom) { @@ -427,7 +428,7 @@ bool CCodec_ProgressiveDecoder::PngAskScanlineBuf(int line, uint8_t*& src_buf) { switch (pDIBitmap->GetFormat()) { case FXDIB_1bppMask: case FXDIB_1bppRgb: - ASSERT(false); + NOTREACHED(); return false; case FXDIB_8bppMask: case FXDIB_8bppRgb: { @@ -487,7 +488,7 @@ void CCodec_ProgressiveDecoder::PngOneOneMapResampleHorz( switch (pDeviceBitmap->GetFormat()) { case FXDIB_1bppMask: case FXDIB_1bppRgb: - ASSERT(false); + NOTREACHED(); return; case FXDIB_8bppMask: case FXDIB_8bppRgb: { diff --git a/core/fxge/dib/cfx_dibsource.cpp b/core/fxge/dib/cfx_dibsource.cpp index 547f01690c..deb8e15f49 100644 --- a/core/fxge/dib/cfx_dibsource.cpp +++ b/core/fxge/dib/cfx_dibsource.cpp @@ -17,6 +17,7 @@ #include "core/fxge/dib/cfx_imagestretcher.h" #include "core/fxge/dib/cfx_imagetransformer.h" #include "core/fxge/ge/cfx_cliprgn.h" +#include "third_party/base/logging.h" #include "third_party/base/ptr_util.h" namespace { @@ -1136,7 +1137,7 @@ bool CFX_DIBSource::ConvertBuffer( case FXDIB_1bppCmyk: case FXDIB_1bppMask: case FXDIB_1bppRgb: - ASSERT(false); + NOTREACHED(); return false; case FXDIB_8bppMask: { if ((src_format & 0xff) == 1) { diff --git a/core/fxge/ge/cfx_cliprgn.cpp b/core/fxge/ge/cfx_cliprgn.cpp index d2f065dba7..e00cb7c3ad 100644 --- a/core/fxge/ge/cfx_cliprgn.cpp +++ b/core/fxge/ge/cfx_cliprgn.cpp @@ -9,6 +9,7 @@ #include #include "core/fxge/dib/cfx_dibitmap.h" +#include "third_party/base/logging.h" CFX_ClipRgn::CFX_ClipRgn(int width, int height) : m_Type(RectI), m_Box(0, 0, width, height) {} @@ -101,5 +102,5 @@ void CFX_ClipRgn::IntersectMaskF(int left, m_Mask = std::move(new_dib); return; } - ASSERT(false); + NOTREACHED(); } diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp index dd48045ce1..a1193fbe9b 100644 --- a/core/fxge/skia/fx_skia_device.cpp +++ b/core/fxge/skia/fx_skia_device.cpp @@ -22,13 +22,8 @@ #include "core/fxge/dib/cfx_imagerenderer.h" #include "core/fxge/dib/cfx_imagestretcher.h" #include "core/fxge/skia/fx_skia_device.h" - -#ifdef _SKIA_SUPPORT_PATHS_ -#include "core/fxge/ge/cfx_cliprgn.h" -#endif // _SKIA_SUPPORT_PATHS_ - +#include "third_party/base/logging.h" #include "third_party/base/ptr_util.h" - #include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkClipOp.h" #include "third_party/skia/include/core/SkImage.h" @@ -41,6 +36,10 @@ #include "third_party/skia/include/effects/SkGradientShader.h" #include "third_party/skia/include/pathops/SkPathOps.h" +#ifdef _SKIA_SUPPORT_PATHS_ +#include "core/fxge/ge/cfx_cliprgn.h" +#endif // _SKIA_SUPPORT_PATHS_ + #ifdef _SKIA_SUPPORT_ #include "third_party/skia/include/core/SkColorFilter.h" #include "third_party/skia/include/core/SkColorPriv.h" @@ -112,7 +111,7 @@ void RgbByteOrderTransferBitmap(const CFX_RetainPtr& pBitmap, } } } else { - ASSERT(false); + NOTREACHED(); } return; } @@ -147,7 +146,7 @@ void RgbByteOrderTransferBitmap(const CFX_RetainPtr& pBitmap, return; } - ASSERT(false); + NOTREACHED(); } #endif // _SKIA_SUPPORT_PATHS_ -- cgit v1.2.3