From 375a86403b7fa8d17d7b142c270e2d8e33bb924f Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Mon, 11 Jan 2016 11:59:17 -0800 Subject: Merge to XFA: Switch most min/max macros to std::min/max. Fix lint errors along the way. R=tsepez@chromium.org TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1567343002 . (cherry picked from commit 9adfbb0920a258e916003b1ee9515e97879db82a) Review URL: https://codereview.chromium.org/1577503002 . --- core/src/fxcodec/lbmp/fx_bmp.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'core/src/fxcodec/lbmp') diff --git a/core/src/fxcodec/lbmp/fx_bmp.cpp b/core/src/fxcodec/lbmp/fx_bmp.cpp index 98bcefdaba..00477581a1 100644 --- a/core/src/fxcodec/lbmp/fx_bmp.cpp +++ b/core/src/fxcodec/lbmp/fx_bmp.cpp @@ -5,6 +5,16 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "fx_bmp.h" + +#include + +namespace { + +const size_t kBmpCoreHeaderSize = 12; +const size_t kBmpInfoHeaderSize = 40; + +} // namespace + FX_DWORD _GetDWord_LSBFirst(uint8_t* p) { return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); } @@ -80,10 +90,12 @@ int32_t _bmp_read_header(bmp_decompress_struct_p bmp_ptr) { bmp_ptr->img_ifh_size = _GetDWord_LSBFirst(bmp_ptr->next_in + bmp_ptr->skip_size); bmp_ptr->pal_type = 0; - ASSERT(sizeof(BmpCoreHeader) == 12); - ASSERT(sizeof(BmpInfoHeader) == 40); + static_assert(sizeof(BmpCoreHeader) == kBmpCoreHeaderSize, + "BmpCoreHeader has wrong size"); + static_assert(sizeof(BmpInfoHeader) == kBmpInfoHeaderSize, + "BmpInfoHeader has wrong size"); switch (bmp_ptr->img_ifh_size) { - case FX_MIN(12, sizeof(BmpCoreHeader)): { + case kBmpCoreHeaderSize: { bmp_ptr->pal_type = 1; BmpCoreHeaderPtr bmp_core_header_ptr = NULL; if (_bmp_read_data(bmp_ptr, (uint8_t**)&bmp_core_header_ptr, @@ -100,7 +112,7 @@ int32_t _bmp_read_header(bmp_decompress_struct_p bmp_ptr) { bmp_ptr->compress_flag = BMP_RGB; bmp_ptr->imgTB_flag = FALSE; } break; - case FX_MIN(40, sizeof(BmpInfoHeader)): { + case kBmpInfoHeaderSize: { BmpInfoHeaderPtr bmp_info_header_ptr = NULL; if (_bmp_read_data(bmp_ptr, (uint8_t**)&bmp_info_header_ptr, bmp_ptr->img_ifh_size) == NULL) { @@ -127,7 +139,8 @@ int32_t _bmp_read_header(bmp_decompress_struct_p bmp_ptr) { } } break; default: { - if (bmp_ptr->img_ifh_size > FX_MIN(40, sizeof(BmpInfoHeader))) { + if (bmp_ptr->img_ifh_size > + std::min(kBmpInfoHeaderSize, sizeof(BmpInfoHeader))) { BmpInfoHeaderPtr bmp_info_header_ptr = NULL; if (_bmp_read_data(bmp_ptr, (uint8_t**)&bmp_info_header_ptr, bmp_ptr->img_ifh_size) == NULL) { -- cgit v1.2.3