From c5748e4494b257df4fd2b0ceb49d05ced4c8159e Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Mon, 3 Feb 2020 18:15:38 -0500 Subject: [PATCH] Give real variable names to SegmentProfiler objects when defining them (bugprone-unused-raii) The reason behind this one is that without a real variable name, the profile objects are immediately desctructed and the profiling only happens for the small window when they were valid. If the intention is to profile the method where they were defined, this doesn't actually happen. --- src/Event.cc | 2 +- src/Func.cc | 4 ++-- src/Net.cc | 2 +- src/Sessions.cc | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Event.cc b/src/Event.cc index 292d70b05f..ef69e7a42d 100644 --- a/src/Event.cc +++ b/src/Event.cc @@ -152,7 +152,7 @@ void EventMgr::Drain() if ( event_queue_flush_point ) QueueEventFast(event_queue_flush_point, val_list{}); - SegmentProfiler(segment_logger, "draining-events"); + SegmentProfiler prof(segment_logger, "draining-events"); PLUGIN_HOOK_VOID(HOOK_DRAIN_EVENTS, HookDrainEvents()); diff --git a/src/Func.cc b/src/Func.cc index 759b132a9a..cd5062af9b 100644 --- a/src/Func.cc +++ b/src/Func.cc @@ -309,7 +309,7 @@ Val* BroFunc::Call(val_list* args, Frame* parent) const #ifdef PROFILE_BRO_FUNCTIONS DEBUG_MSG("Function: %s\n", Name()); #endif - SegmentProfiler(segment_logger, location); + SegmentProfiler prof(segment_logger, location); if ( sample_logger ) sample_logger->FunctionSeen(this); @@ -629,7 +629,7 @@ Val* BuiltinFunc::Call(val_list* args, Frame* parent) const #ifdef PROFILE_BRO_FUNCTIONS DEBUG_MSG("Function: %s\n", Name()); #endif - SegmentProfiler(segment_logger, Name()); + SegmentProfiler prof(segment_logger, Name()); if ( sample_logger ) sample_logger->FunctionSeen(this); diff --git a/src/Net.cc b/src/Net.cc index 1b35907a93..fa9bbd56a2 100644 --- a/src/Net.cc +++ b/src/Net.cc @@ -212,7 +212,7 @@ void net_init(const std::optional& interface, void expire_timers(iosource::PktSrc* src_ps) { - SegmentProfiler(segment_logger, "expiring-timers"); + SegmentProfiler prof(segment_logger, "expiring-timers"); current_dispatched += timer_mgr->Advance(network_time, diff --git a/src/Sessions.cc b/src/Sessions.cc index 8f66ae8633..c86395267b 100644 --- a/src/Sessions.cc +++ b/src/Sessions.cc @@ -120,7 +120,7 @@ void NetSessions::Done() void NetSessions::NextPacket(double t, const Packet* pkt) { - SegmentProfiler(segment_logger, "dispatching-packet"); + SegmentProfiler prof(segment_logger, "dispatching-packet"); if ( raw_packet ) mgr.QueueEventFast(raw_packet, {pkt->BuildPktHdrVal()});