Skip to content

Commit

Permalink
cleanup: too many includes and useless defines
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Aponte <federico.aponte@sysdig.com>
  • Loading branch information
federico-sysdig committed Feb 24, 2024
1 parent 9ed8470 commit f880d07
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 27 deletions.
9 changes: 6 additions & 3 deletions userspace/engine/falco_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
#include <cstring>
#include <iomanip>

#include "falco_utils.h"
#include <libsinsp/utils.h>

#include <re2/re2.h>

#include <cstring>
#include <fstream>
#include <iomanip>
#include <thread>

#define RGX_PROMETHEUS_TIME_DURATION "^((?P<y>[0-9]+)y)?((?P<w>[0-9]+)w)?((?P<d>[0-9]+)d)?((?P<h>[0-9]+)h)?((?P<m>[0-9]+)m)?((?P<s>[0-9]+)s)?((?P<ms>[0-9]+)ms)?$"

// using pre-compiled regex
Expand Down Expand Up @@ -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())
{
Expand Down
26 changes: 3 additions & 23 deletions userspace/engine/falco_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,11 @@ limitations under the License.

#pragma once

#include <sstream>
#include <fstream>
#include <iostream>
#include <cstdint>
#include <string>
#include <thread>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>

#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);
Expand All @@ -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
2 changes: 1 addition & 1 deletion userspace/falco/app/actions/process_events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f880d07

Please sign in to comment.