Skip to content

Commit

Permalink
fix(c++): don't throw outside of the try catch block in nothrow function
Browse files Browse the repository at this point in the history
Reported by cppcheck

Signed-off-by: Samuel Gaist <[email protected]>
  • Loading branch information
sgaist authored and poiana committed Feb 15, 2024
1 parent f3491d6 commit e18acc3
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions userspace/falco/app/actions/process_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ static void process_inspector_events(
source_sync_context* sync,
run_result* res) noexcept
{
run_result result;

try
{
double duration;
Expand All @@ -342,7 +344,7 @@ static void process_inspector_events(

duration = ((double)clock()) / CLOCKS_PER_SEC;

*res = do_inspect(s, inspector, source, statsw, sdropmgr, check_drops_timeouts,
result = do_inspect(s, inspector, source, statsw, sdropmgr, check_drops_timeouts,
uint64_t(s.options.duration_to_tot*ONE_SECOND_IN_NS),
num_evts);

Expand Down Expand Up @@ -373,13 +375,21 @@ static void process_inspector_events(
}
catch(const std::exception& e)
{
*res = run_result::fatal(e.what());
result = run_result::fatal(e.what());
}

if (sync)
{
sync->finish();
try {
sync->finish();
}
catch(const std::exception& e)
{
result = run_result::merge(result, run_result::fatal(e.what()));
}
}

*res = result;
}

static falco::app::run_result init_stats_writer(
Expand Down

0 comments on commit e18acc3

Please sign in to comment.