fix some clang-tidy member init suggestions.
Change-Id: Iebf251c519989e23a995ecf93abe008ab54b85ad
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/101250
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fpdfapi/font/cfx_cttgsubtable.h b/core/fpdfapi/font/cfx_cttgsubtable.h
index 861d4c3..0555333 100644
--- a/core/fpdfapi/font/cfx_cttgsubtable.h
+++ b/core/fpdfapi/font/cfx_cttgsubtable.h
@@ -102,7 +102,7 @@
TSubTable1();
~TSubTable1() override;
- int16_t DeltaGlyphID;
+ int16_t DeltaGlyphID = 0;
};
struct TSubTable2 final : public TSubTableBase {
diff --git a/core/fpdfapi/font/cpdf_cmapparser.h b/core/fpdfapi/font/cpdf_cmapparser.h
index cfcd9ca..9219814 100644
--- a/core/fpdfapi/font/cpdf_cmapparser.h
+++ b/core/fpdfapi/font/cpdf_cmapparser.h
@@ -54,7 +54,7 @@
std::vector<CPDF_CMap::CodeRange> m_PendingRanges;
std::vector<CPDF_CMap::CIDRange> m_AdditionalCharcodeToCIDMappings;
ByteString m_LastWord;
- uint32_t m_CodePoints[4];
+ uint32_t m_CodePoints[4] = {};
};
#endif // CORE_FPDFAPI_FONT_CPDF_CMAPPARSER_H_
diff --git a/core/fpdfapi/font/cpdf_fontencoding.cpp b/core/fpdfapi/font/cpdf_fontencoding.cpp
index 1861b1c..ff2baed 100644
--- a/core/fpdfapi/font/cpdf_fontencoding.cpp
+++ b/core/fpdfapi/font/cpdf_fontencoding.cpp
@@ -1669,8 +1669,6 @@
if (pSrc) {
for (size_t i = 0; i < std::size(m_Unicodes); i++)
m_Unicodes[i] = pSrc[i];
- } else {
- memset(m_Unicodes, 0, sizeof(m_Unicodes));
}
}
diff --git a/core/fpdfapi/font/cpdf_fontencoding.h b/core/fpdfapi/font/cpdf_fontencoding.h
index 06e0561..272c8a6 100644
--- a/core/fpdfapi/font/cpdf_fontencoding.h
+++ b/core/fpdfapi/font/cpdf_fontencoding.h
@@ -53,7 +53,7 @@
RetainPtr<CPDF_Object> Realize(WeakPtr<ByteStringPool> pPool) const;
private:
- wchar_t m_Unicodes[kEncodingTableSize];
+ wchar_t m_Unicodes[kEncodingTableSize] = {};
};
#endif // CORE_FPDFAPI_FONT_CPDF_FONTENCODING_H_
diff --git a/core/fpdfapi/page/cpdf_colorspace.cpp b/core/fpdfapi/page/cpdf_colorspace.cpp
index ccb6f53..7fbf99a 100644
--- a/core/fpdfapi/page/cpdf_colorspace.cpp
+++ b/core/fpdfapi/page/cpdf_colorspace.cpp
@@ -173,8 +173,8 @@
float m_WhitePoint[kBlackWhitePointCount] = {1.0f, 1.0f, 1.0f};
float m_BlackPoint[kBlackWhitePointCount] = {0.0f, 0.0f, 0.0f};
- float m_Gamma[kGammaCount];
- float m_Matrix[kMatrixCount];
+ float m_Gamma[kGammaCount] = {};
+ float m_Matrix[kMatrixCount] = {};
bool m_bHasGamma = false;
bool m_bHasMatrix = false;
};
@@ -210,7 +210,7 @@
float m_WhitePoint[kBlackWhitePointCount] = {1.0f, 1.0f, 1.0f};
float m_BlackPoint[kBlackWhitePointCount] = {0.0f, 0.0f, 0.0f};
- float m_Ranges[kRangesCount];
+ float m_Ranges[kRangesCount] = {};
};
class CPDF_ICCBasedCS final : public CPDF_BasedCS {
@@ -425,9 +425,7 @@
} // namespace
-PatternValue::PatternValue() {
- std::fill(std::begin(m_Comps), std::end(m_Comps), 0.0f);
-}
+PatternValue::PatternValue() = default;
PatternValue::PatternValue(const PatternValue& that) = default;
diff --git a/core/fpdfapi/page/cpdf_colorspace.h b/core/fpdfapi/page/cpdf_colorspace.h
index fff325f..23253c8 100644
--- a/core/fpdfapi/page/cpdf_colorspace.h
+++ b/core/fpdfapi/page/cpdf_colorspace.h
@@ -49,7 +49,7 @@
private:
RetainPtr<CPDF_Pattern> m_pRetainedPattern;
- std::array<float, kMaxPatternColorComps> m_Comps;
+ std::array<float, kMaxPatternColorComps> m_Comps{};
};
class CPDF_ColorSpace : public Retainable, public Observable {
diff --git a/core/fpdfapi/page/cpdf_dib.h b/core/fpdfapi/page/cpdf_dib.h
index 297f0aa..a24d192 100644
--- a/core/fpdfapi/page/cpdf_dib.h
+++ b/core/fpdfapi/page/cpdf_dib.h
@@ -73,8 +73,8 @@
JpxSMaskInlineData();
~JpxSMaskInlineData();
- int width;
- int height;
+ int width = 0;
+ int height = 0;
DataVector<uint8_t> data;
};
diff --git a/core/fpdfapi/page/cpdf_function.h b/core/fpdfapi/page/cpdf_function.h
index 0dfee4f..99d6d32 100644
--- a/core/fpdfapi/page/cpdf_function.h
+++ b/core/fpdfapi/page/cpdf_function.h
@@ -67,8 +67,8 @@
pdfium::span<float> results) const = 0;
const Type m_Type;
- uint32_t m_nInputs;
- uint32_t m_nOutputs;
+ uint32_t m_nInputs = 0;
+ uint32_t m_nOutputs = 0;
std::vector<float> m_Domains;
std::vector<float> m_Ranges;
};
diff --git a/core/fpdfapi/page/cpdf_psengine.h b/core/fpdfapi/page/cpdf_psengine.h
index 2409b06..d7f6f7e 100644
--- a/core/fpdfapi/page/cpdf_psengine.h
+++ b/core/fpdfapi/page/cpdf_psengine.h
@@ -127,7 +127,7 @@
uint32_t m_StackCount = 0;
CPDF_PSProc m_MainProc;
- float m_Stack[kPSEngineStackSize];
+ float m_Stack[kPSEngineStackSize] = {};
};
#endif // CORE_FPDFAPI_PAGE_CPDF_PSENGINE_H_
diff --git a/core/fpdfapi/page/cpdf_sampledfunc.h b/core/fpdfapi/page/cpdf_sampledfunc.h
index bd1457e..8ca7adb 100644
--- a/core/fpdfapi/page/cpdf_sampledfunc.h
+++ b/core/fpdfapi/page/cpdf_sampledfunc.h
@@ -48,8 +48,8 @@
private:
std::vector<SampleEncodeInfo> m_EncodeInfo;
std::vector<SampleDecodeInfo> m_DecodeInfo;
- uint32_t m_nBitsPerSample;
- uint32_t m_SampleMax;
+ uint32_t m_nBitsPerSample = 0;
+ uint32_t m_SampleMax = 0;
RetainPtr<CPDF_StreamAcc> m_pSampleStream;
};
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.h b/core/fpdfapi/page/cpdf_streamcontentparser.h
index 9eef8c3..d8abdc1 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.h
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.h
@@ -74,7 +74,7 @@
ContentParam();
~ContentParam();
- Type m_Type;
+ Type m_Type = Type::kObject;
FX_Number m_Number;
ByteString m_Name;
RetainPtr<CPDF_Object> m_pObject;
diff --git a/core/fpdfapi/page/cpdf_streamparser.h b/core/fpdfapi/page/cpdf_streamparser.h
index 136564e..1a0f115 100644
--- a/core/fpdfapi/page/cpdf_streamparser.h
+++ b/core/fpdfapi/page/cpdf_streamparser.h
@@ -54,7 +54,7 @@
WeakPtr<ByteStringPool> m_pPool;
RetainPtr<CPDF_Object> m_pLastObj;
pdfium::span<const uint8_t> m_pBuf;
- uint8_t m_WordBuffer[kMaxWordLength + 1]; // Include space for NUL.
+ uint8_t m_WordBuffer[kMaxWordLength + 1] = {}; // Include space for NUL.
};
#endif // CORE_FPDFAPI_PAGE_CPDF_STREAMPARSER_H_
diff --git a/core/fpdfapi/page/cpdf_tilingpattern.h b/core/fpdfapi/page/cpdf_tilingpattern.h
index 29d3b6e..519e457 100644
--- a/core/fpdfapi/page/cpdf_tilingpattern.h
+++ b/core/fpdfapi/page/cpdf_tilingpattern.h
@@ -42,8 +42,8 @@
bool m_bColored;
CFX_FloatRect m_BBox;
- float m_XStep;
- float m_YStep;
+ float m_XStep = 0.0f;
+ float m_YStep = 0.0f;
};
#endif // CORE_FPDFAPI_PAGE_CPDF_TILINGPATTERN_H_
diff --git a/core/fpdfapi/parser/cpdf_crypto_handler.h b/core/fpdfapi/parser/cpdf_crypto_handler.h
index cfd3bf1..b8f938c 100644
--- a/core/fpdfapi/parser/cpdf_crypto_handler.h
+++ b/core/fpdfapi/parser/cpdf_crypto_handler.h
@@ -59,7 +59,7 @@
const size_t m_KeyLen;
const Cipher m_Cipher;
std::unique_ptr<CRYPT_aes_context, FxFreeDeleter> m_pAESContext;
- uint8_t m_EncryptKey[32];
+ uint8_t m_EncryptKey[32] = {};
};
#endif // CORE_FPDFAPI_PARSER_CPDF_CRYPTO_HANDLER_H_
diff --git a/core/fpdfapi/parser/cpdf_parser.h b/core/fpdfapi/parser/cpdf_parser.h
index 4382743..5d036a2 100644
--- a/core/fpdfapi/parser/cpdf_parser.h
+++ b/core/fpdfapi/parser/cpdf_parser.h
@@ -189,7 +189,7 @@
// m_CrossRefTable must be destroyed after m_pSecurityHandler due to the
// ownership of the ID array data.
std::unique_ptr<CPDF_CrossRefTable> m_CrossRefTable;
- FX_FILESIZE m_LastXRefOffset;
+ FX_FILESIZE m_LastXRefOffset = 0;
ByteString m_Password;
std::unique_ptr<CPDF_LinearizedHeader> m_pLinearized;
diff --git a/core/fpdfapi/parser/cpdf_security_handler.h b/core/fpdfapi/parser/cpdf_security_handler.h
index 7fd3f89..300dd9b 100644
--- a/core/fpdfapi/parser/cpdf_security_handler.h
+++ b/core/fpdfapi/parser/cpdf_security_handler.h
@@ -90,7 +90,7 @@
ByteString m_FileId;
RetainPtr<const CPDF_Dictionary> m_pEncryptDict;
std::unique_ptr<CPDF_CryptoHandler> m_pCryptoHandler;
- uint8_t m_EncryptKey[32];
+ uint8_t m_EncryptKey[32] = {};
};
#endif // CORE_FPDFAPI_PARSER_CPDF_SECURITY_HANDLER_H_
diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.h b/core/fpdfapi/parser/cpdf_syntax_parser.h
index dfd5f5a..ed79af2 100644
--- a/core/fpdfapi/parser/cpdf_syntax_parser.h
+++ b/core/fpdfapi/parser/cpdf_syntax_parser.h
@@ -126,7 +126,7 @@
DataVector<uint8_t> m_pFileBuf;
FX_FILESIZE m_BufOffset = 0;
uint32_t m_WordSize = 0;
- uint8_t m_WordBuffer[257];
+ uint8_t m_WordBuffer[257] = {};
uint32_t m_ReadBufferSize = CPDF_Stream::kFileBufSize;
// The syntax parser records traversed trailer end byte offsets here.
diff --git a/core/fpdfapi/render/cpdf_renderoptions.h b/core/fpdfapi/render/cpdf_renderoptions.h
index 4197c0b..12eb91a 100644
--- a/core/fpdfapi/render/cpdf_renderoptions.h
+++ b/core/fpdfapi/render/cpdf_renderoptions.h
@@ -80,7 +80,7 @@
Type m_ColorMode = kNormal;
bool m_bDrawAnnots = false;
Options m_Options;
- ColorScheme m_ColorScheme;
+ ColorScheme m_ColorScheme = {};
RetainPtr<CPDF_OCContext> m_pOCContext;
};
diff --git a/core/fpdfdoc/cpdf_bafontmap.h b/core/fpdfdoc/cpdf_bafontmap.h
index 320353e..5cd4bcd 100644
--- a/core/fpdfdoc/cpdf_bafontmap.h
+++ b/core/fpdfdoc/cpdf_bafontmap.h
@@ -41,7 +41,7 @@
Data();
~Data();
- FX_Charset nCharset;
+ FX_Charset nCharset = FX_Charset::kANSI;
RetainPtr<CPDF_Font> pFont;
ByteString sFontName;
};
diff --git a/core/fxcodec/jbig2/JBig2_Context.h b/core/fxcodec/jbig2/JBig2_Context.h
index 8c8897e..279db5b 100644
--- a/core/fxcodec/jbig2/JBig2_Context.h
+++ b/core/fxcodec/jbig2/JBig2_Context.h
@@ -97,7 +97,7 @@
std::unique_ptr<CJBig2_GRDProc> m_pGRD;
std::unique_ptr<CJBig2_Segment> m_pSegment;
uint32_t m_nOffset = 0;
- JBig2RegionInfo m_ri;
+ JBig2RegionInfo m_ri = {};
UnownedPtr<std::list<CJBig2_CachePair>> const m_pSymbolDictCache;
};
diff --git a/core/fxcodec/jpx/cjpx_decoder.h b/core/fxcodec/jpx/cjpx_decoder.h
index bafad1d..ee8c9cd 100644
--- a/core/fxcodec/jpx/cjpx_decoder.h
+++ b/core/fxcodec/jpx/cjpx_decoder.h
@@ -71,7 +71,7 @@
UnownedPtr<opj_codec_t> m_Codec;
std::unique_ptr<DecodeData> m_DecodeData;
UnownedPtr<opj_stream_t> m_Stream;
- opj_dparameters_t m_Parameters;
+ opj_dparameters_t m_Parameters = {};
};
} // namespace fxcodec
diff --git a/core/fxcodec/png/png_decoder.cpp b/core/fxcodec/png/png_decoder.cpp
index 3e0a5a5..484658c 100644
--- a/core/fxcodec/png/png_decoder.cpp
+++ b/core/fxcodec/png/png_decoder.cpp
@@ -30,7 +30,7 @@
png_structp m_pPng = nullptr;
png_infop m_pInfo = nullptr;
UnownedPtr<PngDecoder::Delegate> const m_pDelegate;
- char m_szLastError[PNG_ERROR_SIZE];
+ char m_szLastError[PNG_ERROR_SIZE] = {};
};
extern "C" {
@@ -172,9 +172,7 @@
} // extern "C"
CPngContext::CPngContext(PngDecoder::Delegate* pDelegate)
- : m_pDelegate(pDelegate) {
- memset(m_szLastError, 0, sizeof(m_szLastError));
-}
+ : m_pDelegate(pDelegate) {}
CPngContext::~CPngContext() {
png_destroy_read_struct(m_pPng ? &m_pPng : nullptr,
diff --git a/core/fxcodec/progressive_decoder.h b/core/fxcodec/progressive_decoder.h
index 117f937..2f8d2ab 100644
--- a/core/fxcodec/progressive_decoder.h
+++ b/core/fxcodec/progressive_decoder.h
@@ -138,7 +138,7 @@
}
private:
- int m_ItemSize;
+ int m_ItemSize = 0;
DataVector<uint8_t> m_pWeightTables;
};
@@ -154,7 +154,7 @@
}
private:
- int m_ItemSize;
+ int m_ItemSize = 0;
DataVector<uint8_t> m_pWeightTables;
};
diff --git a/core/fxcrt/xml/cfx_xmldocument.cpp b/core/fxcrt/xml/cfx_xmldocument.cpp
index 6617780..f2c38da 100644
--- a/core/fxcrt/xml/cfx_xmldocument.cpp
+++ b/core/fxcrt/xml/cfx_xmldocument.cpp
@@ -8,9 +8,8 @@
#include "core/fxcrt/xml/cfx_xmlelement.h"
#include "core/fxcrt/xml/cfx_xmlinstruction.h"
-CFX_XMLDocument::CFX_XMLDocument() {
- root_ = CreateNode<CFX_XMLElement>(L"root");
-}
+CFX_XMLDocument::CFX_XMLDocument()
+ : root_(CreateNode<CFX_XMLElement>(L"root")) {}
CFX_XMLDocument::~CFX_XMLDocument() = default;
diff --git a/core/fxge/cfx_path.h b/core/fxge/cfx_path.h
index 364b8e3..5c6199c 100644
--- a/core/fxge/cfx_path.h
+++ b/core/fxge/cfx_path.h
@@ -31,8 +31,8 @@
}
CFX_PointF m_Point;
- Type m_Type;
- bool m_CloseFigure;
+ Type m_Type = Type::kLine;
+ bool m_CloseFigure = false;
};
CFX_Path();
diff --git a/core/fxge/dib/cstretchengine.h b/core/fxge/dib/cstretchengine.h
index 7ddd76b..50a344c 100644
--- a/core/fxge/dib/cstretchengine.h
+++ b/core/fxge/dib/cstretchengine.h
@@ -161,7 +161,7 @@
FXDIB_ResampleOptions m_ResampleOptions;
TransformMethod m_TransMethod;
State m_State = State::kInitial;
- int m_CurRow;
+ int m_CurRow = 0;
WeightTable m_WeightTable;
};
diff --git a/core/fxge/text_char_pos.h b/core/fxge/text_char_pos.h
index 2d499e0..0877a26 100644
--- a/core/fxge/text_char_pos.h
+++ b/core/fxge/text_char_pos.h
@@ -28,7 +28,7 @@
int32_t m_FallbackFontPosition = 0;
bool m_bGlyphAdjust = false;
bool m_bFontStyle = false;
- float m_AdjustMatrix[4];
+ float m_AdjustMatrix[4] = {};
};
#endif // CORE_FXGE_TEXT_CHAR_POS_H_
diff --git a/fpdfsdk/fpdf_ppo.cpp b/fpdfsdk/fpdf_ppo.cpp
index 8b16826..f0f62b8 100644
--- a/fpdfsdk/fpdf_ppo.cpp
+++ b/fpdfsdk/fpdf_ppo.cpp
@@ -41,7 +41,7 @@
#include "third_party/base/span.h"
struct XObjectContext {
- CPDF_Document* dest_doc;
+ UnownedPtr<CPDF_Document> dest_doc;
RetainPtr<CPDF_Stream> xobject;
};
@@ -52,7 +52,7 @@
// scaled down, and scale is in range of (0, 1) exclusive.
struct NupPageSettings {
CFX_PointF subPageStartPoint;
- float scale;
+ float scale = 0.0f;
};
// Calculates the N-up parameters. When importing multiple pages into one page.
diff --git a/fxjs/cfx_globaldata.h b/fxjs/cfx_globaldata.h
index bce77db..6b94265 100644
--- a/fxjs/cfx_globaldata.h
+++ b/fxjs/cfx_globaldata.h
@@ -33,7 +33,7 @@
~Element();
CFX_KeyValue data;
- bool bPersistent;
+ bool bPersistent = false;
};
static CFX_GlobalData* GetRetainedInstance(Delegate* pDelegate);
diff --git a/fxjs/cfx_keyvalue.h b/fxjs/cfx_keyvalue.h
index 97cbc1f..a6ff52a 100644
--- a/fxjs/cfx_keyvalue.h
+++ b/fxjs/cfx_keyvalue.h
@@ -28,8 +28,8 @@
~CFX_Value();
DataType nType = DataType::kNull;
- bool bData;
- double dData;
+ bool bData = false;
+ double dData = 0.0;
ByteString sData;
std::vector<std::unique_ptr<CFX_KeyValue>> objData;
};
diff --git a/fxjs/cjs_delaydata.h b/fxjs/cjs_delaydata.h
index 690cab8..861dbab 100644
--- a/fxjs/cjs_delaydata.h
+++ b/fxjs/cjs_delaydata.h
@@ -20,9 +20,9 @@
FIELD_PROP eProp;
int nControlIndex;
+ int32_t num = 0;
+ bool b = false;
WideString sFieldName;
- int32_t num;
- bool b;
ByteString bytestring;
WideString widestring;
CFX_FloatRect rect;
diff --git a/fxjs/cjs_global.cpp b/fxjs/cjs_global.cpp
index cc5997a..ffbbfcb 100644
--- a/fxjs/cjs_global.cpp
+++ b/fxjs/cjs_global.cpp
@@ -155,8 +155,8 @@
}
CJS_Global::CJS_Global(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime)
- : CJS_Object(pObject, pRuntime) {
- m_pGlobalData = CFX_GlobalData::GetRetainedInstance(nullptr);
+ : CJS_Object(pObject, pRuntime),
+ m_pGlobalData(CFX_GlobalData::GetRetainedInstance(nullptr)) {
UpdateGlobalPersistentVariables();
}
diff --git a/xfa/fde/cfde_textout.cpp b/xfa/fde/cfde_textout.cpp
index 04c564a..ef77b57 100644
--- a/xfa/fde/cfde_textout.cpp
+++ b/xfa/fde/cfde_textout.cpp
@@ -532,10 +532,8 @@
CFDE_TextOut::Line::Line() = default;
-CFDE_TextOut::Line::Line(const Line& that) {
- new_reload_ = that.new_reload_;
- pieces_ = that.pieces_;
-}
+CFDE_TextOut::Line::Line(const Line& that)
+ : new_reload_(that.new_reload_), pieces_(that.pieces_) {}
CFDE_TextOut::Line::~Line() = default;
diff --git a/xfa/fgas/crt/cfgas_decimal.cpp b/xfa/fgas/crt/cfgas_decimal.cpp
index acf1857..dfe5552 100644
--- a/xfa/fgas/crt/cfgas_decimal.cpp
+++ b/xfa/fgas/crt/cfgas_decimal.cpp
@@ -298,9 +298,6 @@
bool pointmet = false;
bool negmet = false;
uint8_t scale = 0;
- m_uHi = 0;
- m_uMid = 0;
- m_uLo = 0;
while (str != strBound && *str == ' ')
str++;
if (str != strBound && *str == '-') {
diff --git a/xfa/fgas/layout/cfgas_textpiece.h b/xfa/fgas/layout/cfgas_textpiece.h
index 9e6e727..5afc30a 100644
--- a/xfa/fgas/layout/cfgas_textpiece.h
+++ b/xfa/fgas/layout/cfgas_textpiece.h
@@ -22,11 +22,11 @@
WideString szText;
std::vector<int32_t> Widths;
- int32_t iChars;
- int32_t iHorScale;
- int32_t iVerScale;
- int32_t iBidiLevel;
- float fFontSize;
+ int32_t iChars = 0;
+ int32_t iHorScale = 0;
+ int32_t iVerScale = 0;
+ int32_t iBidiLevel = 0;
+ float fFontSize = 0.0f;
CFX_RectF rtPiece;
RetainPtr<CFGAS_GEFont> pFont;
};
diff --git a/xfa/fxfa/parser/cxfa_measurement.h b/xfa/fxfa/parser/cxfa_measurement.h
index a5725c2..1324a31 100644
--- a/xfa/fxfa/parser/cxfa_measurement.h
+++ b/xfa/fxfa/parser/cxfa_measurement.h
@@ -33,8 +33,8 @@
void SetString(WideStringView wsMeasure);
bool ToUnitInternal(XFA_Unit eUnit, float* fValue) const;
- float m_fValue;
- XFA_Unit m_eUnit;
+ float m_fValue = 0.0f;
+ XFA_Unit m_eUnit = XFA_Unit::Percent;
};
#endif // XFA_FXFA_PARSER_CXFA_MEASUREMENT_H_