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

@ -68,7 +68,7 @@ namespace detail {
class DebugLogger { class DebugLogger {
public: public:
// Output goes to stderr per default. // Output goes to stderr per default.
DebugLogger() : file(nullptr), all(false), verbose(false) {}; DebugLogger() = default;
~DebugLogger(); ~DebugLogger();
void OpenDebugLog(const char* filename = 0); void OpenDebugLog(const char* filename = 0);
@ -99,14 +99,14 @@ public:
void ShowStreamsHelp(); void ShowStreamsHelp();
private: private:
FILE* file; FILE* file = nullptr;
bool all; bool all = false;
bool verbose; bool verbose = false;
struct Stream { struct Stream {
const char* prefix; const char* prefix = nullptr;
int indent; int indent = 0;
bool enabled; bool enabled = false;
}; };
std::set<std::string> enabled_streams; std::set<std::string> enabled_streams;

View file

@ -2782,7 +2782,7 @@ static void report_field_deprecation(const RecordType* rt, const Expr* e, int fi
} }
FieldExpr::FieldExpr(ExprPtr arg_op, const char* arg_field_name) FieldExpr::FieldExpr(ExprPtr arg_op, const char* arg_field_name)
: UnaryExpr(EXPR_FIELD, std::move(arg_op)), field_name(util::copy_string(arg_field_name)), td(nullptr), field(0) { : UnaryExpr(EXPR_FIELD, std::move(arg_op)), field_name(util::copy_string(arg_field_name)) {
if ( IsError() ) if ( IsError() )
return; return;
@ -2863,7 +2863,7 @@ void FieldExpr::ExprDescribe(ODesc* d) const {
} }
HasFieldExpr::HasFieldExpr(ExprPtr arg_op, const char* arg_field_name) HasFieldExpr::HasFieldExpr(ExprPtr arg_op, const char* arg_field_name)
: UnaryExpr(EXPR_HAS_FIELD, std::move(arg_op)), field_name(arg_field_name), field(0) { : UnaryExpr(EXPR_HAS_FIELD, std::move(arg_op)), field_name(arg_field_name) {
if ( IsError() ) if ( IsError() )
return; return;

View file

@ -1146,8 +1146,8 @@ protected:
void ExprDescribe(ODesc* d) const override; void ExprDescribe(ODesc* d) const override;
const char* field_name; const char* field_name;
const TypeDecl* td; const TypeDecl* td = nullptr;
int field; // -1 = attributes int field = -1;
}; };
// "rec?$fieldname" is true if the value of $fieldname in rec is not nil. // "rec?$fieldname" is true if the value of $fieldname in rec is not nil.
@ -1171,8 +1171,8 @@ protected:
void ExprDescribe(ODesc* d) const override; void ExprDescribe(ODesc* d) const override;
const char* field_name; const char* field_name = nullptr;
int field; int field = -1;
}; };
class RecordConstructorExpr final : public Expr { class RecordConstructorExpr final : public Expr {

View file

@ -72,7 +72,7 @@ static zeek::ValPtr mmdb_getvalue(MMDB_entry_data_s* entry_data, int status, int
return nullptr; return nullptr;
} }
MMDB::MMDB() : mmdb{}, file_info{}, reported_error{false}, last_check{zeek::run_state::network_time} {} MMDB::MMDB() : mmdb{}, file_info{}, last_check{zeek::run_state::network_time} {}
MMDB::~MMDB() { Close(); } MMDB::~MMDB() { Close(); }

View file

@ -64,7 +64,7 @@ private:
std::string filename; std::string filename;
MMDB_s mmdb; MMDB_s mmdb;
struct stat file_info; struct stat file_info;
bool reported_error; // to ensure we emit builtin errors during opening only once. bool reported_error = false; // to ensure we emit builtin errors during opening only once.
double last_check; double last_check;
}; };

View file

