summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2015-07-01 14:08:08 -0700
committerNico Weber <thakis@chromium.org>2015-07-01 14:11:22 -0700
commit2827bddd85edd37a9af6fb4e47882334f007e59b (patch)
treefa1bac0681681b5dc31997a23a15d01ad377b040
parent606346f584700bdae0741066f2e6d2481744032c (diff)
downloadpdfium-2827bddd85edd37a9af6fb4e47882334f007e59b.tar.xz
Cherry-pick to XFA: Fix some clang warnings with -Wmissing-braces in pdfium.
Clang warns if there are missing braces around a subobject initializer. The most common idiom that triggers this is: STRUCT s = {0}; if the first field of STRUCT is itself a struct. This can be more simply written as: STRUCT s = {}; which also prevents the warning from firing. Other instances of the warning have been fixed by adding braces where appropriate. R=brucedawson@chromium.org Review URL: https://codereview.chromium.org/1213523004.
-rw-r--r--core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp2
-rw-r--r--core/src/fxcrt/fxcrt_windows.cpp8
-rw-r--r--fpdfsdk/src/fpdf_flatten.cpp2
-rw-r--r--fpdfsdk/src/javascript/util.cpp8
-rw-r--r--samples/pdfium_test.cc4
-rw-r--r--third_party/BUILD.gn8
-rw-r--r--third_party/third_party.gyp5
7 files changed, 25 insertions, 12 deletions
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 ff1f6c4aa0..3d12ee9c82 100644
--- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old.cpp
@@ -154,7 +154,7 @@ void CPDF_StreamContentParser::Handle_BeginImage()
}
void CPDF_StreamContentParser::ParsePathObject()
{
- FX_FLOAT params[6] = {0};
+ FX_FLOAT params[6] = {};
int nParams = 0;
int last_pos = m_pSyntax->GetPos();
while (1) {
diff --git a/core/src/fxcrt/fxcrt_windows.cpp b/core/src/fxcrt/fxcrt_windows.cpp
index e3dff04413..43765a7bdd 100644
--- a/core/src/fxcrt/fxcrt_windows.cpp
+++ b/core/src/fxcrt/fxcrt_windows.cpp
@@ -98,7 +98,7 @@ FX_FILESIZE CFXCRT_FileAccess_Win64::GetSize() const
if (!m_hFile) {
return 0;
}
- LARGE_INTEGER size = {0, 0};
+ LARGE_INTEGER size = {};
if (!::GetFileSizeEx(m_hFile, &size)) {
return 0;
}
@@ -109,8 +109,8 @@ FX_FILESIZE CFXCRT_FileAccess_Win64::GetPosition() const
if (!m_hFile) {
return (FX_FILESIZE) - 1;
}
- LARGE_INTEGER dist = {0, 0};
- LARGE_INTEGER newPos = {0, 0};
+ LARGE_INTEGER dist = {};
+ LARGE_INTEGER newPos = {};
if (!::SetFilePointerEx(m_hFile, dist, &newPos, FILE_CURRENT)) {
return (FX_FILESIZE) - 1;
}
@@ -123,7 +123,7 @@ FX_FILESIZE CFXCRT_FileAccess_Win64::SetPosition(FX_FILESIZE pos)
}
LARGE_INTEGER dist;
dist.QuadPart = pos;
- LARGE_INTEGER newPos = {0, 0};
+ LARGE_INTEGER newPos = {};
if (!::SetFilePointerEx(m_hFile, dist, &newPos, FILE_BEGIN)) {
return (FX_FILESIZE) - 1;
}
diff --git a/fpdfsdk/src/fpdf_flatten.cpp b/fpdfsdk/src/fpdf_flatten.cpp
index b9edef9941..9ef6117fe2 100644
--- a/fpdfsdk/src/fpdf_flatten.cpp
+++ b/fpdfsdk/src/fpdf_flatten.cpp
@@ -419,7 +419,7 @@ DLLEXPORT int STDCALL FPDFPage_Flatten( FPDF_PAGE page, int nFlag)
{
for (int iKey = 0; /*iKey < 100*/; iKey++)
{
- char sExtend[5] = {0};
+ char sExtend[5] = {};
FXSYS_itoa(iKey, sExtend, 10);
key = CFX_ByteString("FFT") + CFX_ByteString(sExtend);
diff --git a/fpdfsdk/src/javascript/util.cpp b/fpdfsdk/src/javascript/util.cpp
index 22e1c6dd99..c4f03093a7 100644
--- a/fpdfsdk/src/javascript/util.cpp
+++ b/fpdfsdk/src/javascript/util.cpp
@@ -303,7 +303,7 @@ FX_BOOL util::printd(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value&
iMin = jsDate.GetMinutes();
iSec = jsDate.GetSeconds();
- struct tm time = {0};
+ struct tm time = {};
time.tm_year = iYear-1900;
time.tm_mon = iMonth;
time.tm_mday = iDay;
@@ -360,7 +360,7 @@ FX_BOOL util::printd(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value&
CFX_WideString strFormat;
// strFormat.Format(L"%d,%d,%d,%d,%d,%d",iYear, iMonth, iDay, iHour, iMin, iSec);
// CString strFormat = cppTm.Format(cFormat.c_str());
- wchar_t buf[64] = {0};
+ wchar_t buf[64] = {};
strFormat = wcsftime(buf, 64, cFormat.c_str(), &time);
cFormat = buf;
vRet = cFormat.c_str();
@@ -399,7 +399,7 @@ void util::printd(const std::wstring &cFormat2, CJS_Date jsDate, bool bXFAPictur
iMin = jsDate.GetMinutes();
iSec = jsDate.GetSeconds();
- struct tm time = {0};
+ struct tm time = {};
time.tm_year = iYear-1900;
time.tm_mon = iMonth;
time.tm_mday = iDay;
@@ -454,7 +454,7 @@ void util::printd(const std::wstring &cFormat2, CJS_Date jsDate, bool bXFAPictur
}
CFX_WideString strFormat;
- wchar_t buf[64] = {0};
+ wchar_t buf[64] = {};
strFormat = wcsftime(buf, 64, cFormat.c_str(), &time);
cFormat = buf;
cPurpose = cFormat;
diff --git a/samples/pdfium_test.cc b/samples/pdfium_test.cc
index 7c6b8b965d..417bd5603b 100644
--- a/samples/pdfium_test.cc
+++ b/samples/pdfium_test.cc
@@ -216,7 +216,7 @@ static void WriteBmp(const char* pdf_name, int num, const void* buffer,
if (!fp)
return;
- BITMAPINFO bmi = {0};
+ BITMAPINFO bmi = {};
bmi.bmiHeader.biSize = sizeof(bmi) - sizeof(RGBQUAD);
bmi.bmiHeader.biWidth = width;
bmi.bmiHeader.biHeight = -height; // top-down image
@@ -225,7 +225,7 @@ static void WriteBmp(const char* pdf_name, int num, const void* buffer,
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = 0;
- BITMAPFILEHEADER file_header = {0};
+ BITMAPFILEHEADER file_header = {};
file_header.bfType = 0x4d42;
file_header.bfSize = sizeof(file_header) + bmi.bmiHeader.biSize + out_len;
file_header.bfOffBits = file_header.bfSize - out_len;
diff --git a/third_party/BUILD.gn b/third_party/BUILD.gn
index 549df8a3ae..44d5e75831 100644
--- a/third_party/BUILD.gn
+++ b/third_party/BUILD.gn
@@ -95,10 +95,18 @@ source_set("fx_agg") {
}
source_set("fx_lcms2") {
+ config("fx_lcms2_warnings") {
+ if (is_clang) {
+ # cmslut.cc is sloppy with aggregate initialization. Version 2.7 of this
+ # library doesn't appear to have this problem.
+ cflags = [ "-Wno-missing-braces" ]
+ }
+ }
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [
"//build/config/compiler:no_chromium_code",
"//third_party/pdfium:pdfium_config",
+ ":fx_lcms2_warnings",
]
sources = [
"lcms2-2.6/include/lcms2.h",
diff --git a/third_party/third_party.gyp b/third_party/third_party.gyp
index ff657719f6..98ec814b9d 100644
--- a/third_party/third_party.gyp
+++ b/third_party/third_party.gyp
@@ -137,6 +137,11 @@
],
}],
],
+ 'variables': {
+ 'clang_warning_flags': [
+ '-Wno-missing-braces',
+ ],
+ },
},
{
'target_name': 'fx_libjpeg',