From 9bb42e8b18323cc60bfa7021d84adae7752d5d47 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Tue, 13 Feb 2024 23:32:06 +0100 Subject: [PATCH 1/2] fix(c++): re-throw original exception rather than copy Reported by cppcheck Signed-off-by: Samuel Gaist --- userspace/falco/atomic_signal_handler.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/userspace/falco/atomic_signal_handler.h b/userspace/falco/atomic_signal_handler.h index a79e8954bf8..3d80a231dd7 100644 --- a/userspace/falco/atomic_signal_handler.h +++ b/userspace/falco/atomic_signal_handler.h @@ -111,13 +111,13 @@ namespace falco m_handled.store(true, std::memory_order_seq_cst); } } - catch (std::exception& e) + catch (std::exception&) { if (triggered()) { m_handled.store(true, std::memory_order_seq_cst); } - throw e; + throw; } return true; } From f0b7bfa1fac7c462d8ce12cd1b3bbf7755053151 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Tue, 13 Feb 2024 23:32:40 +0100 Subject: [PATCH 2/2] fix(c++): don't throw outside of the try catch block in nothrow function Reported by cppcheck Signed-off-by: Samuel Gaist --- userspace/falco/app/actions/process_events.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/userspace/falco/app/actions/process_events.cpp b/userspace/falco/app/actions/process_events.cpp index 696e92443c4..1d2006793cc 100644 --- a/userspace/falco/app/actions/process_events.cpp +++ b/userspace/falco/app/actions/process_events.cpp @@ -330,6 +330,8 @@ static void process_inspector_events( source_sync_context* sync, run_result* res) noexcept { + run_result result; + try { double duration; @@ -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); @@ -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(