From f880d0727c5d2502e1e80e1530d1b8024b16a454 Mon Sep 17 00:00:00 2001 From: Federico Aponte Date: Sat, 24 Feb 2024 16:31:23 +0100 Subject: [PATCH] cleanup: too many includes and useless defines Signed-off-by: Federico Aponte --- userspace/engine/falco_utils.cpp | 9 ++++--- userspace/engine/falco_utils.h | 26 +++---------------- .../falco/app/actions/process_events.cpp | 2 +- 3 files changed, 10 insertions(+), 27 deletions(-) diff --git a/userspace/engine/falco_utils.cpp b/userspace/engine/falco_utils.cpp index 75a3f80145b..2322f8dddeb 100644 --- a/userspace/engine/falco_utils.cpp +++ b/userspace/engine/falco_utils.cpp @@ -17,14 +17,17 @@ See the License for the specific language governing permissions and limitations under the License. */ -#include -#include #include "falco_utils.h" #include #include +#include +#include +#include +#include + #define RGX_PROMETHEUS_TIME_DURATION "^((?P[0-9]+)y)?((?P[0-9]+)w)?((?P[0-9]+)d)?((?P[0-9]+)h)?((?P[0-9]+)m)?((?P[0-9]+)s)?((?P[0-9]+)ms)?$" // using pre-compiled regex @@ -145,7 +148,7 @@ uint32_t hardware_concurrency() void readfile(const std::string& filename, std::string& data) { - std::ifstream file(filename.c_str(), std::ios::in); + std::ifstream file(filename, std::ios::in); if(file.is_open()) { diff --git a/userspace/engine/falco_utils.h b/userspace/engine/falco_utils.h index 38bc5c9f6fa..9f26355479d 100644 --- a/userspace/engine/falco_utils.h +++ b/userspace/engine/falco_utils.h @@ -20,30 +20,11 @@ limitations under the License. #pragma once -#include -#include -#include +#include #include -#include -#include -#include -#include -#include - -#ifdef __GNUC__ -#define likely(x) __builtin_expect(!!(x), 1) -#define unlikely(x) __builtin_expect(!!(x), 0) -#else -#define likely(x) (x) -#define unlikely(x) (x) -#endif -namespace falco +namespace falco::utils { - -namespace utils -{ - uint64_t parse_prometheus_interval(std::string interval_str); std::string wrap_text(const std::string& in, uint32_t indent, uint32_t linelen); @@ -57,5 +38,4 @@ namespace network static const std::string UNIX_SCHEME("unix://"); bool is_unix_scheme(const std::string& url); } // namespace network -} // namespace utils -} // namespace falco +} // namespace falco::utils diff --git a/userspace/falco/app/actions/process_events.cpp b/userspace/falco/app/actions/process_events.cpp index b5ba82083a8..116a9fe27e7 100644 --- a/userspace/falco/app/actions/process_events.cpp +++ b/userspace/falco/app/actions/process_events.cpp @@ -199,7 +199,7 @@ static falco::app::run_result do_inspect( } else if(rc == SCAP_TIMEOUT) { - if(unlikely(ev == nullptr)) + if(ev == nullptr) [[unlikely]] { timeouts_since_last_success_or_msg++; if(timeouts_since_last_success_or_msg > s.config->m_syscall_evt_timeout_max_consecutives