diff --git a/CHANGES b/CHANGES index feb7ab9db4..9ce15963e2 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,12 @@ + +3.3.0-dev.194 | 2020-08-24 19:20:29 -0700 + + * Mark Continuation.h and PacketDumper.h as deprecated (Tim Wojtulewicz, Corelight) + + * Remove vector iterator type aliases from SmithWaterman code, fix uses of them (Tim Wojtulewicz, Corelight) + + * Fix warning with usage of fmt() (Tim Wojtulewicz, Corelight) + 3.3.0-dev.190 | 2020-08-24 14:43:06 -0700 * Make set_processing_status() signal-safe. diff --git a/NEWS b/NEWS index 58c719001d..b66c269798 100644 --- a/NEWS +++ b/NEWS @@ -52,7 +52,8 @@ Removed Functionality Deprecated Functionality ------------------------ -TODO: nothing notable yet +- Marked the Continuation.h and PacketDumper.h files as deprecated. The code + contained within them is unused by Zeek. Zeek 3.2.0 ========== diff --git a/VERSION b/VERSION index a0dde1bb25..b6c54d00be 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.3.0-dev.190 +3.3.0-dev.194 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e75d4f3a0b..266bae7b81 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -296,7 +296,6 @@ set(MAIN_SRCS bro_inet_ntop.c patricia.c setsignal.c - PacketDumper.cc strsep.c modp_numtoa.c diff --git a/src/Continuation.h b/src/Continuation.h index 455cf52a73..d29d353c57 100644 --- a/src/Continuation.h +++ b/src/Continuation.h @@ -1,3 +1,5 @@ +#warning "This file will be removed in v4.1. The code here is unused by Zeek. Notify a Zeek team member if your plugins are using this code." + // Helper class to implement continuation-like mechanisms for // suspending/resuming tasks for incremental operation. // diff --git a/src/PacketDumper.h b/src/PacketDumper.h index cd66c3c07e..2065dc2ed3 100644 --- a/src/PacketDumper.h +++ b/src/PacketDumper.h @@ -1,3 +1,5 @@ +#warning "This file will be removed in v4.1. The code here is unused by Zeek. Notify a Zeek team member if your plugins are using this code." + // See the file "COPYING" in the main distribution directory for copyright. #pragma once diff --git a/src/SmithWaterman.cc b/src/SmithWaterman.cc index b773283608..15942e9576 100644 --- a/src/SmithWaterman.cc +++ b/src/SmithWaterman.cc @@ -16,8 +16,8 @@ namespace zeek::detail { Substring::Substring(const Substring& bst) : zeek::String((const zeek::String&) bst), _num(), _new(bst._new) { - for ( BSSAlignVecCIt it = bst._aligns.begin(); it != bst._aligns.end(); ++it ) - _aligns.push_back(*it); + for ( const auto& align : bst._aligns ) + _aligns.push_back(align); } const Substring& Substring::operator=(const Substring& bst) @@ -26,8 +26,8 @@ const Substring& Substring::operator=(const Substring& bst) _aligns.clear(); - for ( BSSAlignVecCIt it = bst._aligns.begin(); it != bst._aligns.end(); ++it ) - _aligns.push_back(*it); + for ( const auto& align : bst._aligns ) + _aligns.push_back(align); _new = bst._new; @@ -44,9 +44,9 @@ bool Substring::DoesCover(const Substring* bst) const if ( _aligns.size() != bst->_aligns.size() ) return false; - BSSAlignVecCIt it_bst = bst->_aligns.begin(); + auto it_bst = bst->_aligns.begin(); - for ( BSSAlignVecCIt it = _aligns.begin(); it != _aligns.end(); ++it, ++it_bst ) + for ( auto it = _aligns.begin(); it != _aligns.end(); ++it, ++it_bst ) { const BSSAlign& a = *it; const BSSAlign& a_bst = *it_bst; @@ -134,9 +134,9 @@ char* Substring::VecToString(Vec* vec) { std::string result("["); - for ( Substring::VecIt it = vec->begin(); it != vec->end(); ++it ) + for ( const auto& ss : *vec ) { - result += (*it)->CheckString(); + result += ss->CheckString(); result += ","; } @@ -148,17 +148,14 @@ zeek::String::IdxVec* Substring::GetOffsetsVec(const Vec* vec, unsigned int inde { zeek::String::IdxVec* result = new zeek::String::IdxVec(); - for ( VecCIt it = vec->begin(); it != vec->end(); ++it ) + for ( const auto& bst : *vec ) { - int start, end; - const Substring* bst = (*it); - if ( bst->_aligns.size() <= index ) continue; const BSSAlign& align = bst->_aligns[index]; - start = align.index; - end = start + bst->Len(); + int start = align.index; + int end = start + bst->Len(); result->push_back(start); result->push_back(end); @@ -327,7 +324,7 @@ static void sw_collect_single(Substring::Vec* result, SWNodeMatrix& matrix, // substrings are redundant (i.e., fully covered by a larger common substring). // static void sw_collect_multiple(Substring::Vec* result, - SWNodeMatrix& matrix, SWParams& params) + SWNodeMatrix& matrix, SWParams& params) { std::vector als; @@ -343,21 +340,16 @@ static void sw_collect_multiple(Substring::Vec* result, auto* new_al = new Substring::Vec(); sw_collect_single(new_al, matrix, node, params); - for ( std::vector::iterator it = als.begin(); - it != als.end(); ++it ) + for ( auto& old_al : als ) { - Substring::Vec* old_al = *it; - if ( old_al == nullptr ) continue; - for ( Substring::VecIt it2 = old_al->begin(); - it2 != old_al->end(); ++it2 ) + for ( const auto& old_ss : *old_al ) { - for ( Substring::VecIt it3 = new_al->begin(); - it3 != new_al->end(); ++it3 ) + for ( const auto& new_ss : *new_al ) { - if ( (*it2)->DoesCover(*it3) ) + if ( old_ss->DoesCover(new_ss) ) { zeek::util::delete_each(new_al); delete new_al; @@ -365,11 +357,11 @@ static void sw_collect_multiple(Substring::Vec* result, goto end_loop; } - if ( (*it3)->DoesCover(*it2) ) + if ( new_ss->DoesCover(old_ss) ) { zeek::util::delete_each(old_al); delete old_al; - *it = 0; + old_al = nullptr; goto end_loop; } } @@ -382,17 +374,13 @@ end_loop: } } - for ( std::vector::iterator it = als.begin(); - it != als.end(); ++it ) + for ( const auto& al : als ) { - Substring::Vec* al = *it; - if ( al == nullptr ) continue; - for ( Substring::VecIt it2 = al->begin(); - it2 != al->end(); ++it2 ) - result->push_back(*it2); + for ( const auto& bst : *al ) + result->push_back(bst); delete al; } diff --git a/src/SmithWaterman.h b/src/SmithWaterman.h index 2ed4d71753..6ec49bd605 100644 --- a/src/SmithWaterman.h +++ b/src/SmithWaterman.h @@ -2,8 +2,10 @@ #pragma once -#include "ZeekString.h" #include +#include + +#include "ZeekString.h" namespace zeek::detail { @@ -16,9 +18,7 @@ namespace zeek::detail { class Substring : public zeek::String { public: - typedef std::vector Vec; - typedef Vec::iterator VecIt; - typedef Vec::const_iterator VecCIt; + using Vec = std::vector; // An alignment to another string. // @@ -37,9 +37,7 @@ public: int index; }; - typedef std::vector BSSAlignVec; - typedef BSSAlignVec::iterator BSSAlignVecIt; - typedef BSSAlignVec::const_iterator BSSAlignVecCIt; + using BSSAlignVec = std::vector; explicit Substring(const std::string& string) : zeek::String(string), _num(), _new(false) { } @@ -74,11 +72,10 @@ public: static Vec* VecFromPolicy(zeek::VectorVal* vec); static char* VecToString(Vec* vec); static zeek::String::IdxVec* GetOffsetsVec(const Vec* vec, - unsigned int index); + unsigned int index); private: - typedef std::map DataMap; - typedef DataMap::iterator DataMapIt; + using DataMap = std::map; Substring();