diff options
| author | 2022-09-04 11:20:16 +0100 | |
|---|---|---|
| committer | 2022-09-04 11:28:10 +0100 | |
| commit | 7076a766db6759ac698fea880616ede9545207cc (patch) | |
| tree | 24b03370daca1f5ff92a728d9e6abe135a3a2359 /src/modules | |
| parent | Fix some warnings noticed by the readability-* clang-tidy checkers. (diff) | |
Use auto in places where it is really obvious what the type is.
Diffstat (limited to 'src/modules')
25 files changed, 42 insertions, 49 deletions
diff --git a/src/modules/extra/m_geo_maxmind.cpp b/src/modules/extra/m_geo_maxmind.cpp index 7066f886f..c0b7793b2 100644 --- a/src/modules/extra/m_geo_maxmind.cpp +++ b/src/modules/extra/m_geo_maxmind.cpp @@ -137,7 +137,7 @@ public: // Create a Location object and cache it. const std::string cname(country_name.utf8_string, country_name.data_size); - Geolocation::Location* location = new Geolocation::Location(code, cname); + auto location = new Geolocation::Location(code, cname); locations[code] = location; return location; } diff --git a/src/modules/extra/m_ldap.cpp b/src/modules/extra/m_ldap.cpp index a770036e7..3c224f9dc 100644 --- a/src/modules/extra/m_ldap.cpp +++ b/src/modules/extra/m_ldap.cpp @@ -218,7 +218,7 @@ public: for (unsigned int x = 0; x < attributes.size(); ++x) { const LDAPModification& l = attributes[x]; - LDAPMod* mod = new LDAPMod; + auto mod = new LDAPMod(); mods[x] = mod; if (l.op == LDAPModification::LDAP_ADD) @@ -368,8 +368,7 @@ public: void Bind(LDAPInterface* i, const std::string& who, const std::string& pass) override { - LDAPBind* b = new LDAPBind(this, i, who, pass); - QueueRequest(b); + QueueRequest(new LDAPBind(this, i, who, pass)); } void Search(LDAPInterface* i, const std::string& base, const std::string& filter) override @@ -377,32 +376,27 @@ public: if (!i) throw LDAPException("No interface"); - LDAPSearch* s = new LDAPSearch(this, i, base, searchscope, filter); - QueueRequest(s); + QueueRequest(new LDAPSearch(this, i, base, searchscope, filter)); } void Add(LDAPInterface* i, const std::string& dn, LDAPMods& attributes) override { - LDAPAdd* add = new LDAPAdd(this, i, dn, attributes); - QueueRequest(add); + QueueRequest(new LDAPAdd(this, i, dn, attributes)); } void Del(LDAPInterface* i, const std::string& dn) override { - LDAPDel* del = new LDAPDel(this, i, dn); - QueueRequest(del); + QueueRequest(new LDAPDel(this, i, dn)); } void Modify(LDAPInterface* i, const std::string& base, LDAPMods& attributes) override { - LDAPModify* mod = new LDAPModify(this, i, base, attributes); - QueueRequest(mod); + QueueRequest(new LDAPModify(this, i, base, attributes)); } void Compare(LDAPInterface* i, const std::string& dn, const std::string& attr, const std::string& val) override { - LDAPCompare* comp = new LDAPCompare(this, i, dn, attr, val); - QueueRequest(comp); + QueueRequest(new LDAPCompare(this, i, dn, attr, val)); } private: @@ -566,7 +560,7 @@ public: ServiceMap::iterator curr = LDAPServices.find(id); if (curr == LDAPServices.end()) { - LDAPService* conn = new LDAPService(this, tag); + auto conn = new LDAPService(this, tag); conns[id] = conn; ServerInstance->Modules.AddService(*conn); diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index 51fdef06c..c8ffc33a2 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -474,7 +474,7 @@ void ModuleSQL::ReadConfig(ConfigStatus& status) ConnMap::iterator curr = connections.find(id); if (curr == connections.end()) { - SQLConnection* conn = new SQLConnection(this, tag); + auto conn = new SQLConnection(this, tag); conns.emplace(id, conn); ServerInstance->Modules.AddService(*conn); } diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp index e388f377f..1e6ae751c 100644 --- a/src/modules/extra/m_pgsql.cpp +++ b/src/modules/extra/m_pgsql.cpp @@ -561,7 +561,7 @@ public: ConnMap::iterator curr = connections.find(id); if (curr == connections.end()) { - SQLConn* conn = new SQLConn(this, tag); + auto conn = new SQLConn(this, tag); if (conn->status != DEAD) { conns.emplace(id, conn); diff --git a/src/modules/extra/m_sqlite3.cpp b/src/modules/extra/m_sqlite3.cpp index 0ebd22452..d5b780996 100644 --- a/src/modules/extra/m_sqlite3.cpp +++ b/src/modules/extra/m_sqlite3.cpp @@ -264,7 +264,7 @@ public: if (!stdalgo::string::equalsci(tag->getString("module"), "sqlite")) continue; - SQLConn* conn = new SQLConn(this, tag); + auto conn = new SQLConn(this, tag); conns.emplace(tag->getString("id"), conn); ServerInstance->Modules.AddService(*conn); } diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index d1f31817c..aa3879295 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -663,7 +663,7 @@ private: void VerifyCertificate() { - ssl_cert* certinfo = new ssl_cert; + auto certinfo = new ssl_cert(); this->certificate = certinfo; unsigned int certstatus; diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp index a18cb6379..d418fbb92 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -570,7 +570,7 @@ private: void VerifyCertificate() { X509* cert; - ssl_cert* certinfo = new ssl_cert; + auto certinfo = new ssl_cert(); this->certificate = certinfo; unsigned int n; unsigned char md[EVP_MAX_MD_SIZE]; diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp index cb51f458d..ccc4c3f08 100644 --- a/src/modules/m_callerid.cpp +++ b/src/modules/m_callerid.cpp @@ -103,7 +103,7 @@ struct CallerIDExtInfo final void* old = GetRaw(container); if (old) this->Delete(nullptr, old); - callerid_data* dat = new callerid_data; + auto dat = new callerid_data(); SetRaw(container, dat); irc::commasepstream s(value); diff --git a/src/modules/m_cap.cpp b/src/modules/m_cap.cpp index fcfea8a01..46b3354f7 100644 --- a/src/modules/m_cap.cpp +++ b/src/modules/m_cap.cpp @@ -92,7 +92,7 @@ class Cap::ManagerImpl final if (mod == creator) return; - CapModData* capmoddata = new CapModData; + auto capmoddata = new CapModData(); cd.add(this, capmoddata); for (const auto& [_, cap] : caps) diff --git a/src/modules/m_cban.cpp b/src/modules/m_cban.cpp index 57099b257..403d7622f 100644 --- a/src/modules/m_cban.cpp +++ b/src/modules/m_cban.cpp @@ -127,8 +127,7 @@ public: return CmdResult::FAILURE; } const char *reason = (parameters.size() > 2) ? parameters[2].c_str() : "No reason supplied"; - CBan* r = new CBan(ServerInstance->Time(), duration, user->nick, reason, parameters[0]); - + auto r = new CBan(ServerInstance->Time(), duration, user->nick, reason, parameters[0]); if (ServerInstance->XLines->AddLine(r, user)) { if (!duration) diff --git a/src/modules/m_connectban.cpp b/src/modules/m_connectban.cpp index 535702101..d6d844d7e 100644 --- a/src/modules/m_connectban.cpp +++ b/src/modules/m_connectban.cpp @@ -146,7 +146,7 @@ public: if (i->second >= threshold) { // Create Z-line for set duration. - ZLine* zl = new ZLine(ServerInstance->Time(), banduration, MODNAME "@" + ServerInstance->Config->ServerName, banmessage, mask.str()); + auto zl = new ZLine(ServerInstance->Time(), banduration, MODNAME "@" + ServerInstance->Config->ServerName, banmessage, mask.str()); if (!ServerInstance->XLines->AddLine(zl, nullptr)) { delete zl; diff --git a/src/modules/m_customprefix.cpp b/src/modules/m_customprefix.cpp index 5dce050a3..98836f72d 100644 --- a/src/modules/m_customprefix.cpp +++ b/src/modules/m_customprefix.cpp @@ -99,7 +99,7 @@ public: try { - CustomPrefixMode* mh = new CustomPrefixMode(this, name, letter[0], prefix[0], tag); + auto mh = new CustomPrefixMode(this, name, letter[0], prefix[0], tag); modes.push_back(mh); ServerInstance->Modules.AddService(*mh); } diff --git a/src/modules/m_dccallow.cpp b/src/modules/m_dccallow.cpp index 3384741f3..059c28761 100644 --- a/src/modules/m_dccallow.cpp +++ b/src/modules/m_dccallow.cpp @@ -128,7 +128,7 @@ public: // Remove the old list and create a new one. Unset(user, false); - dccallowlist* list = new dccallowlist(); + auto list = new dccallowlist(); irc::spacesepstream ts(value); while (!ts.StreamEnd()) diff --git a/src/modules/m_filter.cpp b/src/modules/m_filter.cpp index cb1d6a893..06b920b31 100644 --- a/src/modules/m_filter.cpp +++ b/src/modules/m_filter.cpp @@ -465,7 +465,7 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtar } else if (f->action == FA_SHUN && (ServerInstance->XLines->GetFactory("SHUN"))) { - Shun* sh = new Shun(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, user->GetIPString()); + auto sh = new Shun(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, user->GetIPString()); ServerInstance->SNO.WriteGlobalSno('f', InspIRCd::Format("%s (%s) was shunned for %s (expires on %s) because their message to %s matched %s (%s)", user->nick.c_str(), sh->Displayable().c_str(), InspIRCd::DurationString(f->duration).c_str(), InspIRCd::TimeString(ServerInstance->Time() + f->duration).c_str(), @@ -479,7 +479,7 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtar } else if (f->action == FA_GLINE) { - GLine* gl = new GLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, "*", user->GetIPString()); + auto gl = new GLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, "*", user->GetIPString()); ServerInstance->SNO.WriteGlobalSno('f', InspIRCd::Format("%s (%s) was G-lined for %s (expires on %s) because their message to %s matched %s (%s)", user->nick.c_str(), gl->Displayable().c_str(), InspIRCd::DurationString(f->duration).c_str(), InspIRCd::TimeString(ServerInstance->Time() + f->duration).c_str(), @@ -493,7 +493,7 @@ ModResult ModuleFilter::OnUserPreMessage(User* user, const MessageTarget& msgtar } else if (f->action == FA_ZLINE) { - ZLine* zl = new ZLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, user->GetIPString()); + auto zl = new ZLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, user->GetIPString()); ServerInstance->SNO.WriteGlobalSno('f', InspIRCd::Format("%s (%s) was Z-lined for %s (expires on %s) because their message to %s matched %s (%s)", user->nick.c_str(), zl->Displayable().c_str(), InspIRCd::DurationString(f->duration).c_str(), InspIRCd::TimeString(ServerInstance->Time() + f->duration).c_str(), @@ -570,7 +570,7 @@ ModResult ModuleFilter::OnPreCommand(std::string& command, CommandBase::Params& if (f->action == FA_GLINE) { /* Note: We G-line *@IP so that if their host doesn't resolve the G-line still applies. */ - GLine* gl = new GLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, "*", user->GetIPString()); + auto gl = new GLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, "*", user->GetIPString()); ServerInstance->SNO.WriteGlobalSno('f', InspIRCd::Format("%s (%s) was G-lined for %s (expires on %s) because their %s message matched %s (%s)", user->nick.c_str(), gl->Displayable().c_str(), InspIRCd::DurationString(f->duration).c_str(), @@ -586,7 +586,7 @@ ModResult ModuleFilter::OnPreCommand(std::string& command, CommandBase::Params& } if (f->action == FA_ZLINE) { - ZLine* zl = new ZLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, user->GetIPString()); + auto zl = new ZLine(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, user->GetIPString()); ServerInstance->SNO.WriteGlobalSno('f', InspIRCd::Format("%s (%s) was Z-lined for %s (expires on %s) because their %s message matched %s (%s)", user->nick.c_str(), zl->Displayable().c_str(), InspIRCd::DurationString(f->duration).c_str(), @@ -603,7 +603,7 @@ ModResult ModuleFilter::OnPreCommand(std::string& command, CommandBase::Params& else if (f->action == FA_SHUN && (ServerInstance->XLines->GetFactory("SHUN"))) { /* Note: We shun *!*@IP so that if their host doesnt resolve the shun still applies. */ - Shun* sh = new Shun(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, user->GetIPString()); + auto sh = new Shun(ServerInstance->Time(), f->duration, ServerInstance->Config->ServerName, f->reason, user->GetIPString()); ServerInstance->SNO.WriteGlobalSno('f', InspIRCd::Format("%s (%s) was shunned for %s (expires on %s) because their %s message matched %s (%s)", user->nick.c_str(), sh->Displayable().c_str(), InspIRCd::DurationString(f->duration).c_str(), diff --git a/src/modules/m_haproxy.cpp b/src/modules/m_haproxy.cpp index b0523583e..ba9ab7e32 100644 --- a/src/modules/m_haproxy.cpp +++ b/src/modules/m_haproxy.cpp @@ -210,7 +210,7 @@ private: // Create a fake ssl_cert for the user. Ideally we should use the user's // TLS client certificate here but as of 2018-10-16 this is not forwarded // by HAProxy. - ssl_cert* cert = new ssl_cert; + auto cert = new ssl_cert(); cert->error = "HAProxy does not forward client TLS certificates"; cert->invalid = true; cert->revoked = true; diff --git a/src/modules/m_pbkdf2.cpp b/src/modules/m_pbkdf2.cpp index 259f326ad..7d4486a22 100644 --- a/src/modules/m_pbkdf2.cpp +++ b/src/modules/m_pbkdf2.cpp @@ -230,7 +230,7 @@ public: if (hp->IsKDF()) return; - PBKDF2Provider* prov = new PBKDF2Provider(this, hp); + auto prov = new PBKDF2Provider(this, hp); providers.push_back(prov); ServerInstance->Modules.AddService(*prov); diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp index 0d1d01f91..4001150b5 100644 --- a/src/modules/m_rline.cpp +++ b/src/modules/m_rline.cpp @@ -68,7 +68,7 @@ public: { if (ZlineOnMatch) { - ZLine* zl = new ZLine(ServerInstance->Time(), duration ? expiry - ServerInstance->Time() : 0, MODNAME "@" + ServerInstance->Config->ServerName, reason, u->GetIPString()); + auto zl = new ZLine(ServerInstance->Time(), duration ? expiry - ServerInstance->Time() : 0, MODNAME "@" + ServerInstance->Config->ServerName, reason, u->GetIPString()); if (ServerInstance->XLines->AddLine(zl, nullptr)) { if (!duration) diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp index 07a3119dc..d13b0443d 100644 --- a/src/modules/m_shun.cpp +++ b/src/modules/m_shun.cpp @@ -113,7 +113,7 @@ public: expr = parameters[1]; } - Shun* r = new Shun(ServerInstance->Time(), duration, user->nick, expr, target); + auto r = new Shun(ServerInstance->Time(), duration, user->nick, expr, target); if (ServerInstance->XLines->AddLine(r, user)) { if (!duration) diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp index 77a5d6ec1..5802a768d 100644 --- a/src/modules/m_silence.cpp +++ b/src/modules/m_silence.cpp @@ -206,7 +206,7 @@ public: // Remove the old list and create a new one. Unset(user, false); - SilenceList* list = new SilenceList(); + auto list = new SilenceList(); irc::spacesepstream ts(value); while (!ts.StreamEnd()) diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 520868978..c5fbcdce2 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -242,7 +242,7 @@ void ModuleSpanningTree::ConnectServer(std::shared_ptr<Link> x, std::shared_ptr< if (sa.family() != AF_UNSPEC) { // Create a TreeServer object that will start connecting immediately in the background - TreeSocket* newsocket = new TreeSocket(x, y, sa); + auto newsocket = new TreeSocket(x, y, sa); if (!newsocket->HasFd()) { ServerInstance->SNO.WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: %s.", @@ -265,7 +265,7 @@ void ModuleSpanningTree::ConnectServer(std::shared_ptr<Link> x, std::shared_ptr< start_type = DNS::QUERY_A; } - ServernameResolver* snr = new ServernameResolver(*DNS, x->IPAddr, x, start_type, y); + auto snr = new ServernameResolver(*DNS, x->IPAddr, x, start_type, y); try { DNS->Process(snr); @@ -870,7 +870,7 @@ ModuleSpanningTree::~ModuleSpanningTree() { ServerInstance->PI = &ServerInstance->DefaultProtocolInterface; - Server* newsrv = new Server(ServerInstance->Config->GetSID(), ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc); + auto newsrv = new Server(ServerInstance->Config->GetSID(), ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc); SetLocalUsersServer(newsrv); delete Utils; diff --git a/src/modules/m_spanningtree/resolvers.cpp b/src/modules/m_spanningtree/resolvers.cpp index e77db55a5..6c4577be1 100644 --- a/src/modules/m_spanningtree/resolvers.cpp +++ b/src/modules/m_spanningtree/resolvers.cpp @@ -70,7 +70,7 @@ void ServernameResolver::OnLookupComplete(const DNS::Query *r) TreeServer* CheckDupe = Utils->FindServer(MyLink->Name); if (!CheckDupe) /* Check that nobody tried to connect it successfully while we were resolving */ { - TreeSocket* newsocket = new TreeSocket(MyLink, myautoconnect, sa); + auto newsocket = new TreeSocket(MyLink, myautoconnect, sa); if (!newsocket->HasFd()) { /* Something barfed, show the opers */ @@ -91,7 +91,7 @@ void ServernameResolver::OnError(const DNS::Query *r) if (query == DNS::QUERY_AAAA) { - ServernameResolver* snr = new ServernameResolver(this->manager, host, MyLink, DNS::QUERY_A, myautoconnect); + auto snr = new ServernameResolver(this->manager, host, MyLink, DNS::QUERY_A, myautoconnect); try { this->manager->Process(snr); @@ -119,7 +119,7 @@ bool SecurityIPResolver::CheckIPv4() if (query != DNS::QUERY_AAAA) return false; - SecurityIPResolver* res = new SecurityIPResolver(mine, this->manager, host, MyLink, DNS::QUERY_A); + auto res = new SecurityIPResolver(mine, this->manager, host, MyLink, DNS::QUERY_A); try { this->manager->Process(res); diff --git a/src/modules/m_spanningtree/server.cpp b/src/modules/m_spanningtree/server.cpp index cddcd03b4..34bfadc88 100644 --- a/src/modules/m_spanningtree/server.cpp +++ b/src/modules/m_spanningtree/server.cpp @@ -66,7 +66,7 @@ CmdResult CommandServer::HandleServer(TreeServer* ParentOfThis, Params& params) TreeServer* route = ParentOfThis->GetRoute(); std::shared_ptr<Link> lnk = Utils->FindLink(route->GetName()); - TreeServer* Node = new TreeServer(servername, description, sid, ParentOfThis, ParentOfThis->GetSocket(), lnk ? lnk->Hidden : false); + auto Node = new TreeServer(servername, description, sid, ParentOfThis, ParentOfThis->GetSocket(), lnk ? lnk->Hidden : false); HandleExtra(Node, params); diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index 616b7c199..b4e1fd0ef 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -218,7 +218,7 @@ void SpanningTreeUtilities::RefreshIPCache() ValidIPs.push_back(L->IPAddr); else if (this->Creator->DNS) { - SecurityIPResolver* sr = new SecurityIPResolver(Creator, *this->Creator->DNS, L->IPAddr, L, DNS::QUERY_AAAA); + auto sr = new SecurityIPResolver(Creator, *this->Creator->DNS, L->IPAddr, L, DNS::QUERY_AAAA); try { this->Creator->DNS->Process(sr); diff --git a/src/modules/m_sslinfo.cpp b/src/modules/m_sslinfo.cpp index 511efe21f..dd054cbf0 100644 --- a/src/modules/m_sslinfo.cpp +++ b/src/modules/m_sslinfo.cpp @@ -88,7 +88,7 @@ public: if (container->extype != this->extype) return; - ssl_cert* cert = new ssl_cert; + auto cert = new ssl_cert(); Set(static_cast<User*>(container), cert, false); std::stringstream s(value); @@ -448,7 +448,7 @@ public: } // Create a fake ssl_cert for the user. - ssl_cert* cert = new ssl_cert; + auto cert = new ssl_cert(); if (!hash.empty()) { iter = flags->find("certfp-" + hash); diff --git a/src/modules/m_svshold.cpp b/src/modules/m_svshold.cpp index 287c83563..8561d060e 100644 --- a/src/modules/m_svshold.cpp +++ b/src/modules/m_svshold.cpp @@ -136,7 +136,7 @@ public: user->WriteNotice("*** Invalid duration for SVSHOLD."); return CmdResult::FAILURE; } - SVSHold* r = new SVSHold(ServerInstance->Time(), duration, user->nick, parameters[2], parameters[0]); + auto r = new SVSHold(ServerInstance->Time(), duration, user->nick, parameters[2], parameters[0]); if (ServerInstance->XLines->AddLine(r, user)) { |
