From 7ec50eb53f4389d9bdff1c455b44cf496949e240 Mon Sep 17 00:00:00 2001 From: Eduardo Arias Date: Mon, 21 Oct 2024 16:02:27 -0300 Subject: [PATCH] Make GeoLookup::debug function static (and non-member), as suggested by cppcheck. --- src/operators/geo_lookup.cc | 16 ++++++++++------ src/operators/geo_lookup.h | 15 ++++----------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/operators/geo_lookup.cc b/src/operators/geo_lookup.cc index 5717b7af..6bd79185 100644 --- a/src/operators/geo_lookup.cc +++ b/src/operators/geo_lookup.cc @@ -30,8 +30,13 @@ #include "src/utils/geo_lookup.h" -namespace modsecurity { -namespace operators { +namespace modsecurity::operators { + + +static bool debug(const Transaction *transaction, int x, const std::string &a) { + ms_dbg_a(transaction, x, a); + return true; +} bool GeoLookup::evaluate(Transaction *trans, const std::string &exp) { @@ -41,9 +46,9 @@ bool GeoLookup::evaluate(Transaction *trans, const std::string &exp) { if (trans) { ret = Utils::GeoLookup::getInstance().lookup(exp, trans, - std::bind(&GeoLookup::debug, this, trans, _1, _2)); + std::bind(debug, trans, _1, _2)); } else { - ret = Utils::GeoLookup::getInstance().lookup(exp, NULL, + ret = Utils::GeoLookup::getInstance().lookup(exp, nullptr, nullptr); } @@ -51,5 +56,4 @@ bool GeoLookup::evaluate(Transaction *trans, const std::string &exp) { } -} // namespace operators -} // namespace modsecurity +} // namespace modsecurity::operators diff --git a/src/operators/geo_lookup.h b/src/operators/geo_lookup.h index 81155d61..b12b031a 100644 --- a/src/operators/geo_lookup.h +++ b/src/operators/geo_lookup.h @@ -21,8 +21,8 @@ #include "src/operators/operator.h" -namespace modsecurity { -namespace operators { +namespace modsecurity::operators { + class GeoLookup : public Operator { public: @@ -30,17 +30,10 @@ class GeoLookup : public Operator { GeoLookup() : Operator("GeoLookup") { } bool evaluate(Transaction *transaction, const std::string &exp) override; - - protected: - // cppcheck-suppress functionStatic - bool debug(const Transaction *transaction, int x, const std::string &a) { - ms_dbg_a(transaction, x, a); - return true; - } }; -} // namespace operators -} // namespace modsecurity + +} // namespace modsecurity::operators #endif // SRC_OPERATORS_GEO_LOOKUP_H_