diff --git a/scripts/base/init-bare.zeek b/scripts/base/init-bare.zeek index 85a1dc0f20..1d04c2ee09 100644 --- a/scripts/base/init-bare.zeek +++ b/scripts/base/init-bare.zeek @@ -5259,9 +5259,6 @@ const likely_server_ports: set[port] &redef; ## If true, output profiling for Time-Machine queries. const time_machine_profiling = F &redef &deprecated="Remove in v7.1. Unused."; -## If true, warns about unused event handlers at startup. -const check_for_unused_event_handlers = F &redef &deprecated="Remove in v7.1. This has been replaced by usage analyzer functionality."; - ## Holds the filename of the trace file given with ``-w`` (empty if none). ## ## .. zeek:see:: record_all_packets diff --git a/src/EventHandler.h b/src/EventHandler.h index ef647a7c6e..0fbd5c1282 100644 --- a/src/EventHandler.h +++ b/src/EventHandler.h @@ -44,13 +44,6 @@ public: // Returns true if there is at least one local or remote handler. explicit operator bool() const; - [[deprecated("Remove in v7.1 - Unused event handlers are now found via UsageAnalyzer.")]] void SetUsed() { - used = true; - } - [[deprecated("Remove in v7.1 - Unused event handlers are now found via UsageAnalyzer.")]] bool Used() const { - return used; - } - // Handlers marked as error handlers will not be called recursively to // avoid infinite loops if they trigger a similar error themselves. void SetErrorHandler() { error_handler = true; } diff --git a/src/EventRegistry.cc b/src/EventRegistry.cc index 93a5844331..b166546276 100644 --- a/src/EventRegistry.cc +++ b/src/EventRegistry.cc @@ -21,23 +21,12 @@ EventHandlerPtr EventRegistry::Register(std::string_view name, bool is_from_scri if ( ! is_from_script ) not_only_from_script.insert(std::string(name)); -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - // Remove in v7.1 - h->SetUsed(); -#pragma GCC diagnostic pop return h; } h = new EventHandler(std::string(name)); event_registry->Register(h, is_from_script); -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - // Remove in v7.1 - h->SetUsed(); -#pragma GCC diagnostic pop - return h; } @@ -74,36 +63,6 @@ EventRegistry::string_list EventRegistry::Match(RE_Matcher* pattern) { return names; } -EventRegistry::string_list EventRegistry::UnusedHandlers() { - string_list names; - - for ( const auto& entry : handlers ) { - EventHandler* v = entry.second.get(); -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - if ( v->GetFunc() && ! v->Used() ) - names.push_back(entry.first); -#pragma GCC diagnostic pop - } - - return names; -} - -EventRegistry::string_list EventRegistry::UsedHandlers() { - string_list names; - - for ( const auto& entry : handlers ) { - EventHandler* v = entry.second.get(); -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - if ( v->GetFunc() && v->Used() ) - names.push_back(entry.first); -#pragma GCC diagnostic pop - } - - return names; -} - EventRegistry::string_list EventRegistry::AllHandlers() { string_list names; diff --git a/src/EventRegistry.h b/src/EventRegistry.h index eb9b9b0026..cbe9c622bf 100644 --- a/src/EventRegistry.h +++ b/src/EventRegistry.h @@ -69,8 +69,6 @@ public: // themselves. void SetErrorHandler(std::string_view name); - [[deprecated("Remove in v7.1 - Unused handlers are now found via UsageAnalyzer.")]] string_list UnusedHandlers(); - [[deprecated("Remove in v7.1 - UsedHandlers() is unreliable - use AllHandlers().")]] string_list UsedHandlers(); string_list AllHandlers(); void PrintDebug(); diff --git a/src/Expr.cc b/src/Expr.cc index abbb07a3d4..3147906b92 100644 --- a/src/Expr.cc +++ b/src/Expr.cc @@ -414,13 +414,6 @@ NameExpr::NameExpr(IDPtr arg_id, bool const_init) : Expr(EXPR_NAME), id(std::mov SetType(make_intrusive(id->GetType())); else SetType(id->GetType()); - - EventHandler* h = event_registry->Lookup(id->Name()); - if ( h ) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - h->SetUsed(); -#pragma GCC diagnostic pop } bool NameExpr::CanDel() const { @@ -4417,11 +4410,6 @@ EventExpr::EventExpr(const char* arg_name, ListExprPtr arg_args) event_registry->Register(h, true); } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - h->SetUsed(); -#pragma GCC diagnostic pop - handler = h; if ( args->IsError() ) { diff --git a/src/NetVar.cc b/src/NetVar.cc index 67e078e4d6..1b97300858 100644 --- a/src/NetVar.cc +++ b/src/NetVar.cc @@ -182,8 +182,6 @@ int dpd_match_only_beginning; int dpd_late_match_stop; int dpd_ignore_ports; -int check_for_unused_event_handlers; - int record_all_packets; zeek_uint_t bits_per_uid; @@ -229,7 +227,6 @@ void init_general_global_var() { table_incremental_step = id::find_val("table_incremental_step")->AsCount(); packet_filter_default = id::find_val("packet_filter_default")->AsBool(); sig_max_group_size = id::find_val("sig_max_group_size")->AsCount(); - check_for_unused_event_handlers = id::find_val("check_for_unused_event_handlers")->AsBool(); record_all_packets = id::find_val("record_all_packets")->AsBool(); bits_per_uid = id::find_val("bits_per_uid")->AsCount(); } diff --git a/src/NetVar.h b/src/NetVar.h index 8d628c1ff9..8f7319f30f 100644 --- a/src/NetVar.h +++ b/src/NetVar.h @@ -85,8 +85,6 @@ extern int dpd_match_only_beginning; extern int dpd_late_match_stop; extern int dpd_ignore_ports; -extern int check_for_unused_event_handlers; - extern int record_all_packets; extern zeek_uint_t bits_per_uid; diff --git a/src/script_opt/CPP/RuntimeInitSupport.cc b/src/script_opt/CPP/RuntimeInitSupport.cc index f3ab29295a..3674d7605d 100644 --- a/src/script_opt/CPP/RuntimeInitSupport.cc +++ b/src/script_opt/CPP/RuntimeInitSupport.cc @@ -131,13 +131,8 @@ void activate_bodies__CPP(const char* fn, const char* module, bool exported, Typ events.insert(cs.events.begin(), cs.events.end()); } - for ( const auto& e : events ) { - auto eh = event_registry->Register(e); -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - eh->SetUsed(); -#pragma GCC diagnostic pop - } + for ( const auto& e : events ) + event_registry->Register(e); } IDPtr lookup_global__CPP(const char* g, const TypePtr& t, bool exported) { @@ -191,13 +186,8 @@ FuncValPtr lookup_func__CPP(string name, int num_bodies, vector has // This might register the same event more than once, // if it's used in multiple bodies, but that's okay as // the semantics for Register explicitly allow it. - for ( auto& e : f.events ) { - auto eh = event_registry->Register(e); -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - eh->SetUsed(); -#pragma GCC diagnostic pop - } + for ( auto& e : f.events ) + event_registry->Register(e); } auto sf = make_intrusive(std::move(name), std::move(ft), std::move(bodies), std::move(priorities)); diff --git a/src/script_opt/ScriptOpt.cc b/src/script_opt/ScriptOpt.cc index c41e6cf429..d09e9dd25b 100644 --- a/src/script_opt/ScriptOpt.cc +++ b/src/script_opt/ScriptOpt.cc @@ -417,13 +417,8 @@ static void use_CPP() { f.SetBody(b); } - for ( auto& e : s->second.events ) { - auto h = event_registry->Register(e); -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - h->SetUsed(); -#pragma GCC diagnostic pop - } + for ( auto& e : s->second.events ) + event_registry->Register(e); auto finish = s->second.finish_init_func; if ( finish ) diff --git a/src/zeek-setup.cc b/src/zeek-setup.cc index c97458984c..8b740a27d8 100644 --- a/src/zeek-setup.cc +++ b/src/zeek-setup.cc @@ -996,16 +996,6 @@ SetupResult setup(int argc, char** argv, Options* zopts) { if ( zeek_init ) event_mgr.Enqueue(zeek_init, Args{}); -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - EventRegistry::string_list dead_handlers = event_registry->UnusedHandlers(); -#pragma GCC diagnostic pop - - if ( ! dead_handlers.empty() && check_for_unused_event_handlers ) { - for ( const string& handler : dead_handlers ) - reporter->Warning("event handler never invoked: %s", handler.c_str()); - } - // Enable LeakSanitizer before zeek_init() and even before executing // top-level statements. Even though it's not bad if a leak happens only // once at initialization, we have to assume that script-layer code causing diff --git a/testing/btest/core/check-unused-event-handlers.test b/testing/btest/core/check-unused-event-handlers.test deleted file mode 100644 index b5f9cf4aae..0000000000 --- a/testing/btest/core/check-unused-event-handlers.test +++ /dev/null @@ -1,10 +0,0 @@ -# This test should print a warning that the event handler is never invoked. -# @TEST-REQUIRES: test "${ZEEK_USE_CPP}" != "1" -# @TEST-REQUIRES: $SCRIPTS/have-spicy # This test logs uninvoked event handlers, so disable it if Spicy and its plugin is unavailable. -# @TEST-EXEC: zeek -b %INPUT check_for_unused_event_handlers=T -# @TEST-EXEC: TEST_DIFF_CANONIFIER=$SCRIPTS/diff-sort-and-remove-abspath btest-diff .stderr - -event this_is_never_used() - { - print "not even once"; - }