diff options
| author | 2022-07-22 18:33:38 +0100 | |
|---|---|---|
| committer | 2022-07-22 18:53:21 +0100 | |
| commit | 648f813f8c89e6e7d0ed5bda2c2149bee2babb09 (patch) | |
| tree | 5357669e57bb381c80bfdbd24ed4057a99db8e5b /src/modules/extra | |
| parent | Update author list. (diff) | |
Switch from NULL to nullptr.
Diffstat (limited to 'src/modules/extra')
| -rw-r--r-- | src/modules/extra/m_argon2.cpp | 2 | ||||
| -rw-r--r-- | src/modules/extra/m_geo_maxmind.cpp | 14 | ||||
| -rw-r--r-- | src/modules/extra/m_ldap.cpp | 38 | ||||
| -rw-r--r-- | src/modules/extra/m_mysql.cpp | 4 | ||||
| -rw-r--r-- | src/modules/extra/m_pgsql.cpp | 10 | ||||
| -rw-r--r-- | src/modules/extra/m_regex_posix.cpp | 4 | ||||
| -rw-r--r-- | src/modules/extra/m_sqlite3.cpp | 6 | ||||
| -rw-r--r-- | src/modules/extra/m_ssl_gnutls.cpp | 12 | ||||
| -rw-r--r-- | src/modules/extra/m_ssl_mbedtls.cpp | 14 | ||||
| -rw-r--r-- | src/modules/extra/m_ssl_openssl.cpp | 22 | ||||
| -rw-r--r-- | src/modules/extra/m_sslrehashsignal.cpp | 2 |
11 files changed, 64 insertions, 64 deletions
diff --git a/src/modules/extra/m_argon2.cpp b/src/modules/extra/m_argon2.cpp index 58e11eef0..d15fcf9bd 100644 --- a/src/modules/extra/m_argon2.cpp +++ b/src/modules/extra/m_argon2.cpp @@ -186,7 +186,7 @@ public: void ReadConfig(ConfigStatus& status) override { - ProviderConfig defaultConfig("argon2", NULL); + ProviderConfig defaultConfig("argon2", nullptr); argon2i.config = ProviderConfig("argon2i", &defaultConfig); argon2d.config = ProviderConfig("argon2d", &defaultConfig); argon2id.config = ProviderConfig("argon2id", &defaultConfig); diff --git a/src/modules/extra/m_geo_maxmind.cpp b/src/modules/extra/m_geo_maxmind.cpp index 6a69d4a0e..80535c8d3 100644 --- a/src/modules/extra/m_geo_maxmind.cpp +++ b/src/modules/extra/m_geo_maxmind.cpp @@ -98,7 +98,7 @@ public: // Attempt to locate this user. location = GetLocation(user->client_sa); if (!location) - return NULL; + return nullptr; // We found the user. Cache their location for future use. ext.Set(user, location); @@ -109,19 +109,19 @@ public: { // Skip trying to look up a UNIX socket. if (sa.family() != AF_INET && sa.family() != AF_INET6) - return NULL; + return nullptr; // Attempt to look up the socket address. int result; MMDB_lookup_result_s lookup = MMDB_lookup_sockaddr(&mmdb, &sa.sa, &result); if (result != MMDB_SUCCESS || !lookup.found_entry) - return NULL; + return nullptr; // Attempt to retrieve the country code. MMDB_entry_data_s country_code; - result = MMDB_get_value(&lookup.entry, &country_code, "country", "iso_code", NULL); + result = MMDB_get_value(&lookup.entry, &country_code, "country", "iso_code", nullptr); if (result != MMDB_SUCCESS || !country_code.has_data || country_code.type != MMDB_DATA_TYPE_UTF8_STRING || country_code.data_size != 2) - return NULL; + return nullptr; // If the country has been seen before then use our cached Location object. const std::string code(country_code.utf8_string, country_code.data_size); @@ -131,9 +131,9 @@ public: // Attempt to retrieve the country name. MMDB_entry_data_s country_name; - result = MMDB_get_value(&lookup.entry, &country_name, "country", "names", "en", NULL); + result = MMDB_get_value(&lookup.entry, &country_name, "country", "names", "en", nullptr); if (result != MMDB_SUCCESS || !country_name.has_data || country_name.type != MMDB_DATA_TYPE_UTF8_STRING) - return NULL; + return nullptr; // Create a Location object and cache it. const std::string cname(country_name.utf8_string, country_name.data_size); diff --git a/src/modules/extra/m_ldap.cpp b/src/modules/extra/m_ldap.cpp index c1dfa40d9..ce327c3e8 100644 --- a/src/modules/extra/m_ldap.cpp +++ b/src/modules/extra/m_ldap.cpp @@ -79,7 +79,7 @@ public: virtual ~LDAPRequest() { delete result; - if (message != NULL) + if (message != nullptr) ldap_msgfree(message); } @@ -244,14 +244,14 @@ public: static void FreeMods(LDAPMod** mods) { - for (unsigned int i = 0; mods[i] != NULL; ++i) + for (unsigned int i = 0; mods[i] != nullptr; ++i) { LDAPMod* mod = mods[i]; - if (mod->mod_type != NULL) + if (mod->mod_type != nullptr) free(mod->mod_type); - if (mod->mod_values != NULL) + if (mod->mod_values != nullptr) { - for (unsigned int j = 0; mod->mod_values[j] != NULL; ++j) + for (unsigned int j = 0; mod->mod_values[j] != nullptr; ++j) free(mod->mod_values[j]); delete[] mod->mod_values; } @@ -267,7 +267,7 @@ private: throw LDAPException("Unable to connect to LDAP service " + this->name + ": reconnecting too fast"); last_connect = ServerInstance->Time(); - ldap_unbind_ext(this->con, NULL, NULL); + ldap_unbind_ext(this->con, nullptr, nullptr); Connect(); } @@ -276,8 +276,8 @@ private: int ret = ldap_set_option(this->con, option, value); if (ret != LDAP_OPT_SUCCESS) { - ldap_unbind_ext(this->con, NULL, NULL); - this->con = NULL; + ldap_unbind_ext(this->con, nullptr, nullptr); + this->con = nullptr; } return ret; } @@ -342,7 +342,7 @@ public: this->UnlockQueue(); - ldap_unbind_ext(this->con, NULL, NULL); + ldap_unbind_ext(this->con, nullptr, nullptr); } void Connect() @@ -433,14 +433,14 @@ private: LDAPAttributes attributes; char* dn = ldap_get_dn(this->con, cur); - if (dn != NULL) + if (dn != nullptr) { attributes["dn"].push_back(dn); ldap_memfree(dn); - dn = NULL; + dn = nullptr; } - BerElement* ber = NULL; + BerElement* ber = nullptr; for (char* attr = ldap_first_attribute(this->con, cur, &ber); attr; attr = ldap_next_attribute(this->con, cur, ber)) { @@ -455,7 +455,7 @@ private: ldap_value_free_len(vals); ldap_memfree(attr); } - if (ber != NULL) + if (ber != nullptr) ber_free(ber, 0); ldap_result->messages.push_back(attributes); @@ -656,7 +656,7 @@ int LDAPBind::run() cred.bv_val = strdup(pass.c_str()); cred.bv_len = pass.length(); - int i = ldap_sasl_bind_s(service->GetConnection(), who.c_str(), LDAP_SASL_SIMPLE, &cred, NULL, NULL, NULL); + int i = ldap_sasl_bind_s(service->GetConnection(), who.c_str(), LDAP_SASL_SIMPLE, &cred, nullptr, nullptr, nullptr); free(cred.bv_val); @@ -670,7 +670,7 @@ std::string LDAPBind::info() int LDAPSearch::run() { - return ldap_search_ext_s(service->GetConnection(), base.c_str(), searchscope, filter.c_str(), NULL, 0, NULL, NULL, &tv, 0, &message); + return ldap_search_ext_s(service->GetConnection(), base.c_str(), searchscope, filter.c_str(), nullptr, 0, nullptr, nullptr, &tv, 0, &message); } std::string LDAPSearch::info() @@ -681,7 +681,7 @@ std::string LDAPSearch::info() int LDAPAdd::run() { LDAPMod** mods = LDAPService::BuildMods(attributes); - int i = ldap_add_ext_s(service->GetConnection(), dn.c_str(), mods, NULL, NULL); + int i = ldap_add_ext_s(service->GetConnection(), dn.c_str(), mods, nullptr, nullptr); LDAPService::FreeMods(mods); return i; } @@ -693,7 +693,7 @@ std::string LDAPAdd::info() int LDAPDel::run() { - return ldap_delete_ext_s(service->GetConnection(), dn.c_str(), NULL, NULL); + return ldap_delete_ext_s(service->GetConnection(), dn.c_str(), nullptr, nullptr); } std::string LDAPDel::info() @@ -704,7 +704,7 @@ std::string LDAPDel::info() int LDAPModify::run() { LDAPMod** mods = LDAPService::BuildMods(attributes); - int i = ldap_modify_ext_s(service->GetConnection(), base.c_str(), mods, NULL, NULL); + int i = ldap_modify_ext_s(service->GetConnection(), base.c_str(), mods, nullptr, nullptr); LDAPService::FreeMods(mods); return i; } @@ -720,7 +720,7 @@ int LDAPCompare::run() cred.bv_val = strdup(val.c_str()); cred.bv_len = val.length(); - int ret = ldap_compare_ext_s(service->GetConnection(), dn.c_str(), attr.c_str(), &cred, NULL, NULL); + int ret = ldap_compare_ext_s(service->GetConnection(), dn.c_str(), attr.c_str(), &cred, nullptr, nullptr); free(cred.bv_val); diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index 9e1406578..ead27295e 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -327,7 +327,7 @@ public: const std::string pass = config->getString("pass"); const std::string dbname = config->getString("name"); unsigned int port = static_cast<unsigned int>(config->getUInt("port", 3306, 1, 65535)); - if (!mysql_real_connect(connection, host.c_str(), user.c_str(), pass.c_str(), dbname.c_str(), port, NULL, CLIENT_IGNORE_SIGPIPE)) + if (!mysql_real_connect(connection, host.c_str(), user.c_str(), pass.c_str(), dbname.c_str(), port, nullptr, CLIENT_IGNORE_SIGPIPE)) { ServerInstance->Logs.Normal(MODNAME, "Unable to connect to the %s MySQL server: %s", GetId().c_str(), mysql_error(connection)); @@ -435,7 +435,7 @@ public: void ModuleSQL::init() { - if (mysql_library_init(0, NULL, NULL)) + if (mysql_library_init(0, nullptr, nullptr)) throw ModuleException(this, "Unable to initialise the MySQL library!"); Dispatcher = new DispatcherThread(this); diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp index 30d2690a6..f2e23d2e0 100644 --- a/src/modules/extra/m_pgsql.cpp +++ b/src/modules/extra/m_pgsql.cpp @@ -198,7 +198,7 @@ public: SQLConn(Module* Creator, std::shared_ptr<ConfigTag> tag) : SQL::Provider(Creator, tag->getString("id")) , conf(tag) - , qinprog(NULL, "") + , qinprog(nullptr, "") { if (!DoConnect()) DelayReconnect(); @@ -384,7 +384,7 @@ restart: } delete qinprog.c; - qinprog = QueueItem(NULL, ""); + qinprog = QueueItem(nullptr, ""); goto restart; } else @@ -520,7 +520,7 @@ restart: if(sql) { PQfinish(sql); - sql = NULL; + sql = nullptr; } } }; @@ -599,7 +599,7 @@ public: { conn->qinprog.c->OnError(err); delete conn->qinprog.c; - conn->qinprog.c = NULL; + conn->qinprog.c = nullptr; } std::deque<QueueItem>::iterator j = conn->queue.begin(); while (j != conn->queue.end()) @@ -620,7 +620,7 @@ public: bool ReconnectTimer::Tick() { - mod->retimer = NULL; + mod->retimer = nullptr; mod->ReadConf(); delete this; return false; diff --git a/src/modules/extra/m_regex_posix.cpp b/src/modules/extra/m_regex_posix.cpp index 377939867..819046e2b 100644 --- a/src/modules/extra/m_regex_posix.cpp +++ b/src/modules/extra/m_regex_posix.cpp @@ -47,7 +47,7 @@ public: return; // Retrieve the size of the error message and allocate a buffer. - size_t errorsize = regerror(error, ®ex, NULL, 0); + size_t errorsize = regerror(error, ®ex, nullptr, 0); std::vector<char> errormsg(errorsize); // Retrieve the error message and free the buffer. @@ -64,7 +64,7 @@ public: bool IsMatch(const std::string& text) override { - return !regexec(®ex, text.c_str(), 0, NULL, 0); + return !regexec(®ex, text.c_str(), 0, nullptr, 0); } std::optional<Regex::MatchCollection> Matches(const std::string& text) override diff --git a/src/modules/extra/m_sqlite3.cpp b/src/modules/extra/m_sqlite3.cpp index a388d3797..797f54a51 100644 --- a/src/modules/extra/m_sqlite3.cpp +++ b/src/modules/extra/m_sqlite3.cpp @@ -106,11 +106,11 @@ public: , config(tag) { std::string host = tag->getString("hostname"); - if (sqlite3_open_v2(host.c_str(), &conn, SQLITE_OPEN_READWRITE, 0) != SQLITE_OK) + if (sqlite3_open_v2(host.c_str(), &conn, SQLITE_OPEN_READWRITE, nullptr) != SQLITE_OK) { // Even in case of an error conn must be closed sqlite3_close(conn); - conn = NULL; + conn = nullptr; ServerInstance->Logs.Normal(MODNAME, "WARNING: Could not open DB with id: " + tag->getString("id")); } } @@ -128,7 +128,7 @@ public: { SQLite3Result res; sqlite3_stmt *stmt; - int err = sqlite3_prepare_v2(conn, q.c_str(), static_cast<int>(q.length()), &stmt, NULL); + int err = sqlite3_prepare_v2(conn, q.c_str(), static_cast<int>(q.length()), &stmt, nullptr); if (err != SQLITE_OK) { SQL::Error error(SQL::QSEND_FAIL, sqlite3_errmsg(conn)); diff --git a/src/modules/extra/m_ssl_gnutls.cpp b/src/modules/extra/m_ssl_gnutls.cpp index 11ec78db0..b21ce982f 100644 --- a/src/modules/extra/m_ssl_gnutls.cpp +++ b/src/modules/extra/m_ssl_gnutls.cpp @@ -129,7 +129,7 @@ namespace GnuTLS gnutls_hash_hd_t is_digest; if (gnutls_hash_init(&is_digest, hash) < 0) throw Exception("Unknown hash type " + hashname); - gnutls_hash_deinit(is_digest, NULL); + gnutls_hash_deinit(is_digest, nullptr); } gnutls_digest_algorithm_t get() const { return hash; } @@ -311,7 +311,7 @@ namespace GnuTLS ret.append(token); gnutls_priority_t test; - if (gnutls_priority_init(&test, ret.c_str(), NULL) < 0) + if (gnutls_priority_init(&test, ret.c_str(), nullptr) < 0) { // The new token broke the priority string, revert to the previously working one ServerInstance->Logs.Debug(MODNAME, "Priority string token not recognized: \"%s\"", token.c_str()); @@ -441,7 +441,7 @@ namespace GnuTLS { // Copy data from GnuTLS buffers to recvq gnutls_datum_t datum; - gnutls_packet_get(packet, &datum, NULL); + gnutls_packet_get(packet, &datum, nullptr); recvq.append(reinterpret_cast<const char*>(datum.data), datum.size); gnutls_packet_deinit(packet); @@ -610,8 +610,8 @@ private: gnutls_bye(this->sess, GNUTLS_SHUT_WR); gnutls_deinit(this->sess); } - sess = NULL; - certificate = NULL; + sess = nullptr; + certificate = nullptr; status = STATUS_NONE; } @@ -1116,7 +1116,7 @@ public: void init() override { - ServerInstance->Logs.Normal(MODNAME, "GnuTLS lib version %s module was compiled for " GNUTLS_VERSION, gnutls_check_version(NULL)); + ServerInstance->Logs.Normal(MODNAME, "GnuTLS lib version %s module was compiled for " GNUTLS_VERSION, gnutls_check_version(nullptr)); ServerInstance->GenRandom = GnuTLS::GenRandom; } diff --git a/src/modules/extra/m_ssl_mbedtls.cpp b/src/modules/extra/m_ssl_mbedtls.cpp index 67a5cac79..2b4b34bc5 100644 --- a/src/modules/extra/m_ssl_mbedtls.cpp +++ b/src/modules/extra/m_ssl_mbedtls.cpp @@ -106,7 +106,7 @@ namespace mbedTLS public: bool Seed(Entropy& entropy) { - return (mbedtls_ctr_drbg_seed(get(), mbedtls_entropy_func, entropy.get(), NULL, 0) == 0); + return (mbedtls_ctr_drbg_seed(get(), mbedtls_entropy_func, entropy.get(), nullptr, 0) == 0); } void SetupConf(mbedtls_ssl_config* conf) @@ -136,10 +136,10 @@ namespace mbedTLS { #if MBEDTLS_VERSION_MAJOR >= 3 int ret = mbedtls_pk_parse_key(get(), reinterpret_cast<const unsigned char*>(keystr.c_str()), - keystr.size() + 1, NULL, 0, mbedtls_ctr_drbg_random, 0); + keystr.size() + 1, nullptr, 0, mbedtls_ctr_drbg_random, 0); #else int ret = mbedtls_pk_parse_key(get(), reinterpret_cast<const unsigned char*>(keystr.c_str()), - keystr.size() + 1, NULL, 0); + keystr.size() + 1, nullptr, 0); #endif ThrowOnError(ret, "Unable to import private key"); } @@ -221,7 +221,7 @@ namespace mbedTLS ThrowOnError(ret, "Unable to load certificates"); } - bool empty() const { return (get()->raw.p != NULL); } + bool empty() const { return (get()->raw.p != nullptr); } }; class X509CRL final @@ -295,7 +295,7 @@ namespace mbedTLS mbedtls_ssl_config_init(&conf); #ifdef INSPIRCD_MBEDTLS_LIBRARY_DEBUG mbedtls_debug_set_threshold(INT_MAX); - mbedtls_ssl_conf_dbg(&conf, DebugLogFunc, NULL); + mbedtls_ssl_conf_dbg(&conf, DebugLogFunc, nullptr); #endif // TODO: check ret of mbedtls_ssl_config_defaults @@ -555,7 +555,7 @@ private: mbedtls_ssl_close_notify(&sess); mbedtls_ssl_free(&sess); - certificate = NULL; + certificate = nullptr; status = STATUS_NONE; } @@ -709,7 +709,7 @@ public: else GetProfile().SetupClientSession(&sess); - mbedtls_ssl_set_bio(&sess, reinterpret_cast<void*>(sock), Push, Pull, NULL); + mbedtls_ssl_set_bio(&sess, reinterpret_cast<void*>(sock), Push, Pull, nullptr); sock->AddIOHook(this); Handshake(sock); diff --git a/src/modules/extra/m_ssl_openssl.cpp b/src/modules/extra/m_ssl_openssl.cpp index 002411fa8..a7ad33aa4 100644 --- a/src/modules/extra/m_ssl_openssl.cpp +++ b/src/modules/extra/m_ssl_openssl.cpp @@ -64,7 +64,7 @@ static Module* thismod; char* get_error() { - return ERR_error_string(ERR_get_error(), NULL); + return ERR_error_string(ERR_get_error(), nullptr); } static int OnVerify(int preverify_ok, X509_STORE_CTX* ctx); @@ -94,7 +94,7 @@ namespace OpenSSL if (!dhpfile) throw Exception("Couldn't open DH file " + filename); - dh = PEM_read_bio_DHparams(dhpfile, NULL, NULL, NULL); + dh = PEM_read_bio_DHparams(dhpfile, nullptr, nullptr, nullptr); BIO_free(dhpfile); if (!dh) @@ -140,7 +140,7 @@ namespace OpenSSL mode |= SSL_MODE_RELEASE_BUFFERS; #endif SSL_CTX_set_mode(ctx, mode); - SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL); + SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, nullptr); SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_OFF); SSL_CTX_set_info_callback(ctx, StaticSSLInfoCallback); } @@ -200,7 +200,7 @@ namespace OpenSSL bool SetCA(const std::string& filename) { ERR_clear_error(); - return SSL_CTX_load_verify_locations(ctx, filename.c_str(), 0); + return SSL_CTX_load_verify_locations(ctx, filename.c_str(), nullptr); } void SetCRL(const std::string& crlfile, const std::string& crlpath, const std::string& crlmode) @@ -227,11 +227,11 @@ namespace OpenSSL } ERR_clear_error(); if (!X509_STORE_load_locations(store, - crlfile.empty() ? NULL : crlfile.c_str(), - crlpath.empty() ? NULL : crlpath.c_str())) + crlfile.empty() ? nullptr : crlfile.c_str(), + crlpath.empty() ? nullptr : crlpath.c_str())) { unsigned long err = ERR_get_error(); - throw ModuleException(thismod, "Unable to load CRL file '" + crlfile + "' or CRL path '" + crlpath + "': '" + (err ? ERR_error_string(err, NULL) : "unknown") + "'"); + throw ModuleException(thismod, "Unable to load CRL file '" + crlfile + "' or CRL path '" + crlpath + "': '" + (err ? ERR_error_string(err, nullptr) : "unknown") + "'"); } /* Set CRL mode */ @@ -562,8 +562,8 @@ private: SSL_shutdown(sess); SSL_free(sess); } - sess = NULL; - certificate = NULL; + sess = nullptr; + certificate = nullptr; status = STATUS_NONE; } @@ -978,7 +978,7 @@ public: : Module(VF_VENDOR, "Allows TLS encrypted connections using the OpenSSL library.") { // Initialize OpenSSL - OPENSSL_init_ssl(0, NULL); + OPENSSL_init_ssl(0, nullptr); biomethods = OpenSSL::BIOMethod::alloc(); thismod = this; @@ -995,7 +995,7 @@ public: // Register application specific data char exdatastr[] = "inspircd"; - exdataindex = SSL_get_ex_new_index(0, exdatastr, NULL, NULL, NULL); + exdataindex = SSL_get_ex_new_index(0, exdatastr, nullptr, nullptr, nullptr); if (exdataindex < 0) throw ModuleException(this, "Failed to register application specific data"); } diff --git a/src/modules/extra/m_sslrehashsignal.cpp b/src/modules/extra/m_sslrehashsignal.cpp index 41b90d6df..e8abe7a1d 100644 --- a/src/modules/extra/m_sslrehashsignal.cpp +++ b/src/modules/extra/m_sslrehashsignal.cpp @@ -57,7 +57,7 @@ public: ServerInstance->Logs.Normal(MODNAME, feedbackmsg); const std::string str = "tls"; - FOREACH_MOD(OnModuleRehash, (NULL, str)); + FOREACH_MOD(OnModuleRehash, (nullptr, str)); signaled = 0; } }; |
