mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
EventRegistry: Deprecate UsedHandlers() and UnusedHandlers()
and check_for_unused_event_handlers: UsageAnalyzer is more thorough and the previous ones weren't extended to work with &is_used and should probably be considered superseded by the UsageAnalyzer even if that currently does not provide a public API and just prints out deprecation warnings. I'm also tempted to deprecate SetUsed() and Used() of EventHandler for the same reason. Closes #3187.
This commit is contained in:
parent
cd24acdfc8
commit
398122206e
5 changed files with 8 additions and 4 deletions
|
@ -5192,7 +5192,7 @@ const likely_server_ports: set[port] &redef;
|
|||
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;
|
||||
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).
|
||||
##
|
||||
|
|
|
@ -68,8 +68,8 @@ public:
|
|||
// themselves.
|
||||
void SetErrorHandler(std::string_view name);
|
||||
|
||||
string_list UnusedHandlers();
|
||||
string_list UsedHandlers();
|
||||
[[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();
|
||||
|
|
|
@ -489,7 +489,7 @@ function get_event_handler_stats%(%): EventNameStats
|
|||
auto rval = zeek::make_intrusive<zeek::VectorVal>(zeek::id::find_type<VectorType>("EventNameStats"));
|
||||
const auto& recordType = zeek::id::find_type<RecordType>("EventNameCounter");
|
||||
|
||||
const auto& events = event_registry->UsedHandlers();
|
||||
const auto& events = event_registry->AllHandlers();
|
||||
for ( const auto& name : events )
|
||||
{
|
||||
auto handler = event_registry->Lookup(name);
|
||||
|
|
|
@ -1008,7 +1008,10 @@ 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 )
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||
### NOTE: This file has been sorted with diff-sort.
|
||||
warning in <...>/check-unused-event-handlers.test, line 7: handler for non-existing event cannot be invoked (this_is_never_used)
|
||||
warning in <params>, line 1: deprecated (check_for_unused_event_handlers): Remove in v7.1. This has been replaced by usage analyzer functionality.
|
||||
warning in <params>, line 1: event handler never invoked: Control::configuration_update
|
||||
warning in <params>, line 1: event handler never invoked: Control::configuration_update_request
|
||||
warning in <params>, line 1: event handler never invoked: Control::configuration_update_response
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue