From 27e35a861aac4652aa044ab3b3c4e1b0d620a5fc Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Wed, 16 Jul 2014 11:07:33 -0700 Subject: Remove uninitialized const global g_GbFontNameMap. C++11 makes uninitialized const PODs an error, because they contain uninitialized memory (they're uninitialized that can never be initialized (because they're const). In this case, the memory was only used by _GetSubFontName() if the lang parameter was 1, but _GetSubFontName() is only called from one place, with a lang parameter of 0. So remove _GetSubFontName()'s lang parameter too. (Using bsearch for searching an array that always has exactly 2 entries is overkill too, but I'm trying to keep the diff small.) No intended behavior change. Fixes this error on the clang/win bot: ..\..\third_party\pdfium\core\src\fxge\win32\fx_win32_device.cpp(207,20) : error(clang): default initialization of an object of const type 'const _FontNameMap [1]' const _FontNameMap g_GbFontNameMap[1]; ^ BUG=chromium:82385 R=bo_xu@foxitsoftware.com Review URL: https://codereview.chromium.org/369343003 --- core/src/fxge/win32/fx_win32_device.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'core') diff --git a/core/src/fxge/win32/fx_win32_device.cpp b/core/src/fxge/win32/fx_win32_device.cpp index 9c03a30837..044468ff05 100644 --- a/core/src/fxge/win32/fx_win32_device.cpp +++ b/core/src/fxge/win32/fx_win32_device.cpp @@ -204,23 +204,16 @@ const _FontNameMap g_JpFontNameMap[] = { {"MS Mincho", "Heiseimin-W3"}, {"MS Gothic", "Jun101-Light"}, }; -const _FontNameMap g_GbFontNameMap[1]; extern "C" { static int compareString(const void* key, const void* element) { return FXSYS_stricmp((FX_LPCSTR)key, ((_FontNameMap*)element)->m_pSrcFontName); } } -FX_BOOL _GetSubFontName(CFX_ByteString& name, int lang) +FX_BOOL _GetSubFontName(CFX_ByteString& name) { int size = sizeof g_JpFontNameMap; void* pFontnameMap = (void*)g_JpFontNameMap; - if (lang == 1) { - size = sizeof g_GbFontNameMap; - pFontnameMap = (void*)g_GbFontNameMap; - } else if (lang == 2) { - size = 0; - } _FontNameMap* found = (_FontNameMap*)FXSYS_bsearch((FX_LPCSTR)name, pFontnameMap, size / sizeof (_FontNameMap), sizeof (_FontNameMap), compareString); if (found == NULL) { @@ -280,7 +273,7 @@ void CWin32FontInfo::GetJapanesePreference(CFX_ByteString& face, int weight, int } return; } - if (_GetSubFontName(face, 0)) { + if (_GetSubFontName(face)) { return; } if (!(picth_family & FF_ROMAN) && weight > 400) { -- cgit v1.2.3