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.
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 ff1f6c4..3d12ee9 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::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 34d918b..d4e3830 100644
--- a/core/src/fxcrt/fxcrt_windows.cpp
+++ b/core/src/fxcrt/fxcrt_windows.cpp
@@ -98,7 +98,7 @@
if (!m_hFile) {
return 0;
}
- LARGE_INTEGER size = {0, 0};
+ LARGE_INTEGER size = {};
if (!::GetFileSizeEx(m_hFile, &size)) {
return 0;
}
@@ -109,8 +109,8 @@
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 @@
}
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 d3aa8c5..988d7f4 100644
--- a/fpdfsdk/src/fpdf_flatten.cpp
+++ b/fpdfsdk/src/fpdf_flatten.cpp
@@ -410,7 +410,7 @@
{
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 22e1c6d..c4f0309 100644
--- a/fpdfsdk/src/javascript/util.cpp
+++ b/fpdfsdk/src/javascript/util.cpp
@@ -303,7 +303,7 @@
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 @@
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 @@
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 @@
}
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 da33f80..5147266 100644
--- a/samples/pdfium_test.cc
+++ b/samples/pdfium_test.cc
@@ -215,7 +215,7 @@
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
@@ -224,7 +224,7 @@
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 5e7dd5f..37e30ce 100644
--- a/third_party/BUILD.gn
+++ b/third_party/BUILD.gn
@@ -95,10 +95,18 @@
}
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 3446439..79368b5 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',