Skip to content

Commit

Permalink
Make GeoLookup::debug function static (and non-member), as suggested …
Browse files Browse the repository at this point in the history
…by cppcheck.
  • Loading branch information
eduar-hte committed Oct 21, 2024
1 parent 4e68edf commit 7ec50eb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
16 changes: 10 additions & 6 deletions src/operators/geo_lookup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -41,15 +46,14 @@ 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);
}

return ret;
}


} // namespace operators
} // namespace modsecurity
} // namespace modsecurity::operators
15 changes: 4 additions & 11 deletions src/operators/geo_lookup.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,19 @@
#include "src/operators/operator.h"


namespace modsecurity {
namespace operators {
namespace modsecurity::operators {


class GeoLookup : public Operator {
public:
/** @ingroup ModSecurity_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_

0 comments on commit 7ec50eb

Please sign in to comment.