@ -57,9 +57,9 @@ public:
void UnsetFlags(int flags); void UnsetFlags(int flags);
private: private:
int fds[2]; int fds[2] = {-1, -1};
int flags[2]; int flags[2] = {0};
int status_flags[2]; int status_flags[2] = {0};
}; };
/** /**
@ -119,7 +119,7 @@ public:
void Swap() { swapped = ! swapped; } void Swap() { swapped = ! swapped; }
private: private:
Pipe pipes[2]; Pipe pipes[2]; // NOLINT(modernize-use-default-member-init)
bool swapped = false; bool swapped = false;
}; };

View file

@ -112,13 +112,11 @@ private:
friend class RuleMatcher; friend class RuleMatcher;
struct PatternSet { struct PatternSet {
PatternSet() : re() {}
// If we're above the 'RE_level' (see RuleMatcher), this // If we're above the 'RE_level' (see RuleMatcher), this
// expr contains all patterns on this node. If we're on // expr contains all patterns on this node. If we're on
// 'RE_level', it additionally contains all patterns // 'RE_level', it additionally contains all patterns
// of any of its children. // of any of its children.
Specific_RE_Matcher* re; Specific_RE_Matcher* re = nullptr;
// All the patterns and their rule indices. // All the patterns and their rule indices.
string_list patterns; string_list patterns;

View file

@ -20,8 +20,6 @@ using namespace std;
namespace zeek::detail { namespace zeek::detail {
ScriptCoverageManager::ScriptCoverageManager() : ignoring(0), delim('\t') {}
void ScriptCoverageManager::AddStmt(Stmt* s) { void ScriptCoverageManager::AddStmt(Stmt* s) {
if ( ignoring != 0 || analysis_options.gen_ZAM ) if ( ignoring != 0 || analysis_options.gen_ZAM )
return; return;

View file

@ -19,9 +19,6 @@ using ObjPtr = IntrusivePtr<Obj>;
*/ */
class ScriptCoverageManager { class ScriptCoverageManager {
public: public:
ScriptCoverageManager();
virtual ~ScriptCoverageManager() = default;
/** /**
* Imports Zeek script Stmt usage information from file pointed to by * Imports Zeek script Stmt usage information from file pointed to by
* environment variable ZEEK_PROFILER_FILE. * environment variable ZEEK_PROFILER_FILE.
@ -64,12 +61,12 @@ private:
* Indicates whether new statements will not be considered as part of * Indicates whether new statements will not be considered as part of
* coverage statistics because it was marked with the @no-test tag. * coverage statistics because it was marked with the @no-test tag.
*/ */
uint32_t ignoring; uint32_t ignoring = 0;
/** /**
* The character to use to delimit ScriptCoverageManager output files. Default is '\t'. * The character to use to delimit ScriptCoverageManager output files. Default is '\t'.
*/ */
char delim; char delim = '\t';
/** /**
* This maps Stmt location-desc pairs to the total number of times that * This maps Stmt location-desc pairs to the total number of times that

View file

@ -12,10 +12,7 @@
namespace zeek::detail { namespace zeek::detail {
const float SerializationFormat::GROWTH_FACTOR = 2.5; constexpr float SerializationFormat::GROWTH_FACTOR = 2.5;
SerializationFormat::SerializationFormat()
: output(), output_size(), output_pos(), input(), input_len(), input_pos(), bytes_written(), bytes_read() {}
SerializationFormat::~SerializationFormat() { free(output); } SerializationFormat::~SerializationFormat() { free(output); }

View file

@ -20,7 +20,7 @@ namespace detail {
// Abstract base class. // Abstract base class.
class SerializationFormat { class SerializationFormat {
public: public:
SerializationFormat(); SerializationFormat() = default;
virtual ~SerializationFormat(); virtual ~SerializationFormat();
// Unserialization. // Unserialization.
@ -88,16 +88,16 @@ protected:
static const uint32_t INITIAL_SIZE = 65536; static const uint32_t INITIAL_SIZE = 65536;
static const float GROWTH_FACTOR; static const float GROWTH_FACTOR;
char* output; char* output = nullptr;
uint32_t output_size; uint32_t output_size = 0;
uint32_t output_pos; uint32_t output_pos = 0;
const char* input; const char* input = nullptr;
uint32_t input_len; uint32_t input_len = 0;
uint32_t input_pos; uint32_t input_pos = 0;
int bytes_written; int bytes_written = 0;
int bytes_read; int bytes_read = 0;
}; };
class BinarySerializationFormat final : public SerializationFormat { class BinarySerializationFormat final : public SerializationFormat {

View file

@ -642,7 +642,7 @@ void SwitchStmt::Init() {
} }
SwitchStmt::SwitchStmt(ExprPtr index, case_list* arg_cases) SwitchStmt::SwitchStmt(ExprPtr index, case_list* arg_cases)
: ExprStmt(STMT_SWITCH, std::move(index)), cases(arg_cases), default_case_idx(-1) { : ExprStmt(STMT_SWITCH, std::move(index)), cases(arg_cases) {
Init(); Init();
bool have_exprs = false; bool have_exprs = false;

View file

@ -220,9 +220,9 @@ protected:
// the matching type-based case if it defines one. // the matching type-based case if it defines one.
std::pair<int, ID*> FindCaseLabelMatch(const Val* v) const; std::pair<int, ID*> FindCaseLabelMatch(const Val* v) const;
case_list* cases; case_list* cases = nullptr;
int default_case_idx; int default_case_idx = -1;
CompositeHash* comp_hash; CompositeHash* comp_hash = nullptr;
std::unordered_map<const Val*, int> case_label_value_map; std::unordered_map<const Val*, int> case_label_value_map;
PDict<int> case_label_hash_map; PDict<int> case_label_hash_map;
std::vector<std::pair<ID*, int>> case_label_type_list; std::vector<std::pair<ID*, int>> case_label_type_list;

View file

@ -145,7 +145,7 @@ protected:
*/ */
class EncapsulationStack { class EncapsulationStack {
public: public:
EncapsulationStack() : conns(nullptr) {} EncapsulationStack() = default;
EncapsulationStack(const EncapsulationStack& other) { EncapsulationStack(const EncapsulationStack& other) {
if ( other.conns ) if ( other.conns )
@ -241,7 +241,7 @@ public:
void Pop(); void Pop();
protected: protected:
std::vector<EncapsulatingConn>* conns; std::vector<EncapsulatingConn>* conns = nullptr;
}; };
} // namespace zeek } // namespace zeek

View file

@ -11,19 +11,7 @@
namespace zeek::analyzer::conn_size { namespace zeek::analyzer::conn_size {
ConnSize_Analyzer::ConnSize_Analyzer(Connection* c) ConnSize_Analyzer::ConnSize_Analyzer(Connection* c) : Analyzer("CONNSIZE", c) { start_time = c->StartTime(); }
: Analyzer("CONNSIZE", c),
orig_bytes(),
resp_bytes(),
orig_pkts(),
resp_pkts(),
orig_bytes_thresh(),
resp_bytes_thresh(),
orig_pkts_thresh(),
resp_pkts_thresh(),
duration_thresh() {
start_time = c->StartTime();
}
void ConnSize_Analyzer::Init() { void ConnSize_Analyzer::Init() {
Analyzer::Init(); Analyzer::Init();

View file

@ -32,18 +32,18 @@ protected:
void ThresholdEvent(EventHandlerPtr f, uint64_t threshold, bool is_orig); void ThresholdEvent(EventHandlerPtr f, uint64_t threshold, bool is_orig);
uint64_t orig_bytes; uint64_t orig_bytes = 0;
uint64_t resp_bytes; uint64_t resp_bytes = 0;
uint64_t orig_pkts; uint64_t orig_pkts = 0;
uint64_t resp_pkts; uint64_t resp_pkts = 0;
uint64_t orig_bytes_thresh; uint64_t orig_bytes_thresh = 0;
uint64_t resp_bytes_thresh; uint64_t resp_bytes_thresh = 0;
uint64_t orig_pkts_thresh; uint64_t orig_pkts_thresh = 0;
uint64_t resp_pkts_thresh; uint64_t resp_pkts_thresh = 0;
double start_time; double start_time = 0.0;
double duration_thresh; double duration_thresh = 0.0;
}; };
// Exposed to make it available to script optimization. // Exposed to make it available to script optimization.

View file

@ -14,8 +14,6 @@
namespace zeek::analyzer::ftp { namespace zeek::analyzer::ftp {
FTP_Analyzer::FTP_Analyzer(Connection* conn) : analyzer::tcp::TCP_ApplicationAnalyzer("FTP", conn) { FTP_Analyzer::FTP_Analyzer(Connection* conn) : analyzer::tcp::TCP_ApplicationAnalyzer("FTP", conn) {
pending_reply = 0;
nvt_orig = new analyzer::login::NVT_Analyzer(conn, true); nvt_orig = new analyzer::login::NVT_Analyzer(conn, true);
nvt_orig->SetIsNULSensitive(true); nvt_orig->SetIsNULSensitive(true);
nvt_orig->SetCRLFAsEOL(LF_as_EOL); nvt_orig->SetCRLFAsEOL(LF_as_EOL);

View file

@ -22,7 +22,7 @@ public:
protected: protected:
analyzer::login::NVT_Analyzer* nvt_orig; analyzer::login::NVT_Analyzer* nvt_orig;
analyzer::login::NVT_Analyzer* nvt_resp; analyzer::login::NVT_Analyzer* nvt_resp;
uint32_t pending_reply; // code associated with multi-line reply, or 0 uint32_t pending_reply = 0; // code associated with multi-line reply, or 0
std::string auth_requested; // AUTH method requested std::string auth_requested; // AUTH method requested
bool tls_active = false; // starttls active bool tls_active = false; // starttls active
}; };
@ -36,8 +36,7 @@ protected:
*/ */
class FTP_ADAT_Analyzer final : public analyzer::SupportAnalyzer { class FTP_ADAT_Analyzer final : public analyzer::SupportAnalyzer {
public: public:
FTP_ADAT_Analyzer(Connection* conn, bool arg_orig) FTP_ADAT_Analyzer(Connection* conn, bool arg_orig) : SupportAnalyzer("FTP_ADAT", conn, arg_orig) {}
: SupportAnalyzer("FTP_ADAT", conn, arg_orig), first_token(true) {}
void DeliverStream(int len, const u_char* data, bool orig) override; void DeliverStream(int len, const u_char* data, bool orig) override;
@ -45,7 +44,7 @@ protected:
// Used by the client-side analyzer to tell if it needs to peek at the // Used by the client-side analyzer to tell if it needs to peek at the
// initial context token and do sanity checking (i.e. does it look like // initial context token and do sanity checking (i.e. does it look like
// a TLS/SSL handshake token). // a TLS/SSL handshake token).
bool first_token; bool first_token = true;
}; };
} // namespace zeek::analyzer::ftp } // namespace zeek::analyzer::ftp

View file

@ -24,7 +24,7 @@ static RE_Matcher* re_login_timeouts;
static RE_Matcher* init_RE(ListVal* l); static RE_Matcher* init_RE(ListVal* l);
Login_Analyzer::Login_Analyzer(const char* name, Connection* conn) Login_Analyzer::Login_Analyzer(const char* name, Connection* conn)
: analyzer::tcp::TCP_ApplicationAnalyzer(name, conn), user_text() { : analyzer::tcp::TCP_ApplicationAnalyzer(name, conn) {
state = LOGIN_STATE_AUTHENTICATE; state = LOGIN_STATE_AUTHENTICATE;
num_user_lines_seen = lines_scanned = 0; num_user_lines_seen = lines_scanned = 0;
// Set last_failure_num_user_lines so we will always generate // Set last_failure_num_user_lines so we will always generate

View file

@ -64,7 +64,7 @@ protected:
// If we have more user text than this unprocessed, we complain about // If we have more user text than this unprocessed, we complain about
// excessive typeahead. // excessive typeahead.
#define MAX_USER_TEXT 12 #define MAX_USER_TEXT 12
char* user_text[MAX_USER_TEXT]; char* user_text[MAX_USER_TEXT] = {0};
int user_text_first, user_text_last; // indices into user_text int user_text_first, user_text_last; // indices into user_text
int num_user_text; // number of entries in user_text int num_user_text; // number of entries in user_text

View file

@ -316,8 +316,7 @@ void TelnetBinaryOption::InconsistentOption(unsigned int /* type */) {
} // namespace detail } // namespace detail
NVT_Analyzer::NVT_Analyzer(Connection* conn, bool orig) NVT_Analyzer::NVT_Analyzer(Connection* conn, bool orig) : analyzer::tcp::ContentLine_Analyzer("NVT", conn, orig) {}
: analyzer::tcp::ContentLine_Analyzer("NVT", conn, orig), options() {}
NVT_Analyzer::~NVT_Analyzer() { NVT_Analyzer::~NVT_Analyzer() {
for ( int i = 0; i < num_options; ++i ) for ( int i = 0; i < num_options; ++i )

View file

@ -164,7 +164,7 @@ protected:
int encrypting_mode = 0; int encrypting_mode = 0;
char* auth_name = nullptr; char* auth_name = nullptr;
TelnetOption* options[NUM_TELNET_OPTIONS]; TelnetOption* options[NUM_TELNET_OPTIONS] = {nullptr};
int num_options = 0; int num_options = 0;
}; };

View file

@ -14,7 +14,7 @@
namespace zeek::analyzer::pia { namespace zeek::analyzer::pia {
PIA::PIA(analyzer::Analyzer* arg_as_analyzer) : state(INIT), as_analyzer(arg_as_analyzer), conn(), current_packet() {} PIA::PIA(analyzer::Analyzer* arg_as_analyzer) : as_analyzer(arg_as_analyzer), current_packet() {}
PIA::~PIA() { ClearBuffer(&pkt_buffer); } PIA::~PIA() { ClearBuffer(&pkt_buffer); }

View file

@ -73,7 +73,8 @@ protected:
void PIA_DeliverPacket(int len, const u_char* data, bool is_orig, uint64_t seq, const IP_Hdr* ip, int caplen, void PIA_DeliverPacket(int len, const u_char* data, bool is_orig, uint64_t seq, const IP_Hdr* ip, int caplen,
bool clear_state); bool clear_state);
enum State : uint8_t { INIT, BUFFERING, MATCHING_ONLY, SKIPPING } state; enum State : uint8_t { INIT, BUFFERING, MATCHING_ONLY, SKIPPING };
State state = INIT;
// Buffers one chunk of data. Used both for packet payload (incl. // Buffers one chunk of data. Used both for packet payload (incl.
// sequence numbers for TCP) and chunks of a reassembled stream. // sequence numbers for TCP) and chunks of a reassembled stream.
@ -114,8 +115,8 @@ private:
// Joint backend for the two public FirstPacket() methods. // Joint backend for the two public FirstPacket() methods.
void FirstPacket(bool is_orig, const std::optional<TransportProto>& proto, const IP_Hdr* ip); void FirstPacket(bool is_orig, const std::optional<TransportProto>& proto, const IP_Hdr* ip);
analyzer::Analyzer* as_analyzer; analyzer::Analyzer* as_analyzer = nullptr;
Connection* conn; Connection* conn = nullptr;
DataBlock current_packet; DataBlock current_packet;
}; };

View file

@ -625,7 +625,7 @@ void Contents_RPC::DeliverStream(int len, const u_char* data, bool orig) {
} }
RPC_Analyzer::RPC_Analyzer(const char* name, Connection* conn, detail::RPC_Interpreter* arg_interp) RPC_Analyzer::RPC_Analyzer(const char* name, Connection* conn, detail::RPC_Interpreter* arg_interp)
: analyzer::tcp::TCP_ApplicationAnalyzer(name, conn), interp(arg_interp), orig_rpc(), resp_rpc() { : analyzer::tcp::TCP_ApplicationAnalyzer(name, conn), interp(arg_interp) {
if ( Conn()->ConnTransport() == TRANSPORT_UDP ) if ( Conn()->ConnTransport() == TRANSPORT_UDP )
ADD_ANALYZER_TIMER(&RPC_Analyzer::ExpireTimer, run_state::network_time + zeek::detail::rpc_timeout, true, ADD_ANALYZER_TIMER(&RPC_Analyzer::ExpireTimer, run_state::network_time + zeek::detail::rpc_timeout, true,
zeek::detail::TIMER_RPC_EXPIRE); zeek::detail::TIMER_RPC_EXPIRE);

View file

@ -250,8 +250,8 @@ protected:
detail::RPC_Interpreter* interp; detail::RPC_Interpreter* interp;
Contents_RPC* orig_rpc; Contents_RPC* orig_rpc = nullptr;
Contents_RPC* resp_rpc; Contents_RPC* resp_rpc = nullptr;
}; };
} // namespace zeek::analyzer::rpc } // namespace zeek::analyzer::rpc

View file

@ -195,8 +195,7 @@ RecordVal* TCPStats_Endpoint::BuildStats() {
return stats; return stats;
} }
TCPStats_Analyzer::TCPStats_Analyzer(Connection* c) TCPStats_Analyzer::TCPStats_Analyzer(Connection* c) : TCP_ApplicationAnalyzer("TCPSTATS", c) {}
: TCP_ApplicationAnalyzer("TCPSTATS", c), orig_stats(), resp_stats() {}
TCPStats_Analyzer::~TCPStats_Analyzer() { TCPStats_Analyzer::~TCPStats_Analyzer() {
delete orig_stats; delete orig_stats;

View file

@ -117,8 +117,8 @@ public:
protected: protected:
void DeliverPacket(int len, const u_char* data, bool is_orig, uint64_t seq, const IP_Hdr* ip, int caplen) override; void DeliverPacket(int len, const u_char* data, bool is_orig, uint64_t seq, const IP_Hdr* ip, int caplen) override;
TCPStats_Endpoint* orig_stats; TCPStats_Endpoint* orig_stats = nullptr;
TCPStats_Endpoint* resp_stats; TCPStats_Endpoint* resp_stats = nullptr;
}; };
} // namespace zeek::analyzer::tcp } // namespace zeek::analyzer::tcp

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) File::File(const std::string& file_id, const std::string& source_name, Connection* conn, zeek::Tag tag, bool is_orig)
: id(file_id), : id(file_id), val(nullptr), analyzers(this) {
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) {
StaticInit(); StaticInit();
DBG_LOG(DBG_FILE_ANALYSIS, "[%s] Creating new File object", file_id.c_str()); DBG_LOG(DBG_FILE_ANALYSIS, "[%s] Creating new File object", file_id.c_str());

View file

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

View file

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

View file

@ -428,17 +428,17 @@ private:
TagSet* LookupMIMEType(const std::string& mtype, bool add_if_not_found); 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::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::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. */ std::string current_file_id; /**< Hash of what get_file_handle event sets. */
zeek::detail::RuleFileMagicState* magic_state; /**< File magic signature match state. */ zeek::detail::RuleFileMagicState* magic_state = nullptr; /**< File magic signature match state. */
MIMEMap mime_types; /**< Mapping of MIME types to analyzers. */ MIMEMap mime_types; /**< Mapping of MIME types to analyzers. */
inline static TableVal* disabled = nullptr; /**< Table of disabled analyzers. */ inline static TableVal* disabled = nullptr; /**< Table of disabled analyzers. */
inline static TableType* tag_set_type = nullptr; /**< Type for set[tag]. */ inline static TableType* tag_set_type = nullptr; /**< Type for set[tag]. */
size_t cumulative_files; size_t cumulative_files = 0;
size_t max_files; size_t max_files = 0;
zeek::detail::CompositeHash* analyzer_hash = nullptr; 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), : file_analysis::Analyzer(file_mgr->GetComponentTag("EXTRACT"), std::move(args), file),
filename(std::move(arg_filename)), filename(std::move(arg_filename)),
limit(arg_limit), limit(arg_limit),
written(0),
limit_includes_missing(arg_limit_includes_missing) { limit_includes_missing(arg_limit_includes_missing) {
char buf[128]; char buf[128];
file_stream = fopen(filename.data(), "wb"); file_stream = fopen(filename.data(), "wb");

View file

@ -69,10 +69,10 @@ protected:
private: private:
std::string filename; std::string filename;
FILE* file_stream; FILE* file_stream = nullptr;
uint64_t limit; // the file extraction limit uint64_t limit = 0; // the file extraction limit
uint64_t written; // how many bytes we have written so far uint64_t written = 0; // how many bytes we have written so far
bool limit_includes_missing; // do count missing bytes against limit if true bool limit_includes_missing = false; // do count missing bytes against limit if true
}; };
} // namespace zeek::file_analysis::detail } // 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_analysis::Analyzer(file_mgr->GetComponentTag(util::to_upper(arg_kind->ToStdString())), std::move(args),
file), file),
hash(hv), hash(hv),
fed(false),
kind(std::move(arg_kind)) { kind(std::move(arg_kind)) {
hash->Init(); hash->Init();
} }

View file

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

View file

@ -15,7 +15,7 @@ namespace zeek::input::reader::detail {
streamsize Binary::chunk_size = 0; streamsize Binary::chunk_size = 0;
Binary::Binary(ReaderFrontend* frontend) : ReaderBackend(frontend), in(nullptr), mtime(0), ino(0), firstrun(true) { Binary::Binary(ReaderFrontend* frontend) : ReaderBackend(frontend) {
if ( ! chunk_size ) { if ( ! chunk_size ) {
chunk_size = BifConst::InputBinary::chunk_size; chunk_size = BifConst::InputBinary::chunk_size;

View file

@ -32,10 +32,10 @@ private:
int UpdateModificationTime(); int UpdateModificationTime();
std::string fname; std::string fname;
std::ifstream* in; std::ifstream* in = nullptr;
time_t mtime; time_t mtime = 0;
ino_t ino; ino_t ino = 0;
bool firstrun; bool firstrun = true;
// options set from the script-level. // options set from the script-level.
static std::streamsize chunk_size; static std::streamsize chunk_size;

View file

@ -16,8 +16,7 @@ using zeek::threading::Value;
namespace zeek::input::reader::detail { namespace zeek::input::reader::detail {
SQLite::SQLite(ReaderFrontend* frontend) SQLite::SQLite(ReaderFrontend* frontend) : ReaderBackend(frontend) {
: ReaderBackend(frontend), fields(), num_fields(), mode(), started(), query(), db(), st() {
set_separator.assign((const char*)BifConst::LogSQLite::set_separator->Bytes(), set_separator.assign((const char*)BifConst::LogSQLite::set_separator->Bytes(),
BifConst::InputSQLite::set_separator->Len()); BifConst::InputSQLite::set_separator->Len());

View file

@ -28,14 +28,14 @@ private:
threading::Value* EntryToVal(sqlite3_stmt* st, const threading::Field* field, int pos, int subpos); threading::Value* EntryToVal(sqlite3_stmt* st, const threading::Field* field, int pos, int subpos);
const threading::Field* const* fields; // raw mapping const threading::Field* const* fields = nullptr; // raw mapping
unsigned int num_fields; unsigned int num_fields = 0;
int mode; int mode = 0;
bool started; bool started = false;
std::string query; std::string query;
sqlite3* db; sqlite3* db = nullptr;
sqlite3_stmt* st; sqlite3_stmt* st = nullptr;
threading::formatter::Ascii* io; threading::formatter::Ascii* io = nullptr;
std::string set_separator; std::string set_separator;
std::string unset_field; std::string unset_field;

View file

@ -60,7 +60,7 @@ public:
* *
* Structure takes ownership of string. * Structure takes ownership of string.
*/ */
const char* path; const char* path = nullptr;
/** /**
* The filter this writer is attached to. * The filter this writer is attached to.
@ -79,17 +79,17 @@ public:
/** /**
* The rotation interval as configured for this writer. * The rotation interval as configured for this writer.
*/ */
double rotation_interval; double rotation_interval = 0.0;
/** /**
* The parsed value of log_rotate_base_time in seconds. * The parsed value of log_rotate_base_time in seconds.
*/ */
double rotation_base; double rotation_base = 0.0;
/** /**
* The network time when the writer is created. * The network time when the writer is created.
*/ */
double network_time; double network_time = 0.0;
/** /**
* A map of key/value pairs corresponding to the relevant * A map of key/value pairs corresponding to the relevant
@ -97,7 +97,7 @@ public:
*/ */
config_map config; config_map config;
WriterInfo() : path(nullptr), rotation_interval(0.0), rotation_base(0.0), network_time(0.0) {} WriterInfo() = default;
WriterInfo(const WriterInfo& other) { WriterInfo(const WriterInfo& other) {
path = other.path ? util::copy_string(other.path) : nullptr; path = other.path ? util::copy_string(other.path) : nullptr;

View file

@ -16,7 +16,7 @@ using zeek::threading::Value;
namespace zeek::logging::writer::detail { namespace zeek::logging::writer::detail {
SQLite::SQLite(WriterFrontend* frontend) : WriterBackend(frontend), fields(), num_fields(), db(), st() { SQLite::SQLite(WriterFrontend* frontend) : WriterBackend(frontend) {
set_separator.assign((const char*)BifConst::LogSQLite::set_separator->Bytes(), set_separator.assign((const char*)BifConst::LogSQLite::set_separator->Bytes(),
BifConst::LogSQLite::set_separator->Len()); BifConst::LogSQLite::set_separator->Len());

View file

@ -32,11 +32,11 @@ private:
int AddParams(threading::Value* val, int pos); int AddParams(threading::Value* val, int pos);
std::string GetTableType(int, int); std::string GetTableType(int, int);
const threading::Field* const* fields; // raw mapping const threading::Field* const* fields = nullptr; // raw mapping
unsigned int num_fields; unsigned int num_fields = 0;
sqlite3* db; sqlite3* db = nullptr;
sqlite3_stmt* st; sqlite3_stmt* st = nullptr;
std::string set_separator; std::string set_separator;
std::string unset_field; std::string unset_field;

View file

@ -19,7 +19,6 @@ IdentifierInfo::IdentifierInfo(zeek::detail::IDPtr arg_id, ScriptInfo* script, b
initial_val(), initial_val(),
redefs(), redefs(),
fields(), fields(),
last_field_seen(),
declaring_script(script), declaring_script(script),
from_redef(redef) { from_redef(redef) {
if ( id->GetVal() && (id->IsOption() || id->IsRedefinable()) ) if ( id->GetVal() && (id->IsOption() || id->IsRedefinable()) )

View file

@ -185,8 +185,8 @@ private:
ValPtr initial_val; ValPtr initial_val;
redef_list redefs; redef_list redefs;
record_field_map fields; record_field_map fields;
RecordField* last_field_seen; RecordField* last_field_seen = nullptr;
ScriptInfo* declaring_script; ScriptInfo* declaring_script = nullptr;
bool from_redef = false; bool from_redef = false;
}; };

View file

@ -51,18 +51,14 @@ static string RemoveLeadingSpace(const string& s) {
} }
Manager::Manager(const string& arg_config, const string& command) Manager::Manager(const string& arg_config, const string& command)
: disabled(), : comment_buffer(),
comment_buffer(),
comment_buffer_map(), comment_buffer_map(),
packages(), packages(),
scripts(), scripts(),
identifiers(), identifiers(),
all_info(), all_info(),
last_identifier_seen(),
incomplete_type(),
enum_mappings(), enum_mappings(),
config(arg_config), config(arg_config) {
mtime() {
if ( getenv("ZEEK_DISABLE_ZEEKYGEN") ) if ( getenv("ZEEK_DISABLE_ZEEKYGEN") )
disabled = true; disabled = true;

View file

@ -226,7 +226,7 @@ private:
IdentifierInfo* CreateIdentifierInfo(zeek::detail::IDPtr id, ScriptInfo* script, bool from_redef = false); IdentifierInfo* CreateIdentifierInfo(zeek::detail::IDPtr id, ScriptInfo* script, bool from_redef = false);
bool disabled; bool disabled = false;
comment_buffer_t comment_buffer; // For whatever next identifier comes in. comment_buffer_t comment_buffer; // For whatever next identifier comes in.
comment_buffer_map_t comment_buffer_map; // For a particular identifier. comment_buffer_map_t comment_buffer_map; // For a particular identifier.
InfoMap<PackageInfo> packages; InfoMap<PackageInfo> packages;
@ -234,11 +234,11 @@ private:
InfoMap<IdentifierInfo> identifiers; InfoMap<IdentifierInfo> identifiers;
InfoMap<SpicyModuleInfo> spicy_modules; InfoMap<SpicyModuleInfo> spicy_modules;
std::vector<Info*> all_info; std::vector<Info*> all_info;
IdentifierInfo* last_identifier_seen; IdentifierInfo* last_identifier_seen = nullptr;
IdentifierInfo* incomplete_type; IdentifierInfo* incomplete_type = nullptr;
std::map<std::string, std::string> enum_mappings; // enum id -> enum type id std::map<std::string, std::string> enum_mappings; // enum id -> enum type id
Config config; Config config;
time_t mtime; time_t mtime = 0;
}; };
template<class T> template<class T>

View file

@ -189,7 +189,7 @@ static vector<T*> filter_matches(const vector<Info*>& from, Target* t) {
return rval; return rval;
} }
TargetFile::TargetFile(string arg_name) : name(std::move(arg_name)), f() { TargetFile::TargetFile(string arg_name) : name(std::move(arg_name)) {
if ( name.find('/') != string::npos ) { if ( name.find('/') != string::npos ) {
string dir = util::SafeDirname(name).result; string dir = util::SafeDirname(name).result;

View file

@ -35,8 +35,8 @@ struct TargetFile {
*/ */
~TargetFile(); ~TargetFile();
std::string name; /**< File name. */ std::string name; /**< File name. */
FILE* f; /**< File stream. */ FILE* f = nullptr; /**< File stream. */
}; };
/** /**