diff --git a/examples/patbench.cc b/examples/patbench.cc index 1f965f13..132e416f 100644 --- a/examples/patbench.cc +++ b/examples/patbench.cc @@ -358,9 +358,11 @@ public: // Return the number of bytes scanned size_t bytes() const { size_t sum = 0; - for (const auto &packet : packets) { - sum += packet.size(); - } + auto packs = [](size_t z, const string &packet) { return z + packet.size(); }; + sum += std::accumulate(packets.begin(), packets.end(), 0, packs); + // for (const auto &packet : packets) { + // sum += packet.size(); + // } return sum; } @@ -461,6 +463,7 @@ public: vector cstrPatterns; cstrPatterns.reserve(patterns.size()); for (const auto &pattern : patterns) { + // cppcheck-suppress useStlAlgorithm cstrPatterns.push_back(pattern.c_str()); } diff --git a/examples/pcapscan.cc b/examples/pcapscan.cc index bd5493a4..071de740 100644 --- a/examples/pcapscan.cc +++ b/examples/pcapscan.cc @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -250,9 +251,8 @@ public: // Return the number of bytes scanned size_t bytes() const { size_t sum = 0; - for (const auto &packet : packets) { - sum += packet.size(); - } + auto packs = [](size_t z, const string &packet) { return z + packet.size(); }; + sum += std::accumulate(packets.begin(), packets.end(), 0, packs); return sum; } @@ -433,6 +433,7 @@ static void databasesFromFile(const char *filename, // storage.) vector cstrPatterns; for (const auto &pattern : patterns) { + // cppcheck-suppress useStlAlgorithm cstrPatterns.push_back(pattern.c_str()); }