Fix clang-tidy modernize-use-default-member-init warnings in headers

This commit is contained in:
Tim Wojtulewicz 2025-06-10 09:32:23 -07:00
parent a05b4abdf7
commit fb55c8856e
49 changed files with 134 additions and 185 deletions

View file

@ -77,19 +77,7 @@ void File::StaticInit() {
}
File::File(const std::string& file_id, const std::string& source_name, Connection* conn, zeek::Tag tag, bool is_orig)
: id(file_id),
val(nullptr),
file_reassembler(nullptr),
stream_offset(0),
reassembly_max_buffer(0),
did_metadata_inference(false),
reassembly_enabled(false),
postpone_timeout(false),
done(false),
seen_bytes(0),
missing_bytes(0),
overflow_bytes(0),
analyzers(this) {
: id(file_id), val(nullptr), analyzers(this) {
StaticInit();
DBG_LOG(DBG_FILE_ANALYSIS, "[%s] Creating new File object", file_id.c_str());

View file

@ -314,31 +314,31 @@ protected:
static void StaticInit();
protected:
std::string id; /**< A pretty hash that likely identifies file */
RecordValPtr val; /**< \c fa_file from script layer. */
FileReassembler* file_reassembler; /**< A reassembler for the file if it's needed. */
uint64_t stream_offset; /**< The offset of the file which has been forwarded. */
uint64_t reassembly_max_buffer; /**< Maximum allowed buffer for reassembly. */
bool did_metadata_inference; /**< Whether the metadata inference has already been attempted. */
bool reassembly_enabled; /**< Whether file stream reassembly is needed. */
bool postpone_timeout; /**< Whether postponing timeout is requested. */
bool done; /**< If this object is about to be deleted. */
uint64_t seen_bytes; /**< Number of bytes processed for this file. */
uint64_t missing_bytes; /**< Number of bytes missed for this file. */
uint64_t overflow_bytes; /**< Number of bytes not delivered. */
detail::AnalyzerSet analyzers; /**< A set of attached file analyzers. */
std::list<Analyzer*> done_analyzers; /**< Analyzers we're done with, remembered here until they
can be safely deleted. */
std::string id; /**< A pretty hash that likely identifies file */
RecordValPtr val; /**< \c fa_file from script layer. */
FileReassembler* file_reassembler = nullptr; /**< A reassembler for the file if it's needed. */
uint64_t stream_offset = 0; /**< The offset of the file which has been forwarded. */
uint64_t reassembly_max_buffer = 0; /**< Maximum allowed buffer for reassembly. */
bool did_metadata_inference = false; /**< Whether the metadata inference has already been attempted. */
bool reassembly_enabled = false; /**< Whether file stream reassembly is needed. */
bool postpone_timeout = false; /**< Whether postponing timeout is requested. */
bool done = false; /**< If this object is about to be deleted. */
uint64_t seen_bytes = 0; /**< Number of bytes processed for this file. */
uint64_t missing_bytes = 0; /**< Number of bytes missed for this file. */
uint64_t overflow_bytes = 0; /**< Number of bytes not delivered. */
detail::AnalyzerSet analyzers; /**< A set of attached file analyzers. */
std::list<Analyzer*> done_analyzers; /**< Analyzers we're done with, remembered here until they
can be safely deleted. */
struct BOF_Buffer {
BOF_Buffer() : full(false), size(0) {}
BOF_Buffer() = default;
~BOF_Buffer() {
for ( auto* chunk : chunks )
delete chunk;
}
bool full;
uint64_t size;
bool full = false;
uint64_t size = 0;
String::CVec chunks;
} bof_buffer; /**< Beginning of file buffer. */

View file

@ -16,12 +16,7 @@ using namespace std;
namespace zeek::file_analysis {
Manager::Manager()
: plugin::ComponentManager<file_analysis::Component>("Files", "Tag", "AllAnalyzers"),
current_file_id(),
magic_state(),
cumulative_files(0),
max_files(0) {}
Manager::Manager() : plugin::ComponentManager<file_analysis::Component>("Files", "Tag", "AllAnalyzers") {}
Manager::~Manager() {
for ( const auto& [_, tag] : mime_types )

View file

@ -428,17 +428,17 @@ private:
TagSet* LookupMIMEType(const std::string& mtype, bool add_if_not_found);
std::map<std::string, File*> id_map; /**< Map file ID to file_analysis::File records. */
std::set<std::string> ignored; /**< Ignored files. Will be finally removed on EOF. */
std::string current_file_id; /**< Hash of what get_file_handle event sets. */
zeek::detail::RuleFileMagicState* magic_state; /**< File magic signature match state. */
MIMEMap mime_types; /**< Mapping of MIME types to analyzers. */
std::map<std::string, File*> id_map; /**< Map file ID to file_analysis::File records. */
std::set<std::string> ignored; /**< Ignored files. Will be finally removed on EOF. */
std::string current_file_id; /**< Hash of what get_file_handle event sets. */
zeek::detail::RuleFileMagicState* magic_state = nullptr; /**< File magic signature match state. */
MIMEMap mime_types; /**< Mapping of MIME types to analyzers. */
inline static TableVal* disabled = nullptr; /**< Table of disabled analyzers. */
inline static TableType* tag_set_type = nullptr; /**< Type for set[tag]. */
size_t cumulative_files;
size_t max_files;
size_t cumulative_files = 0;
size_t max_files = 0;
zeek::detail::CompositeHash* analyzer_hash = nullptr;
};

View file

@ -16,7 +16,6 @@ Extract::Extract(RecordValPtr args, file_analysis::File* file, std::string arg_f
: file_analysis::Analyzer(file_mgr->GetComponentTag("EXTRACT"), std::move(args), file),
filename(std::move(arg_filename)),
limit(arg_limit),
written(0),
limit_includes_missing(arg_limit_includes_missing) {
char buf[128];
file_stream = fopen(filename.data(), "wb");

View file

@ -69,10 +69,10 @@ protected:
private:
std::string filename;
FILE* file_stream;
uint64_t limit; // the file extraction limit
uint64_t written; // how many bytes we have written so far
bool limit_includes_missing; // do count missing bytes against limit if true
FILE* file_stream = nullptr;
uint64_t limit = 0; // the file extraction limit
uint64_t written = 0; // how many bytes we have written so far
bool limit_includes_missing = false; // do count missing bytes against limit if true
};
} // namespace zeek::file_analysis::detail

View file

@ -16,7 +16,6 @@ Hash::Hash(RecordValPtr args, file_analysis::File* file, HashVal* hv, StringValP
: file_analysis::Analyzer(file_mgr->GetComponentTag(util::to_upper(arg_kind->ToStdString())), std::move(args),
file),
hash(hv),
fed(false),
kind(std::move(arg_kind)) {
hash->Init();
}

View file

@ -60,8 +60,8 @@ protected:
void Finalize();
private:
HashVal* hash;
bool fed;
HashVal* hash = nullptr;
bool fed = false;
StringValPtr kind;
};