diff --git a/include/qpdf/ClosedFileInputSource.hh b/include/qpdf/ClosedFileInputSource.hh index b5d7e33..f93764d 100644 --- a/include/qpdf/ClosedFileInputSource.hh +++ b/include/qpdf/ClosedFileInputSource.hh @@ -69,9 +69,9 @@ class QPDF_DLL_CLASS ClosedFileInputSource: public InputSource void after(); std::string filename; - qpdf_offset_t offset; + qpdf_offset_t offset{0}; std::shared_ptr fis; - bool stay_open; + bool stay_open{false}; }; #endif // QPDF_CLOSEDFILEINPUTSOURCE_HH diff --git a/include/qpdf/QPDFAcroFormDocumentHelper.hh b/include/qpdf/QPDFAcroFormDocumentHelper.hh index 248525a..db75226 100644 --- a/include/qpdf/QPDFAcroFormDocumentHelper.hh +++ b/include/qpdf/QPDFAcroFormDocumentHelper.hh @@ -234,10 +234,10 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper ~Members() = default; private: - Members(); + Members() = default; Members(Members const&) = delete; - bool cache_valid; + bool cache_valid{false}; std::map> field_to_annotations; std::map annotation_to_field; std::map field_to_name; diff --git a/libqpdf/AES_PDF_native.cc b/libqpdf/AES_PDF_native.cc index 42f1cda..8808d20 100644 --- a/libqpdf/AES_PDF_native.cc +++ b/libqpdf/AES_PDF_native.cc @@ -17,8 +17,7 @@ AES_PDF_native::AES_PDF_native( unsigned char* cbc_block) : encrypt(encrypt), cbc_mode(cbc_mode), - cbc_block(cbc_block), - nrounds(0) + cbc_block(cbc_block) { size_t keybits = 8 * key_bytes; this->key = std::make_unique(key_bytes); diff --git a/libqpdf/BitWriter.cc b/libqpdf/BitWriter.cc index 2558592..c77eece 100644 --- a/libqpdf/BitWriter.cc +++ b/libqpdf/BitWriter.cc @@ -5,9 +5,7 @@ #include BitWriter::BitWriter(Pipeline* pl) : - pl(pl), - ch(0), - bit_offset(7) + pl(pl) { } diff --git a/libqpdf/ClosedFileInputSource.cc b/libqpdf/ClosedFileInputSource.cc index 2a6cb89..5995906 100644 --- a/libqpdf/ClosedFileInputSource.cc +++ b/libqpdf/ClosedFileInputSource.cc @@ -3,9 +3,7 @@ #include ClosedFileInputSource::ClosedFileInputSource(char const* filename) : - filename(filename), - offset(0), - stay_open(false) + filename(filename) { } diff --git a/libqpdf/ContentNormalizer.cc b/libqpdf/ContentNormalizer.cc index 6ec6cf9..03496d4 100644 --- a/libqpdf/ContentNormalizer.cc +++ b/libqpdf/ContentNormalizer.cc @@ -5,12 +5,6 @@ using namespace qpdf; -ContentNormalizer::ContentNormalizer() : - any_bad_tokens(false), - last_token_was_bad(false) -{ -} - void ContentNormalizer::handleToken(QPDFTokenizer::Token const& token) { diff --git a/libqpdf/InsecureRandomDataProvider.cc b/libqpdf/InsecureRandomDataProvider.cc index 1c7fb9e..5c317e7 100644 --- a/libqpdf/InsecureRandomDataProvider.cc +++ b/libqpdf/InsecureRandomDataProvider.cc @@ -4,11 +4,6 @@ #include #include -InsecureRandomDataProvider::InsecureRandomDataProvider() : - seeded_random(false) -{ -} - void InsecureRandomDataProvider::provideRandomData(unsigned char* data, size_t len) { diff --git a/libqpdf/NNTree.cc b/libqpdf/NNTree.cc index fd7d437..210b8db 100644 --- a/libqpdf/NNTree.cc +++ b/libqpdf/NNTree.cc @@ -28,8 +28,7 @@ error(QPDF& qpdf, QPDFObjectHandle& node, std::string const& msg) } NNTreeIterator::NNTreeIterator(NNTreeImpl& impl) : - impl(impl), - item_number(-1) + impl(impl) { } @@ -666,7 +665,6 @@ NNTreeImpl::NNTreeImpl( NNTreeDetails const& details, QPDF& qpdf, QPDFObjectHandle& oh, bool auto_repair) : details(details), qpdf(qpdf), - split_threshold(32), oh(oh), auto_repair(auto_repair) { diff --git a/libqpdf/Pl_SHA2.cc b/libqpdf/Pl_SHA2.cc index 090d778..9514d1c 100644 --- a/libqpdf/Pl_SHA2.cc +++ b/libqpdf/Pl_SHA2.cc @@ -5,8 +5,7 @@ #include Pl_SHA2::Pl_SHA2(int bits, Pipeline* next) : - Pipeline("sha2", next), - in_progress(false) + Pipeline("sha2", next) { if (bits) { resetBits(bits); diff --git a/libqpdf/QPDFAcroFormDocumentHelper.cc b/libqpdf/QPDFAcroFormDocumentHelper.cc index 5c513c3..aa54d81 100644 --- a/libqpdf/QPDFAcroFormDocumentHelper.cc +++ b/libqpdf/QPDFAcroFormDocumentHelper.cc @@ -9,11 +9,6 @@ using namespace qpdf; -QPDFAcroFormDocumentHelper::Members::Members() : - cache_valid(false) -{ -} - QPDFAcroFormDocumentHelper::QPDFAcroFormDocumentHelper(QPDF& qpdf) : QPDFDocumentHelper(qpdf), m(new Members()) diff --git a/libqpdf/QPDFArgParser.cc b/libqpdf/QPDFArgParser.cc index 9490fa5..18cb501 100644 --- a/libqpdf/QPDFArgParser.cc +++ b/libqpdf/QPDFArgParser.cc @@ -18,12 +18,7 @@ QPDFArgParser::Members::Members(int argc, char const* const argv[], char const* argc(argc), argv(argv), - progname_env(progname_env), - cur_arg(0), - bash_completion(false), - zsh_completion(false), - option_table(nullptr), - final_check_handler(nullptr) + progname_env(progname_env) { auto tmp = QUtil::make_unique_cstr(argv[0]); whoami = QUtil::getWhoami(tmp.get()); diff --git a/libqpdf/ResourceFinder.cc b/libqpdf/ResourceFinder.cc index 798fe67..06d37e1 100644 --- a/libqpdf/ResourceFinder.cc +++ b/libqpdf/ResourceFinder.cc @@ -1,10 +1,5 @@ #include -ResourceFinder::ResourceFinder() : - last_name_offset(0) -{ -} - void ResourceFinder::handleObject(QPDFObjectHandle obj, size_t offset, size_t) { diff --git a/libqpdf/qpdf/AES_PDF_native.hh b/libqpdf/qpdf/AES_PDF_native.hh index 0b93203..527e8cb 100644 --- a/libqpdf/qpdf/AES_PDF_native.hh +++ b/libqpdf/qpdf/AES_PDF_native.hh @@ -25,7 +25,7 @@ class AES_PDF_native unsigned char* cbc_block; std::unique_ptr key; std::unique_ptr rk; - unsigned int nrounds; + unsigned int nrounds{0}; }; #endif // AES_PDF_NATIVE_HH diff --git a/libqpdf/qpdf/BitWriter.hh b/libqpdf/qpdf/BitWriter.hh index 24c7416..9b8e2bc 100644 --- a/libqpdf/qpdf/BitWriter.hh +++ b/libqpdf/qpdf/BitWriter.hh @@ -21,8 +21,8 @@ class BitWriter private: Pipeline* pl; - unsigned char ch; - size_t bit_offset; + unsigned char ch{0}; + size_t bit_offset{7}; }; #endif // BITWRITER_HH diff --git a/libqpdf/qpdf/ContentNormalizer.hh b/libqpdf/qpdf/ContentNormalizer.hh index 930cf14..7c3b6d2 100644 --- a/libqpdf/qpdf/ContentNormalizer.hh +++ b/libqpdf/qpdf/ContentNormalizer.hh @@ -6,7 +6,7 @@ class ContentNormalizer final: public QPDFObjectHandle::TokenFilter { public: - ContentNormalizer(); + ContentNormalizer() = default; ~ContentNormalizer() final = default; void handleToken(QPDFTokenizer::Token const&) final; @@ -22,8 +22,8 @@ class ContentNormalizer final: public QPDFObjectHandle::TokenFilter } private: - bool any_bad_tokens; - bool last_token_was_bad; + bool any_bad_tokens{false}; + bool last_token_was_bad{false}; }; #endif // CONTENTNORMALIZER_HH diff --git a/libqpdf/qpdf/InsecureRandomDataProvider.hh b/libqpdf/qpdf/InsecureRandomDataProvider.hh index bab4e00..b9870d1 100644 --- a/libqpdf/qpdf/InsecureRandomDataProvider.hh +++ b/libqpdf/qpdf/InsecureRandomDataProvider.hh @@ -3,18 +3,18 @@ #include -class InsecureRandomDataProvider: public RandomDataProvider +class InsecureRandomDataProvider final: public RandomDataProvider { public: - InsecureRandomDataProvider(); - ~InsecureRandomDataProvider() override = default; - void provideRandomData(unsigned char* data, size_t len) override; + InsecureRandomDataProvider() = default; + ~InsecureRandomDataProvider() final = default; + void provideRandomData(unsigned char* data, size_t len) final; static RandomDataProvider* getInstance(); private: long random(); - bool seeded_random; + bool seeded_random{false}; }; #endif // INSECURERANDOMDATAPROVIDER_HH diff --git a/libqpdf/qpdf/NNTree.hh b/libqpdf/qpdf/NNTree.hh index 4b5ba20..e62e959 100644 --- a/libqpdf/qpdf/NNTree.hh +++ b/libqpdf/qpdf/NNTree.hh @@ -84,7 +84,7 @@ class NNTreeIterator NNTreeImpl& impl; std::list path; QPDFObjectHandle node; - int item_number; + int item_number{-1}; value_type ivalue; }; @@ -123,7 +123,7 @@ class NNTreeImpl NNTreeDetails const& details; QPDF& qpdf; - int split_threshold; + int split_threshold{32}; QPDFObjectHandle oh; bool auto_repair; }; diff --git a/libqpdf/qpdf/Pl_SHA2.hh b/libqpdf/qpdf/Pl_SHA2.hh index ee4c5c1..e3d924b 100644 --- a/libqpdf/qpdf/Pl_SHA2.hh +++ b/libqpdf/qpdf/Pl_SHA2.hh @@ -25,7 +25,7 @@ class Pl_SHA2 final: public Pipeline std::string getRawDigest(); private: - bool in_progress; + bool in_progress{false}; std::shared_ptr crypto; }; diff --git a/libqpdf/qpdf/QPDFArgParser.hh b/libqpdf/qpdf/QPDFArgParser.hh index f5c9620..7e4c92e 100644 --- a/libqpdf/qpdf/QPDFArgParser.hh +++ b/libqpdf/qpdf/QPDFArgParser.hh @@ -206,9 +206,9 @@ class QPDFArgParser char const* const* argv; std::string whoami; std::string progname_env; - int cur_arg; - bool bash_completion; - bool zsh_completion; + int cur_arg{0}; + bool bash_completion{false}; + bool zsh_completion{false}; std::string bash_prev; std::string bash_cur; std::string bash_line; @@ -216,9 +216,9 @@ class QPDFArgParser std::map option_tables; option_table_t main_option_table; option_table_t help_option_table; - option_table_t* option_table; + option_table_t* option_table{nullptr}; std::string option_table_name; - bare_arg_handler_t final_check_handler; + bare_arg_handler_t final_check_handler{nullptr}; std::vector new_argv; std::vector bash_argv; std::vector argv_ph; diff --git a/libqpdf/qpdf/QPDFCrypto_native.hh b/libqpdf/qpdf/QPDFCrypto_native.hh index 4dd6362..9ac0d75 100644 --- a/libqpdf/qpdf/QPDFCrypto_native.hh +++ b/libqpdf/qpdf/QPDFCrypto_native.hh @@ -8,37 +8,37 @@ #include #include -class QPDFCrypto_native: public QPDFCryptoImpl +class QPDFCrypto_native final: public QPDFCryptoImpl { public: QPDFCrypto_native() = default; - virtual ~QPDFCrypto_native() = default; + ~QPDFCrypto_native() final = default; - virtual void provideRandomData(unsigned char* data, size_t len); + void provideRandomData(unsigned char* data, size_t len) final; - virtual void MD5_init(); - virtual void MD5_update(unsigned char const* data, size_t len); - virtual void MD5_finalize(); - virtual void MD5_digest(MD5_Digest); + void MD5_init() final; + void MD5_update(unsigned char const* data, size_t len) final; + void MD5_finalize() final; + void MD5_digest(MD5_Digest) final; - virtual void RC4_init(unsigned char const* key_data, int key_len = -1); - virtual void RC4_process(unsigned char const* in_data, size_t len, unsigned char* out_data = 0); - virtual void RC4_finalize(); + void RC4_init(unsigned char const* key_data, int key_len = -1) final; + void RC4_process(unsigned char const* in_data, size_t len, unsigned char* out_data = 0) final; + void RC4_finalize() final; - virtual void SHA2_init(int bits); - virtual void SHA2_update(unsigned char const* data, size_t len); - virtual void SHA2_finalize(); - virtual std::string SHA2_digest(); + void SHA2_init(int bits) final; + void SHA2_update(unsigned char const* data, size_t len) final; + void SHA2_finalize() final; + std::string SHA2_digest() final; - virtual void rijndael_init( + void rijndael_init( bool encrypt, unsigned char const* key_data, size_t key_len, bool cbc_mode, - unsigned char* cbc_block); - virtual void rijndael_process(unsigned char* in_data, unsigned char* out_data); - virtual void rijndael_finalize(); + unsigned char* cbc_block) final; + void rijndael_process(unsigned char* in_data, unsigned char* out_data) final; + void rijndael_finalize() final; private: std::shared_ptr md5; diff --git a/libqpdf/qpdf/ResourceFinder.hh b/libqpdf/qpdf/ResourceFinder.hh index 1c4c59a..04614d7 100644 --- a/libqpdf/qpdf/ResourceFinder.hh +++ b/libqpdf/qpdf/ResourceFinder.hh @@ -3,20 +3,20 @@ #include -class ResourceFinder: public QPDFObjectHandle::ParserCallbacks +class ResourceFinder final: public QPDFObjectHandle::ParserCallbacks { public: - ResourceFinder(); - ~ResourceFinder() override = default; - void handleObject(QPDFObjectHandle, size_t, size_t) override; - void handleEOF() override; + ResourceFinder() = default; + ~ResourceFinder() final = default; + void handleObject(QPDFObjectHandle, size_t, size_t) final; + void handleEOF() final; std::set const& getNames() const; std::map>> const& getNamesByResourceType() const; private: std::string last_name; - size_t last_name_offset; + size_t last_name_offset{0}; std::set names; std::map>> names_by_resource_type; };