From 98e4ddfb21d285c8b675788c155bb204822fbd4a Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Thu, 6 Feb 2020 11:25:42 +0000 Subject: Use C++11 inline initialisation for class members. --- src/modules/extra/m_ldap.cpp | 12 +++++------- src/modules/extra/m_mysql.cpp | 19 ++++--------------- src/modules/extra/m_pgsql.cpp | 20 +++++++------------- src/modules/extra/m_sqlite3.cpp | 8 ++------ src/modules/extra/m_ssl_gnutls.cpp | 11 +++-------- src/modules/extra/m_ssl_openssl.cpp | 3 +-- src/modules/m_alias.cpp | 3 +-- src/modules/m_banredirect.cpp | 3 +-- src/modules/m_bcrypt.cpp | 3 +-- src/modules/m_callerid.cpp | 4 +--- src/modules/m_channames.cpp | 3 +-- src/modules/m_cloaking.cpp | 9 +++------ src/modules/m_connflood.cpp | 9 ++------- src/modules/m_dccallow.cpp | 3 +-- src/modules/m_filter.cpp | 3 +-- src/modules/m_hideoper.cpp | 9 ++++----- src/modules/m_httpd.cpp | 9 +++------ src/modules/m_httpd_stats.cpp | 3 +-- src/modules/m_ircv3_batch.cpp | 3 +-- src/modules/m_ircv3_labeledresponse.cpp | 7 ++----- src/modules/m_ircv3_msgid.cpp | 5 ++--- src/modules/m_ircv3_servertime.cpp | 6 ++---- src/modules/m_joinflood.cpp | 7 ++++--- src/modules/m_kicknorejoin.cpp | 3 +-- src/modules/m_ldapauth.cpp | 10 ++++++---- src/modules/m_nickflood.cpp | 7 ++++--- src/modules/m_permchannels.cpp | 6 ++---- src/modules/m_repeat.cpp | 14 ++++++-------- src/modules/m_restrictchans.cpp | 7 +------ src/modules/m_rline.cpp | 3 +-- src/modules/m_sasl.cpp | 6 ++---- src/modules/m_services_account.cpp | 3 +-- src/modules/m_spanningtree/commandbuilder.h | 5 +---- src/modules/m_spanningtree/main.cpp | 2 -- src/modules/m_spanningtree/main.h | 4 ++-- src/modules/m_spanningtree/netburst.cpp | 4 ++-- src/modules/m_spanningtree/treeserver.cpp | 8 -------- src/modules/m_spanningtree/treeserver.h | 8 ++++---- src/modules/m_spanningtree/treesocket.h | 10 +++++++--- src/modules/m_spanningtree/treesocket1.cpp | 10 ++++++---- src/modules/m_spanningtree/utils.cpp | 3 +-- src/modules/m_spanningtree/utils.h | 8 ++++++-- src/modules/m_sqloper.cpp | 5 ++--- src/modules/m_websocket.cpp | 6 ++---- 44 files changed, 110 insertions(+), 184 deletions(-) (limited to 'src/modules') diff --git a/src/modules/extra/m_ldap.cpp b/src/modules/extra/m_ldap.cpp index 6dfd575e9..46b76ab5f 100644 --- a/src/modules/extra/m_ldap.cpp +++ b/src/modules/extra/m_ldap.cpp @@ -54,16 +54,14 @@ class LDAPRequest public: LDAPService* service; LDAPInterface* inter; - LDAPMessage* message; /* message returned by ldap_ */ - LDAPResult* result; /* final result */ + LDAPMessage* message = nullptr; /* message returned by ldap_ */ + LDAPResult* result = nullptr; /* final result */ struct timeval tv; QueryType type; LDAPRequest(LDAPService* s, LDAPInterface* i) : service(s) , inter(i) - , message(NULL) - , result(NULL) { type = QUERY_UNKNOWN; tv.tv_sec = 0; @@ -183,9 +181,9 @@ class LDAPCompare : public LDAPRequest class LDAPService : public LDAPProvider, public SocketThread { - LDAP* con; + LDAP* con = nullptr; reference config; - time_t last_connect; + time_t last_connect = 0; int searchscope; time_t timeout; @@ -275,7 +273,7 @@ class LDAPService : public LDAPProvider, public SocketThread LDAPService(Module* c, ConfigTag* tag) : LDAPProvider(c, "LDAP/" + tag->getString("id")) - , con(NULL), config(tag), last_connect(0) + , config(tag) { std::string scope = config->getString("searchscope"); if (stdalgo::string::equalsci(scope, "base")) diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index 179a6790b..f4207dcb2 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -133,12 +133,11 @@ typedef std::deque ResultQueue; class ModuleSQL : public Module { public: - DispatcherThread* Dispatcher; + DispatcherThread* Dispatcher = nullptr; QueryQueue qq; // MUST HOLD MUTEX ResultQueue rq; // MUST HOLD MUTEX ConnMap connections; // main thread only - ModuleSQL(); void init() override; ~ModuleSQL(); void ReadConfig(ConfigStatus& status) override; @@ -163,15 +162,13 @@ class MySQLresult : public SQL::Result { public: SQL::Error err; - int currentrow; - int rows; + int currentrow = 0; + int rows = 0; std::vector colnames; std::vector fieldlists; MySQLresult(MYSQL_RES* res, int affected_rows) : err(SQL::SUCCESS) - , currentrow(0) - , rows(0) { if (affected_rows >= 1) { @@ -216,8 +213,6 @@ class MySQLresult : public SQL::Result MySQLresult(SQL::Error& e) : err(e) - , currentrow(0) - , rows(0) { } @@ -301,14 +296,13 @@ class SQLConnection : public SQL::Provider public: reference config; - MYSQL *connection; + MYSQL* connection = nullptr; std::mutex lock; // This constructor creates an SQLConnection object with the given credentials, but does not connect yet. SQLConnection(Module* p, ConfigTag* tag) : SQL::Provider(p, tag->getString("id")) , config(tag) - , connection(NULL) { } @@ -439,11 +433,6 @@ class SQLConnection : public SQL::Provider } }; -ModuleSQL::ModuleSQL() - : Dispatcher(NULL) -{ -} - void ModuleSQL::init() { if (mysql_library_init(0, NULL, NULL)) diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp index 567c2b30f..8702ab8a4 100644 --- a/src/modules/extra/m_pgsql.cpp +++ b/src/modules/extra/m_pgsql.cpp @@ -92,8 +92,8 @@ struct QueueItem class PgSQLresult : public SQL::Result { PGresult* res; - int currentrow; - int rows; + int currentrow = 0; + int rows = 0; std::vector colnames; void getColNames() @@ -105,7 +105,8 @@ class PgSQLresult : public SQL::Result } } public: - PgSQLresult(PGresult* result) : res(result), currentrow(0) + PgSQLresult(PGresult* result) + : res(result) { rows = PQntuples(res); if (!rows) @@ -177,15 +178,13 @@ class SQLConn : public SQL::Provider, public EventHandler public: reference conf; /* The entry */ std::deque queue; - PGconn* sql; /* PgSQL database connection handle */ - SQLstatus status; /* PgSQL database connection status */ + PGconn* sql = nullptr; /* PgSQL database connection handle */ + SQLstatus status = CWRITE; /* PgSQL database connection status */ QueueItem qinprog; /* If there is currently a query in progress */ SQLConn(Module* Creator, ConfigTag* tag) : SQL::Provider(Creator, tag->getString("id")) , conf(tag) - , sql(NULL) - , status(CWRITE) , qinprog(NULL, "") { if (!DoConnect()) @@ -536,12 +535,7 @@ class ModulePgSQL : public Module { public: ConnMap connections; - ReconnectTimer* retimer; - - ModulePgSQL() - : retimer(NULL) - { - } + ReconnectTimer* retimer = nullptr; ~ModulePgSQL() { diff --git a/src/modules/extra/m_sqlite3.cpp b/src/modules/extra/m_sqlite3.cpp index e60217dff..1b315df27 100644 --- a/src/modules/extra/m_sqlite3.cpp +++ b/src/modules/extra/m_sqlite3.cpp @@ -49,15 +49,11 @@ typedef insp::flat_map ConnMap; class SQLite3Result : public SQL::Result { public: - int currentrow; - int rows; + int currentrow = 0; + int rows = 0; std::vector columns; std::vector fieldlists; - SQLite3Result() : currentrow(0), rows(0) - { - } - int Rows() override { return rows; diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index 1c193df6a..42192325c 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -611,10 +611,10 @@ namespace GnuTLS class GnuTLSIOHook : public SSLIOHook { private: - gnutls_session_t sess; - issl_status status; + gnutls_session_t sess = nullptr; + issl_status status = ISSL_NONE; #ifdef INSPIRCD_GNUTLS_HAS_CORK - size_t gbuffersize; + size_t gbuffersize = 0; #endif void CloseSession() @@ -909,11 +909,6 @@ info_done_dealloc: public: GnuTLSIOHook(IOHookProvider* hookprov, StreamSocket* sock, unsigned int flags) : SSLIOHook(hookprov) - , sess(NULL) - , status(ISSL_NONE) -#ifdef INSPIRCD_GNUTLS_HAS_CORK - , gbuffersize(0) -#endif { gnutls_init(&sess, flags); gnutls_transport_set_ptr(sess, reinterpret_cast(sock)); diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp index 5cbdb9dcf..b7916b857 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -480,7 +480,7 @@ class OpenSSLIOHook : public SSLIOHook private: SSL* sess; issl_status status; - bool data_to_write; + bool data_to_write = false; // Returns 1 if handshake succeeded, 0 if it is still in progress, -1 if it failed int Handshake(StreamSocket* user) @@ -647,7 +647,6 @@ class OpenSSLIOHook : public SSLIOHook : SSLIOHook(hookprov) , sess(session) , status(ISSL_NONE) - , data_to_write(false) { // Create BIO instance and store a pointer to the socket in it which will be used by the read and write functions BIO* bio = BIO_new(biomethods); diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp index cef93c19b..664b36207 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -77,7 +77,7 @@ class ModuleAlias : public Module UserModeReference botmode; // Whether we are actively executing an alias. - bool active; + bool active = false; public: void ReadConfig(ConfigStatus& status) override @@ -116,7 +116,6 @@ class ModuleAlias : public Module ModuleAlias() : botmode(this, "bot") - , active(false) { } diff --git a/src/modules/m_banredirect.cpp b/src/modules/m_banredirect.cpp index d43f92ee8..f0737351a 100644 --- a/src/modules/m_banredirect.cpp +++ b/src/modules/m_banredirect.cpp @@ -248,14 +248,13 @@ class BanRedirect : public ModeWatcher class ModuleBanRedirect : public Module { BanRedirect re; - bool nofollow; + bool nofollow = false; ChanModeReference limitmode; ChanModeReference redirectmode; public: ModuleBanRedirect() : re(this) - , nofollow(false) , limitmode(this, "limit") , redirectmode(this, "redirect") { diff --git a/src/modules/m_bcrypt.cpp b/src/modules/m_bcrypt.cpp index d98a564fe..2bf09acfa 100644 --- a/src/modules/m_bcrypt.cpp +++ b/src/modules/m_bcrypt.cpp @@ -42,7 +42,7 @@ class BCryptProvider : public HashProvider } public: - unsigned int rounds; + unsigned int rounds = 10; std::string Generate(const std::string& data, const std::string& salt) { @@ -74,7 +74,6 @@ class BCryptProvider : public HashProvider BCryptProvider(Module* parent) : HashProvider(parent, "bcrypt", 60) - , rounds(10) { } }; diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp index 0d4a8b752..93867a38c 100644 --- a/src/modules/m_callerid.cpp +++ b/src/modules/m_callerid.cpp @@ -49,7 +49,7 @@ class callerid_data typedef insp::flat_set UserSet; typedef std::vector CallerIdDataSet; - time_t lastnotify; + time_t lastnotify = 0; /** Users I accept messages from */ @@ -59,8 +59,6 @@ class callerid_data */ CallerIdDataSet wholistsme; - callerid_data() : lastnotify(0) { } - std::string ToString(bool human) const { std::ostringstream oss; diff --git a/src/modules/m_channames.cpp b/src/modules/m_channames.cpp index a3add12a2..a5de222c0 100644 --- a/src/modules/m_channames.cpp +++ b/src/modules/m_channames.cpp @@ -50,13 +50,12 @@ bool NewIsChannelHandler::Call(const std::string& channame) class ModuleChannelNames : public Module { std::function rememberer; - bool badchan; + bool badchan = false; ChanModeReference permchannelmode; public: ModuleChannelNames() : rememberer(ServerInstance->IsChannel) - , badchan(false) , permchannelmode(this, "permanent") { } diff --git a/src/modules/m_cloaking.cpp b/src/modules/m_cloaking.cpp index 0fa7e0983..406ab410b 100644 --- a/src/modules/m_cloaking.cpp +++ b/src/modules/m_cloaking.cpp @@ -85,18 +85,15 @@ typedef std::vector CloakList; class CloakUser : public ModeHandler { public: - bool active; + bool active = false; SimpleExtItem ext; std::string debounce_uid; - time_t debounce_ts; - int debounce_count; + time_t debounce_ts = 0; + int debounce_count = 0; CloakUser(Module* source) : ModeHandler(source, "cloak", 'x', PARAM_NONE, MODETYPE_USER) - , active(false) , ext(source, "cloaked_host", ExtensionItem::EXT_USER) - , debounce_ts(0) - , debounce_count(0) { } diff --git a/src/modules/m_connflood.cpp b/src/modules/m_connflood.cpp index 7dfad4440..66b25cbb0 100644 --- a/src/modules/m_connflood.cpp +++ b/src/modules/m_connflood.cpp @@ -30,18 +30,13 @@ class ModuleConnFlood : public Module unsigned int seconds; unsigned int timeout; unsigned int boot_wait; - unsigned int conns; + unsigned int conns = 0; unsigned int maxconns; - bool throttled; + bool throttled = false; time_t first; std::string quitmsg; public: - ModuleConnFlood() - : conns(0), throttled(false) - { - } - Version GetVersion() override { return Version("Connection throttle", VF_VENDOR); diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp index 20f602005..84189947e 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -371,14 +371,13 @@ class ModuleDCCAllow : public Module { DCCAllowExt ext; CommandDccallow cmd; - bool blockchat; + bool blockchat = false; std::string defaultaction; public: ModuleDCCAllow() : ext(this) , cmd(this, ext) - , blockchat(false) { } diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index dfd8b6b42..dfce068e8 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -191,7 +191,7 @@ class ModuleFilter { typedef insp::flat_set ExemptTargetSet; - bool initing; + bool initing = true; bool notifyuser; bool warnonselfmsg; RegexFactory* factory; @@ -348,7 +348,6 @@ bool ModuleFilter::AppliesToMe(User* user, FilterResult* filter, int iflags) ModuleFilter::ModuleFilter() : ServerProtocol::SyncEventListener(this) , Stats::EventListener(this) - , initing(true) , filtcommand(this) , RegexEngine(this, "regex") { diff --git a/src/modules/m_hideoper.cpp b/src/modules/m_hideoper.cpp index bad967a1c..67c9c39d7 100644 --- a/src/modules/m_hideoper.cpp +++ b/src/modules/m_hideoper.cpp @@ -36,10 +36,10 @@ class HideOper : public SimpleUserModeHandler { public: - size_t opercount; + size_t opercount = 0; - HideOper(Module* Creator) : SimpleUserModeHandler(Creator, "hideoper", 'H') - , opercount(0) + HideOper(Module* Creator) + : SimpleUserModeHandler(Creator, "hideoper", 'H') { oper = true; } @@ -66,7 +66,7 @@ class ModuleHideOper { private: HideOper hm; - bool active; + bool active = false; public: ModuleHideOper() @@ -74,7 +74,6 @@ class ModuleHideOper , Who::EventListener(this) , Whois::LineEventListener(this) , hm(this) - , active(false) { } diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp index b0f4ecf0b..e649cfaca 100644 --- a/src/modules/m_httpd.cpp +++ b/src/modules/m_httpd.cpp @@ -70,12 +70,12 @@ class HttpServerSocket : public BufferedSocket, public Timer, public insp::intru HTTPHeaders headers; std::string body; size_t total_buffers; - int status_code; + int status_code = 0; /** True if this object is in the cull list */ - bool waitingcull; - bool messagecomplete; + bool waitingcull = false; + bool messagecomplete = false; bool Tick(time_t currtime) override { @@ -205,9 +205,6 @@ class HttpServerSocket : public BufferedSocket, public Timer, public insp::intru : BufferedSocket(newfd) , Timer(timeoutsec) , ip(IP) - , status_code(0) - , waitingcull(false) - , messagecomplete(false) { if ((!via->iohookprovs.empty()) && (via->iohookprovs.back())) { diff --git a/src/modules/m_httpd_stats.cpp b/src/modules/m_httpd_stats.cpp index eb6544914..93dcfdfe3 100644 --- a/src/modules/m_httpd_stats.cpp +++ b/src/modules/m_httpd_stats.cpp @@ -408,14 +408,13 @@ class ModuleHttpStats : public Module, public HTTPRequestEventListener private: HTTPdAPI API; ISupport::EventProvider isupportevprov; - bool enableparams; + bool enableparams = false; public: ModuleHttpStats() : HTTPRequestEventListener(this) , API(this) , isupportevprov(this) - , enableparams(false) { isevprov = &isupportevprov; } diff --git a/src/modules/m_ircv3_batch.cpp b/src/modules/m_ircv3_batch.cpp index 638118b2d..f6a18ad27 100644 --- a/src/modules/m_ircv3_batch.cpp +++ b/src/modules/m_ircv3_batch.cpp @@ -65,7 +65,7 @@ class IRCv3::Batch::ManagerImpl : public Manager ClientProtocol::EventProvider protoevprov; IntExtItem batchbits; BatchList active_batches; - bool unloading; + bool unloading = false; bool ShouldSendTag(LocalUser* user, const ClientProtocol::MessageTagData& tagdata) override { @@ -101,7 +101,6 @@ class IRCv3::Batch::ManagerImpl : public Manager , cap(mod, "batch") , protoevprov(mod, "BATCH") , batchbits(mod, "batchbits", ExtensionItem::EXT_USER) - , unloading(false) { } diff --git a/src/modules/m_ircv3_labeledresponse.cpp b/src/modules/m_ircv3_labeledresponse.cpp index 4f2117209..a56376ed2 100644 --- a/src/modules/m_ircv3_labeledresponse.cpp +++ b/src/modules/m_ircv3_labeledresponse.cpp @@ -27,14 +27,13 @@ class LabeledResponseTag : public ClientProtocol::MessageTagProvider const Cap::Capability& cap; public: - LocalUser* labeluser; + LocalUser* labeluser = nullptr; std::string label; const std::string labeltag; LabeledResponseTag(Module* mod, const Cap::Capability& capref) : ClientProtocol::MessageTagProvider(mod) , cap(capref) - , labeluser(NULL) , labeltag("label") { } @@ -76,7 +75,7 @@ class ModuleIRCv3LabeledResponse : public Module ClientProtocol::EventProvider ackmsgprov; ClientProtocol::EventProvider labelmsgprov; insp::aligned_storage firstmsg; - size_t msgcount; + size_t msgcount = 0; void FlushFirstMsg(LocalUser* user) { @@ -95,8 +94,6 @@ class ModuleIRCv3LabeledResponse : public Module , batchcap(this) , ackmsgprov(this, "ACK") , labelmsgprov(this, "labeled") - , msgcount(0) - { } diff --git a/src/modules/m_ircv3_msgid.cpp b/src/modules/m_ircv3_msgid.cpp index 7d1c99899..f30000912 100644 --- a/src/modules/m_ircv3_msgid.cpp +++ b/src/modules/m_ircv3_msgid.cpp @@ -50,14 +50,13 @@ class MsgIdTag : public ClientProtocol::MessageTagProvider class MsgIdGenerator { - uint64_t counter; + uint64_t counter = 0; std::string strid; const std::string::size_type baselen; public: MsgIdGenerator() - : counter(0) - , strid(InspIRCd::Format("%s~%lu~", ServerInstance->Config->GetSID().c_str(), ServerInstance->startup_time)) + : strid(InspIRCd::Format("%s~%lu~", ServerInstance->Config->GetSID().c_str(), ServerInstance->startup_time)) , baselen(strid.length()) { } diff --git a/src/modules/m_ircv3_servertime.cpp b/src/modules/m_ircv3_servertime.cpp index decd66414..210e97ee9 100644 --- a/src/modules/m_ircv3_servertime.cpp +++ b/src/modules/m_ircv3_servertime.cpp @@ -28,8 +28,8 @@ class ServerTimeTag , public IRCv3::CapTag , public ServerProtocol::MessageEventListener { - time_t lasttime; - long lasttimens; + time_t lasttime = 0; + long lasttimens = 0; std::string lasttimestring; void RefreshTimeString() @@ -53,8 +53,6 @@ class ServerTimeTag : IRCv3::ServerTime::Manager(mod) , IRCv3::CapTag(mod, "server-time", "time") , ServerProtocol::MessageEventListener(mod) - , lasttime(0) - , lasttimens(0) { tagprov = this; } diff --git a/src/modules/m_joinflood.cpp b/src/modules/m_joinflood.cpp index 1c4550443..ffc0c5147 100644 --- a/src/modules/m_joinflood.cpp +++ b/src/modules/m_joinflood.cpp @@ -42,11 +42,12 @@ class joinfloodsettings unsigned int secs; unsigned int joins; time_t reset; - time_t unlocktime; - unsigned int counter; + time_t unlocktime = 0; + unsigned int counter = 0; joinfloodsettings(unsigned int b, unsigned int c) - : secs(b), joins(c), unlocktime(0), counter(0) + : secs(b) + , joins(c) { reset = ServerInstance->Time() + secs; } diff --git a/src/modules/m_kicknorejoin.cpp b/src/modules/m_kicknorejoin.cpp index bf5abecc1..bc9d7b033 100644 --- a/src/modules/m_kicknorejoin.cpp +++ b/src/modules/m_kicknorejoin.cpp @@ -93,11 +93,10 @@ class KickRejoinData */ class KickRejoin : public ParamMode > { - const unsigned int max; + const unsigned int max = 60; public: KickRejoin(Module* Creator) : ParamMode >(Creator, "kicknorejoin", 'J') - , max(60) { syntax = ""; } diff --git a/src/modules/m_ldapauth.cpp b/src/modules/m_ldapauth.cpp index 6275dc140..089f428b7 100644 --- a/src/modules/m_ldapauth.cpp +++ b/src/modules/m_ldapauth.cpp @@ -40,9 +40,9 @@ class BindInterface : public LDAPInterface const std::string provider; const std::string uid; std::string DN; - bool checkingAttributes; - bool passed; - int attrCount; + bool checkingAttributes = false; + bool passed = false; + int attrCount = 0; static std::string SafeReplace(const std::string& text, std::map& replacements) { @@ -100,7 +100,9 @@ class BindInterface : public LDAPInterface public: BindInterface(Module* c, const std::string& p, const std::string& u, const std::string& dn) : LDAPInterface(c) - , provider(p), uid(u), DN(dn), checkingAttributes(false), passed(false), attrCount(0) + , provider(p) + , uid(u) + , DN(dn) { } diff --git a/src/modules/m_nickflood.cpp b/src/modules/m_nickflood.cpp index 32e26c1cf..5a2406500 100644 --- a/src/modules/m_nickflood.cpp +++ b/src/modules/m_nickflood.cpp @@ -36,11 +36,12 @@ class nickfloodsettings unsigned int secs; unsigned int nicks; time_t reset; - time_t unlocktime; - unsigned int counter; + time_t unlocktime = 0; + unsigned int counter = 0; nickfloodsettings(unsigned int b, unsigned int c) - : secs(b), nicks(c), unlocktime(0), counter(0) + : secs(b) + , nicks(c) { reset = ServerInstance->Time() + secs; } diff --git a/src/modules/m_permchannels.cpp b/src/modules/m_permchannels.cpp index 1b572a574..252694952 100644 --- a/src/modules/m_permchannels.cpp +++ b/src/modules/m_permchannels.cpp @@ -169,16 +169,14 @@ class ModulePermanentChannels { PermChannel p; - bool dirty; - bool loaded; + bool dirty = false; + bool loaded = false; bool save_listmodes; public: ModulePermanentChannels() : Timer(0, true) , p(this) - , dirty(false) - , loaded(false) { } diff --git a/src/modules/m_repeat.cpp b/src/modules/m_repeat.cpp index c4359bcbd..de3a8b3f3 100644 --- a/src/modules/m_repeat.cpp +++ b/src/modules/m_repeat.cpp @@ -79,18 +79,16 @@ class RepeatMode : public ParamMode > struct MemberInfo { RepeatItemList ItemList; - unsigned int Counter; - MemberInfo() : Counter(0) {} + unsigned int Counter = 0; }; struct ModuleSettings { - unsigned int MaxLines; - unsigned int MaxSecs; - unsigned int MaxBacklog; - unsigned int MaxDiff; - unsigned int MaxMessageSize; - ModuleSettings() : MaxLines(0), MaxSecs(0), MaxBacklog(0), MaxDiff() { } + unsigned int MaxLines = 0; + unsigned int MaxSecs = 0; + unsigned int MaxBacklog = 0; + unsigned int MaxDiff = 0; + unsigned int MaxMessageSize = 0; }; std::vector mx[2]; diff --git a/src/modules/m_restrictchans.cpp b/src/modules/m_restrictchans.cpp index ded33cdf4..ba88afa68 100644 --- a/src/modules/m_restrictchans.cpp +++ b/src/modules/m_restrictchans.cpp @@ -31,7 +31,7 @@ typedef insp::flat_set AllowChans; class ModuleRestrictChans : public Module { AllowChans allowchans; - bool allowregistered; + bool allowregistered = false; bool CanCreateChannel(LocalUser* user, const std::string& name) { @@ -52,11 +52,6 @@ class ModuleRestrictChans : public Module } public: - ModuleRestrictChans() - : allowregistered(false) - { - } - void ReadConfig(ConfigStatus& status) override { AllowChans newallows; diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp index e595b50e3..45f3aafbf 100644 --- a/src/modules/m_rline.cpp +++ b/src/modules/m_rline.cpp @@ -226,7 +226,7 @@ class ModuleRLine : public Module, public Stats::EventListener RLineFactory f; CommandRLine r; bool MatchOnNickChange; - bool initing; + bool initing = true; RegexFactory* factory; public: @@ -235,7 +235,6 @@ class ModuleRLine : public Module, public Stats::EventListener , rxfactory(this, "regex") , f(rxfactory) , r(this, f) - , initing(true) { } diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp index 3fbffd07e..df67a0037 100644 --- a/src/modules/m_sasl.cpp +++ b/src/modules/m_sasl.cpp @@ -174,9 +174,9 @@ class SaslAuthenticator private: std::string agent; LocalUser* user; - SaslState state; + SaslState state = SASL_INIT; SaslResult result; - bool state_announced; + bool state_announced = false; void SendHostIP(UserCertificateAPI& sslapi) { @@ -191,8 +191,6 @@ class SaslAuthenticator public: SaslAuthenticator(LocalUser* user_, const std::string& method, UserCertificateAPI& sslapi) : user(user_) - , state(SASL_INIT) - , state_announced(false) { SendHostIP(sslapi); diff --git a/src/modules/m_services_account.cpp b/src/modules/m_services_account.cpp index 55b95f60b..d362e162a 100644 --- a/src/modules/m_services_account.cpp +++ b/src/modules/m_services_account.cpp @@ -157,7 +157,7 @@ class ModuleServicesAccount Channel_r chanregmode; User_r userregmode; AccountExtItemImpl accountname; - bool checking_ban; + bool checking_ban = false; public: ModuleServicesAccount() @@ -172,7 +172,6 @@ class ModuleServicesAccount , chanregmode(this) , userregmode(this) , accountname(this) - , checking_ban(false) { } diff --git a/src/modules/m_spanningtree/commandbuilder.h b/src/modules/m_spanningtree/commandbuilder.h index 527b53584..927213d74 100644 --- a/src/modules/m_spanningtree/commandbuilder.h +++ b/src/modules/m_spanningtree/commandbuilder.h @@ -35,7 +35,7 @@ class CmdBuilder ClientProtocol::TagMap tags; /** The size of tags within the contents. */ - size_t tagsize; + size_t tagsize = 0; /** Fires the ServerProtocol::MessageEventListener::OnBuildMessage event for a server target. */ void FireEvent(Server* target, const char* cmd, ClientProtocol::TagMap& taglist); @@ -49,7 +49,6 @@ class CmdBuilder public: CmdBuilder(const char* cmd) : content(1, ':') - , tagsize(0) { content.append(ServerInstance->Config->GetSID()); push(cmd); @@ -58,7 +57,6 @@ class CmdBuilder CmdBuilder(TreeServer* src, const char* cmd) : content(1, ':') - , tagsize(0) { content.append(src->GetId()); push(cmd); @@ -67,7 +65,6 @@ class CmdBuilder CmdBuilder(User* src, const char* cmd) : content(1, ':') - , tagsize(0) { content.append(src->uuid); push(cmd); diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index cdfcdd3b7..e595c680f 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -47,7 +47,6 @@ ModuleSpanningTree::ModuleSpanningTree() , rsquit(this) , map(this) , commands(this) - , currmembid(0) , broadcasteventprov(this, "event/server-broadcast") , linkeventprov(this, "event/server-link") , messageeventprov(this, "event/server-message") @@ -56,7 +55,6 @@ ModuleSpanningTree::ModuleSpanningTree() , servicetag(this) , DNS(this, "DNS") , tagevprov(this) - , loopCall(false) { } diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index 839c859af..40f2724f5 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -94,7 +94,7 @@ class ModuleSpanningTree /** Next membership id assigned when a local user joins a channel */ - Membership::Id currmembid; + Membership::Id currmembid = 0; /** The specialized ProtocolInterface that is assigned to ServerInstance->PI on load */ @@ -129,7 +129,7 @@ class ModuleSpanningTree /** Set to true if inside a spanningtree call, to prevent sending * xlines and other things back to their source */ - bool loopCall; + bool loopCall = false; /** Constructor */ diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp index 7d7755a6b..8bde08a39 100644 --- a/src/modules/m_spanningtree/netburst.cpp +++ b/src/modules/m_spanningtree/netburst.cpp @@ -39,12 +39,12 @@ class FModeBuilder : public CmdBuilder { static const size_t maxline = 480; std::string params; - unsigned int modes; + unsigned int modes = 0; std::string::size_type startpos; public: FModeBuilder(Channel* chan) - : CmdBuilder("FMODE"), modes(0) + : CmdBuilder("FMODE") { push(chan->name).push_int(chan->age).push_raw(" +"); startpos = str().size(); diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp index e40f22e91..48bedb839 100644 --- a/src/modules/m_spanningtree/treeserver.cpp +++ b/src/modules/m_spanningtree/treeserver.cpp @@ -43,14 +43,10 @@ TreeServer::TreeServer() , rawversion(INSPIRCD_VERSION) , Socket(NULL) , behind_bursting(0) - , isdead(false) , pingtimer(this) , ServerUser(ServerInstance->FakeClient) , age(ServerInstance->Time()) , UserCount(ServerInstance->Users.LocalUserCount()) - , OperCount(0) - , rtt(0) - , StartBurst(0) , Hidden(false) { AddHashEntry(); @@ -65,14 +61,10 @@ TreeServer::TreeServer(const std::string& Name, const std::string& Desc, const s , Parent(Above) , Socket(Sock) , behind_bursting(Parent->behind_bursting) - , isdead(false) , pingtimer(this) , ServerUser(new FakeUser(id, this)) , age(ServerInstance->Time()) , UserCount(0) - , OperCount(0) - , rtt(0) - , StartBurst(0) , Hidden(Hide) { ServerInstance->Logs.Log(MODNAME, LOG_DEBUG, "New server %s behind_bursting %u", GetName().c_str(), behind_bursting); diff --git a/src/modules/m_spanningtree/treeserver.h b/src/modules/m_spanningtree/treeserver.h index e6471d77e..1e7c30a1a 100644 --- a/src/modules/m_spanningtree/treeserver.h +++ b/src/modules/m_spanningtree/treeserver.h @@ -66,7 +66,7 @@ class TreeServer : public Server /** True if this server has been lost in a split and is awaiting destruction */ - bool isdead; + bool isdead = false; /** Timer handling PINGing the server and killing it on timeout */ @@ -91,7 +91,7 @@ class TreeServer : public Server const time_t age; unsigned int UserCount; /* How many users are on this server? [note: doesn't care about +i] */ - unsigned int OperCount; /* How many opers are on this server? */ + unsigned int OperCount = 0; /* How many opers are on this server? */ /** We use this constructor only to create the 'root' item, Utils->TreeRoot, which * represents our own server. Therefore, it has no route, no parent, and @@ -157,11 +157,11 @@ class TreeServer : public Server /** Round trip time of last ping */ - unsigned long rtt; + unsigned long rtt = 0; /** When we received BURST from this server, used to calculate total burst time at ENDBURST. */ - uint64_t StartBurst; + uint64_t StartBurst = 0; /** True if this server is hidden */ diff --git a/src/modules/m_spanningtree/treesocket.h b/src/modules/m_spanningtree/treesocket.h index 8f59fb3ba..36cde5715 100644 --- a/src/modules/m_spanningtree/treesocket.h +++ b/src/modules/m_spanningtree/treesocket.h @@ -99,14 +99,18 @@ class TreeSocket : public BufferedSocket std::string linkID; /* Description for this link */ ServerState LinkState; /* Link state */ CapabData* capab; /* Link setup data (held until burst is sent) */ - TreeServer* MyRoot; /* The server we are talking to */ - unsigned int proto_version; /* Remote protocol version */ + + /* The server we are talking to */ + TreeServer* MyRoot = NULL; + + /* Remote protocol version */ + unsigned int proto_version = 0; /** True if we've sent our burst. * This only changes the behavior of message translation for 1202 protocol servers and it can be * removed once 1202 support is dropped. */ - bool burstsent; + bool burstsent = false; /** Checks if the given servername and sid are both free */ diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp index 6119b1d38..9e4dd5ddd 100644 --- a/src/modules/m_spanningtree/treesocket1.cpp +++ b/src/modules/m_spanningtree/treesocket1.cpp @@ -40,8 +40,9 @@ * and only do minor initialization tasks ourselves. */ TreeSocket::TreeSocket(Link* link, Autoconnect* myac, const irc::sockets::sockaddrs& dest) - : linkID(link->Name), LinkState(CONNECTING), MyRoot(NULL), proto_version(0) - , burstsent(false), age(ServerInstance->Time()) + : linkID(link->Name) + , LinkState(CONNECTING) + , age(ServerInstance->Time()) { capab = new CapabData; capab->link = link; @@ -77,8 +78,9 @@ TreeSocket::TreeSocket(Link* link, Autoconnect* myac, const irc::sockets::sockad */ TreeSocket::TreeSocket(int newfd, ListenSocket* via, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server) : BufferedSocket(newfd) - , linkID("inbound from " + client->addr()), LinkState(WAIT_AUTH_1), MyRoot(NULL), proto_version(0) - , burstsent(false), age(ServerInstance->Time()) + , linkID("inbound from " + client->addr()) + , LinkState(WAIT_AUTH_1) + , age(ServerInstance->Time()) { capab = new CapabData; capab->capab_phase = 0; diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index 33f605912..0f839efe7 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -107,8 +107,7 @@ TreeServer* SpanningTreeUtilities::FindRouteTarget(const std::string& target) } SpanningTreeUtilities::SpanningTreeUtilities(ModuleSpanningTree* C) - : Creator(C), TreeRoot(NULL) - , PingFreq(60) // XXX: TreeServer constructor reads this and TreeRoot is created before the config is read, so init it to something (value doesn't matter) to avoid a valgrind warning in TimerManager on unload + : Creator(C) { ServerInstance->Timers.AddTimer(&RefreshTimer); } diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h index eb9d76652..01c474f8e 100644 --- a/src/modules/m_spanningtree/utils.h +++ b/src/modules/m_spanningtree/utils.h @@ -86,7 +86,7 @@ class SpanningTreeUtilities : public classbase unsigned int PingWarnTime; /** This variable represents the root of the server tree */ - TreeServer *TreeRoot; + TreeServer *TreeRoot = nullptr; /** IPs allowed to link to us */ std::vector ValidIPs; @@ -107,8 +107,12 @@ class SpanningTreeUtilities : public classbase std::vector > AutoconnectBlocks; /** Ping frequency of server to server links + * XXX: TreeServer constructor reads this and TreeRoot is created before the + * config is read, so init it to something (value doesn't matter) to avoid a + * valgrind warning in TimerManager on unload */ - unsigned int PingFreq; + unsigned int PingFreq = 60; + /** Initialise utility class */ diff --git a/src/modules/m_sqloper.cpp b/src/modules/m_sqloper.cpp index 9ff52b600..9d7ace7d8 100644 --- a/src/modules/m_sqloper.cpp +++ b/src/modules/m_sqloper.cpp @@ -164,7 +164,7 @@ class OperQuery : public SQL::Query class ModuleSQLOper : public Module { // Whether OperQuery is running - bool active; + bool active = false; std::string query; // Stores oper blocks from DB std::vector my_blocks; @@ -172,8 +172,7 @@ class ModuleSQLOper : public Module public: ModuleSQLOper() - : active(false) - , SQL(this, "SQL") + : SQL(this, "SQL") { } diff --git a/src/modules/m_websocket.cpp b/src/modules/m_websocket.cpp index 0c240b022..817a5861d 100644 --- a/src/modules/m_websocket.cpp +++ b/src/modules/m_websocket.cpp @@ -121,8 +121,8 @@ class WebSocketHook : public IOHookMiddle // Clients sending ping or pong frames faster than this are killed static const time_t MINPINGPONGDELAY = 10; - State state; - time_t lastpingpong; + State state = STATE_HTTPREQ; + time_t lastpingpong = 0; WebSocketConfig& config; static size_t FillHeader(unsigned char* outbuf, size_t sendlength, OpCode opcode) @@ -408,8 +408,6 @@ class WebSocketHook : public IOHookMiddle public: WebSocketHook(IOHookProvider* Prov, StreamSocket* sock, WebSocketConfig& cfg) : IOHookMiddle(Prov) - , state(STATE_HTTPREQ) - , lastpingpong(0) , config(cfg) { sock->AddIOHook(this); -- cgit v1.3.1-10-gc9f91