diff --git a/.clang-tidy b/.clang-tidy index 897b30f2ab..4d9daefbad 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -9,6 +9,7 @@ Checks: [-*, modernize-redundant-void-arg, modernize-return-braced-init-list, modernize-use-bool-literals, + modernize-use-default-member-init, # Enable a very limited number of the cppcoreguidelines checkers. # See the notes for some of the rest of them below. diff --git a/src/Reassem.cc b/src/Reassem.cc index e4fdf7fd8c..7efa34b42d 100644 --- a/src/Reassem.cc +++ b/src/Reassem.cc @@ -243,12 +243,7 @@ uint64_t DataBlockList::Trim(uint64_t seq, uint64_t max_old, DataBlockList* old_ } Reassembler::Reassembler(uint64_t init_seq, ReassemblerType reassem_type) - : block_list(this), - old_block_list(this), - last_reassem_seq(init_seq), - trim_seq(init_seq), - max_old_blocks(0), - rtype(reassem_type) {} + : block_list(this), old_block_list(this), last_reassem_seq(init_seq), trim_seq(init_seq), rtype(reassem_type) {} void Reassembler::CheckOverlap(const DataBlockList& list, uint64_t seq, uint64_t len, const u_char* data) { if ( list.Empty() ) diff --git a/src/file_analysis/FileReassembler.cc b/src/file_analysis/FileReassembler.cc index 7745bcdc75..fae2626451 100644 --- a/src/file_analysis/FileReassembler.cc +++ b/src/file_analysis/FileReassembler.cc @@ -11,7 +11,7 @@ namespace zeek::file_analysis { class File; FileReassembler::FileReassembler(File* f, uint64_t starting_offset) - : Reassembler(starting_offset, REASSEM_FILE), the_file(f), flushing(false) {} + : Reassembler(starting_offset, REASSEM_FILE), the_file(f) {} uint64_t FileReassembler::Flush() { if ( flushing ) diff --git a/src/input/Manager.cc b/src/input/Manager.cc index 03e4b6bde0..94eae7490c 100644 --- a/src/input/Manager.cc +++ b/src/input/Manager.cc @@ -51,16 +51,16 @@ static void input_hash_delete_func(void* val) { class Manager::Stream { public: string name; - bool removed; + bool removed = false; StreamType stream_type; // to distinguish between event and table streams - EnumVal* type; - ReaderFrontend* reader; - TableVal* config; + EnumVal* type = nullptr; + ReaderFrontend* reader = nullptr; + TableVal* config = nullptr; EventHandlerPtr error_event; - RecordVal* description; + RecordVal* description = nullptr; virtual ~Stream(); @@ -68,8 +68,7 @@ protected: Stream(StreamType t); }; -Manager::Stream::Stream(StreamType t) - : name(), removed(), stream_type(t), type(), reader(), config(), error_event(), description() {} +Manager::Stream::Stream(StreamType t) : stream_type(t) {} Manager::Stream::~Stream() { Unref(type); @@ -80,18 +79,18 @@ Manager::Stream::~Stream() { class Manager::TableStream final : public Manager::Stream { public: - unsigned int num_idx_fields; - unsigned int num_val_fields; - bool want_record; + unsigned int num_idx_fields = 0; + unsigned int num_val_fields = 0; + bool want_record = false; - TableVal* tab; - RecordType* rtype; - RecordType* itype; + TableVal* tab = nullptr; + RecordType* rtype = nullptr; + RecordType* itype = nullptr; - PDict* currDict; - PDict* lastDict; + PDict* currDict = nullptr; + PDict* lastDict = nullptr; - Func* pred; + Func* pred = nullptr; EventHandlerPtr event; @@ -103,7 +102,7 @@ class Manager::EventStream final : public Manager::Stream { public: EventHandlerPtr event; - RecordType* fields; + RecordType* fields = nullptr; unsigned int num_fields; bool want_record; @@ -119,21 +118,9 @@ public: ~AnalysisStream() override = default; }; -Manager::TableStream::TableStream() - : Manager::Stream::Stream(TABLE_STREAM), - num_idx_fields(), - num_val_fields(), - want_record(), - tab(), - rtype(), - itype(), - currDict(), - lastDict(), - pred(), - event() {} +Manager::TableStream::TableStream() : Manager::Stream::Stream(TABLE_STREAM) {} -Manager::EventStream::EventStream() - : Manager::Stream::Stream(EVENT_STREAM), event(), fields(), num_fields(), want_record() {} +Manager::EventStream::EventStream() : Manager::Stream::Stream(EVENT_STREAM) {} Manager::EventStream::~EventStream() { if ( fields )