mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 09:38:19 +00:00
Clang format it all
This commit is contained in:
parent
12494aac45
commit
5cdc6e150e
18 changed files with 323 additions and 313 deletions
|
@ -23,8 +23,7 @@ do \
|
|||
fprintf(stderr, "\n"); \
|
||||
_exit(1); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
} while ( 0 )
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -26,9 +26,13 @@ public:
|
|||
*/
|
||||
int FD() const
|
||||
#if ! defined(_MSC_VER)
|
||||
{ return pipe.ReadFD(); }
|
||||
{
|
||||
return pipe.ReadFD();
|
||||
}
|
||||
#else
|
||||
{ return recvfd; }
|
||||
{
|
||||
return recvfd;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
|
|
@ -3962,7 +3962,6 @@ ValManager::ValManager()
|
|||
|
||||
for ( auto i = 0u; i < PREALLOCATED_INTS; ++i )
|
||||
ints[i] = Val::MakeInt(PREALLOCATED_INT_LOWEST + i);
|
||||
|
||||
}
|
||||
|
||||
const PortValPtr& ValManager::Port(uint32_t port_num, TransportProto port_type)
|
||||
|
@ -3975,9 +3974,7 @@ const PortValPtr& ValManager::Port(uint32_t port_num, TransportProto port_type)
|
|||
|
||||
std::pair key{port_num, port_type};
|
||||
if ( ports.find(key) == ports.end() )
|
||||
{
|
||||
ports[key] = IntrusivePtr{AdoptRef{}, new PortVal(PortVal::Mask(port_num, port_type))};
|
||||
}
|
||||
|
||||
return ports[key];
|
||||
}
|
||||
|
|
|
@ -62,7 +62,8 @@ bool IPAnalyzer::AnalyzePacket(size_t len, const uint8_t* data, Packet* packet)
|
|||
return false;
|
||||
}
|
||||
|
||||
ip_hdr = std::make_shared<IP_Hdr>((const struct ip6_hdr*)data, false, static_cast<int>(len));
|
||||
packet->ip_hdr = std::make_shared<IP_Hdr>((const struct ip6_hdr*)data, false,
|
||||
static_cast<int>(len));
|
||||
packet->l3_proto = L3_IPV6;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,18 +1,21 @@
|
|||
|
||||
#include <mutex>
|
||||
|
||||
#include "Plugin.h"
|
||||
|
||||
#include "zeek/Func.h"
|
||||
#include "zeek/Event.h"
|
||||
#include <mutex>
|
||||
|
||||
#include "zeek/Conn.h"
|
||||
#include "zeek/Desc.h"
|
||||
#include "zeek/threading/Formatter.h"
|
||||
#include "zeek/Event.h"
|
||||
#include "zeek/Func.h"
|
||||
#include "zeek/RunState.h"
|
||||
#include "zeek/threading/Formatter.h"
|
||||
|
||||
#include "statistics.bif.h"
|
||||
|
||||
namespace zeek::plugin::statistics { Plugin plugin; }
|
||||
namespace zeek::plugin::statistics
|
||||
{
|
||||
Plugin plugin;
|
||||
}
|
||||
|
||||
using namespace zeek::plugin::statistics;
|
||||
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <unordered_map>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "zeek/plugin/Plugin.h"
|
||||
|
||||
namespace zeek::plugin::statistics {
|
||||
namespace zeek::plugin::statistics
|
||||
{
|
||||
|
||||
class Plugin : public zeek::plugin::Plugin
|
||||
{
|
||||
|
@ -22,7 +24,6 @@ public:
|
|||
private:
|
||||
std::unordered_map<const char*, int> m_eventNameCounters;
|
||||
std::mutex m_lock;
|
||||
|
||||
};
|
||||
|
||||
extern Plugin plugin;
|
||||
|
|
|
@ -995,12 +995,14 @@ std::optional<SupervisedNode> Stem::Poll()
|
|||
node_pollfd_indices[name] = pfd_idx;
|
||||
|
||||
if ( node.stdout_pipe.pipe )
|
||||
pfds[pfd_idx++] = {static_cast<decltype(pollfd::fd)>(node.stdout_pipe.pipe->ReadFD()), POLLIN, 0};
|
||||
pfds[pfd_idx++] = {static_cast<decltype(pollfd::fd)>(node.stdout_pipe.pipe->ReadFD()),
|
||||
POLLIN, 0};
|
||||
else
|
||||
pfds[pfd_idx++] = {static_cast<decltype(pollfd::fd)>(-1), POLLIN, 0};
|
||||
|
||||
if ( node.stderr_pipe.pipe )
|
||||
pfds[pfd_idx++] = {static_cast<decltype(pollfd::fd)>(node.stderr_pipe.pipe->ReadFD()), POLLIN, 0};
|
||||
pfds[pfd_idx++] = {static_cast<decltype(pollfd::fd)>(node.stderr_pipe.pipe->ReadFD()),
|
||||
POLLIN, 0};
|
||||
else
|
||||
pfds[pfd_idx++] = {static_cast<decltype(pollfd::fd)>(-1), POLLIN, 0};
|
||||
}
|
||||
|
|
|
@ -50,7 +50,8 @@ void BasicThread::SetOSName(const char* arg_name)
|
|||
{
|
||||
// Do it only if libc++ supports pthread_t.
|
||||
if constexpr ( std::is_same<std::thread::native_handle_type, pthread_t>::value )
|
||||
zeek::util::detail::set_thread_name(arg_name, reinterpret_cast<pthread_t>(thread.native_handle()));
|
||||
zeek::util::detail::set_thread_name(arg_name,
|
||||
reinterpret_cast<pthread_t>(thread.native_handle()));
|
||||
}
|
||||
|
||||
const char* BasicThread::Fmt(const char* format, ...)
|
||||
|
|
15
src/util.cc
15
src/util.cc
|
@ -40,9 +40,9 @@
|
|||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <iostream>
|
||||
#include <random>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <random>
|
||||
|
||||
#include "zeek/3rdparty/ConvertUTF.h"
|
||||
#include "zeek/3rdparty/doctest.h"
|
||||
|
@ -662,7 +662,8 @@ TEST_CASE("util normalize_path")
|
|||
string normalize_path(std::string_view path)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
if (0 == path.compare(zeek::detail::ScannedFile::canonical_stdin_path)) {
|
||||
if ( 0 == path.compare(zeek::detail::ScannedFile::canonical_stdin_path) )
|
||||
{
|
||||
return string(path);
|
||||
}
|
||||
// "//" interferes with std::weakly_canonical
|
||||
|
@ -1805,14 +1806,11 @@ FILE* open_file(const string& path, const string& mode)
|
|||
return rval;
|
||||
}
|
||||
|
||||
TEST_CASE("util path ops")
|
||||
{
|
||||
TEST_CASE("util path ops"){
|
||||
#ifdef _MSC_VER
|
||||
// TODO: adapt these tests to Windows paths
|
||||
#else
|
||||
SUBCASE("SafeDirname")
|
||||
{
|
||||
SafeDirname d("/this/is/a/path", false);
|
||||
SUBCASE("SafeDirname"){SafeDirname d("/this/is/a/path", false);
|
||||
CHECK(d.result == "/this/is/a");
|
||||
|
||||
SafeDirname d2("invalid", false);
|
||||
|
@ -1835,7 +1833,8 @@ TEST_CASE("util path ops")
|
|||
#endif
|
||||
}
|
||||
|
||||
SafeDirname::SafeDirname(const char* path, bool error_aborts) : SafePathOp()
|
||||
SafeDirname::SafeDirname(const char* path, bool error_aborts)
|
||||
: SafePathOp()
|
||||
{
|
||||
DoFunc(path ? path : "", error_aborts);
|
||||
}
|
||||
|
|
11
src/util.h
11
src/util.h
|
@ -16,7 +16,6 @@
|
|||
|
||||
#include <libgen.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <array>
|
||||
#include <cinttypes>
|
||||
#include <cstdarg>
|
||||
|
@ -82,13 +81,19 @@ extern "C"
|
|||
#ifdef _MSC_VER
|
||||
#include <pthread.h>
|
||||
#include <filesystem>
|
||||
namespace zeek { namespace filesystem = std::filesystem; }
|
||||
namespace zeek
|
||||
{
|
||||
namespace filesystem = std::filesystem;
|
||||
}
|
||||
inline constexpr std::string_view path_list_separator = ";";
|
||||
#else
|
||||
// Expose ghc::filesystem as zeek::filesystem until we can
|
||||
// switch to std::filesystem on all platforms.
|
||||
#include "zeek/3rdparty/ghc/filesystem.hpp"
|
||||
namespace zeek { namespace filesystem = ghc::filesystem; }
|
||||
namespace zeek
|
||||
{
|
||||
namespace filesystem = ghc::filesystem;
|
||||
}
|
||||
inline constexpr std::string_view path_list_separator = ":";
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
// See the file "COPYING" in the main distribution directory for copyright.
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "zeek/zeek-setup.h"
|
||||
|
||||
#include "zeek/zeek-config.h"
|
||||
|
@ -10,6 +8,7 @@
|
|||
#include <openssl/opensslv.h>
|
||||
#include <openssl/ssl.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <csignal>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
@ -978,8 +977,8 @@ SetupResult setup(int argc, char** argv, Options* zopts)
|
|||
}
|
||||
|
||||
if ( dns_type != DNS_PRIME )
|
||||
run_state::detail::init_run(options.interface, options.pcap_file,
|
||||
options.pcap_output_file, options.use_watchdog);
|
||||
run_state::detail::init_run(options.interface, options.pcap_file, options.pcap_output_file,
|
||||
options.use_watchdog);
|
||||
|
||||
if ( ! g_policy_debug )
|
||||
{
|
||||
|
@ -1107,8 +1106,7 @@ SetupResult setup(int argc, char** argv, Options* zopts)
|
|||
packet_mgr->DumpDebug();
|
||||
analyzer_mgr->DumpDebug();
|
||||
|
||||
run_state::detail::have_pending_timers = ! run_state::reading_traces &&
|
||||
timer_mgr->Size() > 0;
|
||||
run_state::detail::have_pending_timers = ! run_state::reading_traces && timer_mgr->Size() > 0;
|
||||
|
||||
return {0, std::move(options)};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue