diff --git a/src/Debug.h b/src/Debug.h index 06bc483b98..a2e7da266d 100644 --- a/src/Debug.h +++ b/src/Debug.h @@ -137,7 +137,7 @@ public: protected: Location loc; - Stmt* stmt; + Stmt* stmt = nullptr; }; extern bool g_policy_debug; // enable debugging facility diff --git a/src/File.h b/src/File.h index e5c2dab9c8..98b722228d 100644 --- a/src/File.h +++ b/src/File.h @@ -108,17 +108,17 @@ protected: // Raises a file_opened event. void RaiseOpenEvent(); - FILE* f; + FILE* f = nullptr; TypePtr t; - char* name; - char* access; - detail::Attributes* attrs; - double open_time; - bool is_open; // whether the file is open in a general sense - bool buffered; - bool raw_output; + char* name = nullptr; + char* access = nullptr; + detail::Attributes* attrs = nullptr; + double open_time = 0.0; + bool is_open = false; // whether the file is open in a general sense + bool buffered = false; + bool raw_output = false; - static const int MIN_BUFFER_SIZE = 1024; + static constexpr int MIN_BUFFER_SIZE = 1024; private: static std::list> open_files; diff --git a/src/Hash.h b/src/Hash.h index 985c71446a..615eefd466 100644 --- a/src/Hash.h +++ b/src/Hash.h @@ -232,7 +232,7 @@ constexpr int NUM_HASH_KEYS = HASH_KEY_STRING + 1; class HashKey { public: - explicit HashKey() { } + explicit HashKey() { key_u.u32 = 0; } explicit HashKey(bool b); explicit HashKey(int i); explicit HashKey(zeek_int_t bi); diff --git a/src/RandTest.h b/src/RandTest.h index 91812f1b81..d03b0254fc 100644 --- a/src/RandTest.h +++ b/src/RandTest.h @@ -32,7 +32,7 @@ private: int64_t totalc; /* Total bytes counted */ int mp; int sccfirst; - unsigned int monte[RT_MONTEN]; + unsigned int monte[RT_MONTEN] = {0}; int64_t inmont, mcount; double cexp, montex, montey, montepi, sccu0, scclast, scct1, scct2, scct3; }; diff --git a/src/Type.cc b/src/Type.cc index 18b95277b5..78a8ec1b0e 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -1001,7 +1001,7 @@ public: R_INIT_RECORD, // field requires a new record R_INIT_TABLE, // field requires a new table/set R_INIT_VECTOR, // field requires a new vector - } init_type; + } init_type = R_INIT_NONE; bool def_coerce = false; // whether coercion's required diff --git a/src/Type.h b/src/Type.h index 1c7b719ada..cbdc4a3602 100644 --- a/src/Type.h +++ b/src/Type.h @@ -725,12 +725,12 @@ protected: std::vector managed_fields; // Number of fields in the type. - int num_fields; + int num_fields = 0; // Number of fields in the type when originally declared. - int num_orig_fields; + int num_orig_fields = 0; - type_decl_list* types; + type_decl_list* types = nullptr; std::set field_ids; }; diff --git a/src/analyzer/protocol/dnp3/DNP3.h b/src/analyzer/protocol/dnp3/DNP3.h index 7b46b5b739..d40600407a 100644 --- a/src/analyzer/protocol/dnp3/DNP3.h +++ b/src/analyzer/protocol/dnp3/DNP3.h @@ -23,13 +23,13 @@ protected: struct Endpoint { - u_char buffer[MAX_BUFFER_SIZE]; - int buffer_len; - bool in_hdr; - int tpflags; - int pkt_length; - int pkt_cnt; - bool encountered_first_chunk; + u_char buffer[MAX_BUFFER_SIZE] = {0}; + int buffer_len = 0; + bool in_hdr = false; + int tpflags = 0; + int pkt_length = 0; + int pkt_cnt = 0; + bool encountered_first_chunk = false; }; bool ProcessData(int len, const u_char* data, bool orig); diff --git a/src/analyzer/protocol/file/File.cc b/src/analyzer/protocol/file/File.cc index f827d4fe79..961efc224b 100644 --- a/src/analyzer/protocol/file/File.cc +++ b/src/analyzer/protocol/file/File.cc @@ -14,7 +14,6 @@ namespace zeek::analyzer::file File_Analyzer::File_Analyzer(const char* name, Connection* conn) : TCP_ApplicationAnalyzer(name, conn) { - buffer_len = 0; } void File_Analyzer::DeliverStream(int len, const u_char* data, bool orig) diff --git a/src/analyzer/protocol/file/File.h b/src/analyzer/protocol/file/File.h index c2841bf609..7cca4f7520 100644 --- a/src/analyzer/protocol/file/File.h +++ b/src/analyzer/protocol/file/File.h @@ -27,8 +27,8 @@ protected: void Identify(); static const int BUFFER_SIZE = 1024; - char buffer[BUFFER_SIZE]; - int buffer_len; + char buffer[BUFFER_SIZE] = {0}; + int buffer_len = 0; std::string file_id_orig; std::string file_id_resp; }; diff --git a/src/analyzer/protocol/rpc/RPC.h b/src/analyzer/protocol/rpc/RPC.h index 88dcfd6c83..5b1264d813 100644 --- a/src/analyzer/protocol/rpc/RPC.h +++ b/src/analyzer/protocol/rpc/RPC.h @@ -99,15 +99,15 @@ protected: uint32_t cred_flavor, stamp; uint32_t uid, gid; std::vector auxgids; - uint32_t verf_flavor; + uint32_t verf_flavor = 0; u_char* call_buf; // copy of original call buffer std::string machinename; double start_time; double last_time; - int rpc_len; // size of the full RPC call, incl. xid and msg_type - int call_n; // size of call buf - int header_len; // size of data before the arguments - bool valid_call; // whether call was well-formed + int rpc_len = 0; // size of the full RPC call, incl. xid and msg_type + int call_n = 0; // size of call buf + int header_len = 0; // size of data before the arguments + bool valid_call = true; // whether call was well-formed ValPtr v; // single (perhaps compound) value corresponding to call }; diff --git a/src/input/readers/raw/Raw.h b/src/input/readers/raw/Raw.h index 7ebb334301..a1b4e43825 100644 --- a/src/input/readers/raw/Raw.h +++ b/src/input/readers/raw/Raw.h @@ -78,7 +78,7 @@ private: int64_t offset; - int pipes[6]; + int pipes[6] = {-1}; pid_t childpid; enum IoChannels diff --git a/src/iosource/PktDumper.h b/src/iosource/PktDumper.h index 5ad513f061..ed7689e478 100644 --- a/src/iosource/PktDumper.h +++ b/src/iosource/PktDumper.h @@ -99,7 +99,7 @@ protected: struct Properties { std::string path; - double open_time; + double open_time = 0.0; }; /** diff --git a/src/logging/Manager.cc b/src/logging/Manager.cc index 872648551e..733b62ba81 100644 --- a/src/logging/Manager.cc +++ b/src/logging/Manager.cc @@ -90,7 +90,7 @@ struct Manager::Stream WriterMap writers; // Writers indexed by id/path pair. - bool enable_remote; + bool enable_remote = false; ~Stream(); }; diff --git a/src/probabilistic/CardinalityCounter.h b/src/probabilistic/CardinalityCounter.h index 41913e1753..e3f97b7b33 100644 --- a/src/probabilistic/CardinalityCounter.h +++ b/src/probabilistic/CardinalityCounter.h @@ -168,7 +168,7 @@ private: * error is 1.04/sqrt(m), so the actual cardinality will be the * estimate +/- 1.04/sqrt(m) with approximately 68% probability. */ - uint64_t m; + uint64_t m = 0; /** * These are the actual buckets that are storing an estimate of the @@ -184,9 +184,9 @@ private: * buckets that are 0 and this is used in the small error correction. * alpha_m is a multiplicative constant used in the algorithm. */ - uint64_t V; - double alpha_m; - int p; // the log2 of m + uint64_t V = 0; + double alpha_m = 0.0; + int p = 0; // the log2 of m }; } // namespace zeek::probabilistic::detail diff --git a/src/probabilistic/Hasher.h b/src/probabilistic/Hasher.h index c98b630d95..2bc47d9315 100644 --- a/src/probabilistic/Hasher.h +++ b/src/probabilistic/Hasher.h @@ -130,8 +130,8 @@ protected: virtual HasherType Type() const = 0; private: - size_t k; - seed_t seed; + size_t k = 0; + seed_t seed = {0}; }; /** diff --git a/src/script_opt/ZAM/ZBody.h b/src/script_opt/ZAM/ZBody.h index 0d3d594a8c..512fa56b15 100644 --- a/src/script_opt/ZAM/ZBody.h +++ b/src/script_opt/ZAM/ZBody.h @@ -73,7 +73,7 @@ private: const char* func_name = nullptr; const ZInst* insts = nullptr; - unsigned int ninst; + unsigned int ninst = 0; FrameReMap frame_denizens; int frame_size;