clang-format: Set penalty for breaking after assignment operator

This commit is contained in:
Tim Wojtulewicz 2021-09-24 16:06:13 -07:00
parent 4423574d26
commit 9af6b2f48d
54 changed files with 255 additions and 247 deletions

View file

@ -70,6 +70,10 @@ SpacesInParentheses: false
TabWidth: 4
UseTab: AlignWithSpaces
# Setting this to a high number causes clang-format to prefer breaking somewhere else
# over breaking after the assignment operator in a line that's over the column limit
PenaltyBreakAssignment: 100
IncludeBlocks: Regroup
# Include categories go like this:

View file

@ -1167,15 +1167,15 @@ void DNS_Mgr::IssueAsyncRequests()
if ( req->IsAddrReq() )
success = DoRequest(nb_dns, new DNS_Mgr_Request(req->host));
else if ( req->is_txt )
success =
DoRequest(nb_dns, new DNS_Mgr_Request(req->name.c_str(), AF_INET, req->is_txt));
success = DoRequest(nb_dns,
new DNS_Mgr_Request(req->name.c_str(), AF_INET, req->is_txt));
else
{
// If only one request type succeeds, don't consider it a failure.
success =
DoRequest(nb_dns, new DNS_Mgr_Request(req->name.c_str(), AF_INET, req->is_txt));
success =
DoRequest(nb_dns, new DNS_Mgr_Request(req->name.c_str(), AF_INET6, req->is_txt)) ||
success = DoRequest(nb_dns,
new DNS_Mgr_Request(req->name.c_str(), AF_INET, req->is_txt));
success = DoRequest(nb_dns,
new DNS_Mgr_Request(req->name.c_str(), AF_INET6, req->is_txt)) ||
success;
}

View file

@ -1060,8 +1060,8 @@ int Dictionary::LookupIndex(const void* key, int key_size, detail::hash_t hash,
#ifdef DEBUG
int linear_position = LinearLookupIndex(key, key_size, hash);
#endif // DEBUG
int position =
LookupIndex(key, key_size, hash, bucket, Capacity(), insert_position, insert_distance);
int position = LookupIndex(key, key_size, hash, bucket, Capacity(), insert_position,
insert_distance);
if ( position >= 0 )
{
ASSERT(position == linear_position); // same as linearLookup

View file

@ -72,8 +72,8 @@ bool Discarder::NextPacket(const std::unique_ptr<IP_Hdr>& ip, int len, int caple
bool is_tcp = (proto == IPPROTO_TCP);
bool is_udp = (proto == IPPROTO_UDP);
int min_hdr_len =
is_tcp ? sizeof(struct tcphdr) : (is_udp ? sizeof(struct udphdr) : sizeof(struct icmp));
int min_hdr_len = is_tcp ? sizeof(struct tcphdr)
: (is_udp ? sizeof(struct udphdr) : sizeof(struct icmp));
if ( len < min_hdr_len || caplen < min_hdr_len )
// we don't have a complete protocol header

View file

@ -32,8 +32,8 @@ const FuncTypePtr& EventHandler::GetType(bool check_export)
if ( type )
return type;
const auto& id =
detail::lookup_ID(name.data(), detail::current_module.c_str(), false, false, check_export);
const auto& id = detail::lookup_ID(name.data(), detail::current_module.c_str(), false, false,
check_export);
if ( ! id )
return FuncType::nil;

View file

@ -277,8 +277,8 @@ void Expr::AssignToIndex(ValPtr v1, ValPtr v2, ValPtr v3) const
{
bool iterators_invalidated;
auto error_msg =
assign_to_index(std::move(v1), std::move(v2), std::move(v3), iterators_invalidated);
auto error_msg = assign_to_index(std::move(v1), std::move(v2), std::move(v3),
iterators_invalidated);
if ( iterators_invalidated )
{
@ -718,8 +718,8 @@ ValPtr UnaryExpr::Fold(Val* v) const
void UnaryExpr::ExprDescribe(ODesc* d) const
{
bool is_coerce =
Tag() == EXPR_ARITH_COERCE || Tag() == EXPR_RECORD_COERCE || Tag() == EXPR_TABLE_COERCE;
bool is_coerce = Tag() == EXPR_ARITH_COERCE || Tag() == EXPR_RECORD_COERCE ||
Tag() == EXPR_TABLE_COERCE;
if ( d->IsReadable() )
{
@ -1084,8 +1084,8 @@ ValPtr BinaryExpr::PatternFold(Val* v1, Val* v2) const
if ( tag != EXPR_AND && tag != EXPR_OR )
BadTag("BinaryExpr::PatternFold");
RE_Matcher* res =
tag == EXPR_AND ? RE_Matcher_conjunction(re1, re2) : RE_Matcher_disjunction(re1, re2);
RE_Matcher* res = tag == EXPR_AND ? RE_Matcher_conjunction(re1, re2)
: RE_Matcher_disjunction(re1, re2);
return make_intrusive<PatternVal>(res);
}
@ -2860,8 +2860,8 @@ IndexExpr::IndexExpr(ExprPtr arg_op1, ListExprPtr arg_op2, bool arg_is_slice)
if ( match_type == DOES_NOT_MATCH_INDEX )
{
std::string error_msg =
util::fmt("expression with type '%s' is not a type that can be indexed",
std::string error_msg = util::fmt(
"expression with type '%s' is not a type that can be indexed",
type_name(op1->GetType()->Tag()));
SetError(error_msg.data());
}
@ -3995,8 +3995,8 @@ RecordCoerceExpr::RecordCoerceExpr(ExprPtr arg_op, RecordTypePtr r)
if ( ! is_arithmetic_promotable(sup_t_i.get(), sub_t_i.get()) &&
! is_record_promotable(sup_t_i.get(), sub_t_i.get()) )
{
std::string error_msg =
util::fmt("type clash for field \"%s\"", sub_r->FieldName(i));
std::string error_msg = util::fmt("type clash for field \"%s\"",
sub_r->FieldName(i));
Error(error_msg.c_str(), sub_t_i.get());
SetError();
break;
@ -4015,8 +4015,8 @@ RecordCoerceExpr::RecordCoerceExpr(ExprPtr arg_op, RecordTypePtr r)
{
if ( ! t_r->FieldDecl(i)->GetAttr(ATTR_OPTIONAL) )
{
std::string error_msg =
util::fmt("non-optional field \"%s\" missing", t_r->FieldName(i));
std::string error_msg = util::fmt("non-optional field \"%s\" missing",
t_r->FieldName(i));
Error(error_msg.c_str());
SetError();
break;
@ -4101,8 +4101,8 @@ RecordValPtr coerce_to_record(RecordTypePtr rt, Val* v, const std::vector<int>&
if ( rhs_type->Tag() == TYPE_RECORD && field_type->Tag() == TYPE_RECORD &&
! same_type(rhs_type, field_type) )
{
if ( auto new_val =
rhs->AsRecordVal()->CoerceTo(cast_intrusive<RecordType>(field_type)) )
if ( auto new_val = rhs->AsRecordVal()->CoerceTo(
cast_intrusive<RecordType>(field_type)) )
rhs = std::move(new_val);
}
else if ( BothArithmetic(rhs_type->Tag(), field_type->Tag()) &&
@ -4125,8 +4125,8 @@ RecordValPtr coerce_to_record(RecordTypePtr rt, Val* v, const std::vector<int>&
if ( def_type->Tag() == TYPE_RECORD && field_type->Tag() == TYPE_RECORD &&
! same_type(def_type, field_type) )
{
auto tmp =
def_val->AsRecordVal()->CoerceTo(cast_intrusive<RecordType>(field_type));
auto tmp = def_val->AsRecordVal()->CoerceTo(
cast_intrusive<RecordType>(field_type));
if ( tmp )
def_val = std::move(tmp);
@ -4567,9 +4567,9 @@ LambdaExpr::LambdaExpr(std::unique_ptr<function_ingredients> arg_ing, IDPList ar
// Install a dummy version of the function globally for use only
// when broker provides a closure.
auto dummy_func =
make_intrusive<ScriptFunc>(ingredients->id, ingredients->body, ingredients->inits,
ingredients->frame_size, ingredients->priority);
auto dummy_func = make_intrusive<ScriptFunc>(ingredients->id, ingredients->body,
ingredients->inits, ingredients->frame_size,
ingredients->priority);
dummy_func->SetOuterIDs(outer_ids);
@ -4880,8 +4880,8 @@ TypePtr ListExpr::InitType() const
// Collapse any embedded sets or lists.
if ( ti->IsSet() || ti->Tag() == TYPE_LIST )
{
TypeList* til =
ti->IsSet() ? ti->AsSetType()->GetIndices().get() : ti->AsTypeList();
TypeList* til = ti->IsSet() ? ti->AsSetType()->GetIndices().get()
: ti->AsTypeList();
if ( ! til->IsPure() || ! til->AllMatch(til->GetPureType(), true) )
tl->Append({NewRef{}, til});
@ -5164,8 +5164,8 @@ RecordAssignExpr::RecordAssignExpr(const ExprPtr& record, const ExprPtr& init_li
if ( field >= 0 && same_type(lhs->GetFieldType(field), t->GetFieldType(j)) )
{
auto fe_lhs = make_intrusive<FieldExpr>(record, field_name);
auto fe_rhs =
make_intrusive<FieldExpr>(IntrusivePtr{NewRef{}, init}, field_name);
auto fe_rhs = make_intrusive<FieldExpr>(IntrusivePtr{NewRef{}, init},
field_name);
Append(get_assign_expr(std::move(fe_lhs), std::move(fe_rhs), is_init));
}
}

View file

@ -656,8 +656,8 @@ void IPv6_Hdr_Chain::ProcessDstOpts(const struct ip6_dest* d, uint16_t len)
if ( homeAddr )
reporter->Weird(SrcAddr(), DstAddr(), "multiple_home_addr_opts");
else
homeAddr =
new IPAddr(*((const in6_addr*)(data + sizeof(struct ip6_opt))));
homeAddr = new IPAddr(
*((const in6_addr*)(data + sizeof(struct ip6_opt))));
}
else
reporter->Weird(SrcAddr(), DstAddr(), "bad_home_addr_len");

View file

@ -292,8 +292,8 @@ void init_net_var()
udp_content_deliver_all_orig = bool(id::find_val("udp_content_deliver_all_orig")->AsBool());
udp_content_deliver_all_resp = bool(id::find_val("udp_content_deliver_all_resp")->AsBool());
udp_content_delivery_ports_use_resp =
bool(id::find_val("udp_content_delivery_ports_use_resp")->AsBool());
udp_content_delivery_ports_use_resp = bool(
id::find_val("udp_content_delivery_ports_use_resp")->AsBool());
dns_session_timeout = id::find_val("dns_session_timeout")->AsInterval();
rpc_timeout = id::find_val("rpc_timeout")->AsInterval();

View file

@ -94,8 +94,8 @@ std::list<std::tuple<IPPrefix, void*>> PrefixTable::FindAll(const SubNetVal* val
void* PrefixTable::Lookup(const IPAddr& addr, int width, bool exact) const
{
prefix_t* prefix = MakePrefix(addr, width);
patricia_node_t* node =
exact ? patricia_search_exact(tree, prefix) : patricia_search_best(tree, prefix);
patricia_node_t* node = exact ? patricia_search_exact(tree, prefix)
: patricia_search_best(tree, prefix);
int elems = 0;
patricia_node_t** list = nullptr;

View file

@ -600,10 +600,10 @@ void Reporter::DoLog(const char* prefix, EventHandlerPtr event, FILE* out, Conne
if ( locations.size() )
{
auto locs = locations.back();
raise_event =
PLUGIN_HOOK_WITH_RESULT(HOOK_REPORTER,
raise_event = PLUGIN_HOOK_WITH_RESULT(HOOK_REPORTER,
HookReporter(prefix, event, conn, addl, location,
locs.first, locs.second, time, buffer),
locs.first, locs.second, time,
buffer),
true);
}
else

View file

@ -663,8 +663,8 @@ RuleMatcher::MIME_Matches* RuleMatcher::Match(RuleFileMagicState* state, const u
#ifdef DEBUG
if ( debug_logger.IsEnabled(DBG_RULES) )
{
const char* s =
util::fmt_bytes(reinterpret_cast<const char*>(data), min(40, static_cast<int>(len)));
const char* s = util::fmt_bytes(reinterpret_cast<const char*>(data),
min(40, static_cast<int>(len)));
DBG_LOG(DBG_RULES, "Matching %s rules on |%s%s|", Rule::TypeToString(Rule::FILE_MAGIC), s,
len > 40 ? "..." : "");
}
@ -806,8 +806,8 @@ RuleEndpointState* RuleMatcher::InitEndpoint(analyzer::Analyzer* analyzer, const
case RuleHdrTest::ICMPv6:
case RuleHdrTest::TCP:
case RuleHdrTest::UDP:
match =
compare(*h->vals, getval(ip->Payload() + h->offset, h->size), h->comp);
match = compare(*h->vals, getval(ip->Payload() + h->offset, h->size),
h->comp);
break;
case RuleHdrTest::IPSrc:
@ -1405,8 +1405,8 @@ void RuleMatcherState::InitEndpointMatcher(analyzer::Analyzer* analyzer, const I
delete orig_match_state;
}
orig_match_state =
rule_matcher->InitEndpoint(analyzer, ip, caplen, resp_match_state, from_orig, pia);
orig_match_state = rule_matcher->InitEndpoint(analyzer, ip, caplen, resp_match_state,
from_orig, pia);
}
else
@ -1417,8 +1417,8 @@ void RuleMatcherState::InitEndpointMatcher(analyzer::Analyzer* analyzer, const I
delete resp_match_state;
}
resp_match_state =
rule_matcher->InitEndpoint(analyzer, ip, caplen, orig_match_state, from_orig, pia);
resp_match_state = rule_matcher->InitEndpoint(analyzer, ip, caplen, orig_match_state,
from_orig, pia);
}
}

View file

@ -386,8 +386,9 @@ void get_final_stats()
{
iosource::PktSrc::Stats s;
ps->Statistics(&s);
double dropped_pct =
s.dropped > 0.0 ? ((double)s.dropped / ((double)s.received + (double)s.dropped)) * 100.0
double dropped_pct = s.dropped > 0.0
? ((double)s.dropped / ((double)s.received + (double)s.dropped)) *
100.0
: 0.0;
reporter->Info("%" PRIu64 " packets received on interface %s, %" PRIu64 " (%.2f%%) dropped",
s.received, ps->Path().c_str(), s.dropped, dropped_pct);

View file

@ -111,8 +111,8 @@ const IDPtr& lookup_ID(const char* name, const char* curr_module, bool no_global
std::string fullname = make_full_var_name(curr_module, name);
std::string ID_module = extract_module_name(fullname.c_str());
bool need_export =
check_export && (ID_module != GLOBAL_MODULE_NAME && ID_module != curr_module);
bool need_export = check_export &&
(ID_module != GLOBAL_MODULE_NAME && ID_module != curr_module);
for ( auto s_i = scopes.rbegin(); s_i != scopes.rend(); ++s_i )
{

View file

@ -392,13 +392,15 @@ void SegmentProfiler::Report()
struct rusage final_rusage;
getrusage(RUSAGE_SELF, &final_rusage);
double start_time =
double(initial_rusage.ru_utime.tv_sec) + double(initial_rusage.ru_utime.tv_usec) / 1e6 +
double(initial_rusage.ru_stime.tv_sec) + double(initial_rusage.ru_stime.tv_usec) / 1e6;
double start_time = double(initial_rusage.ru_utime.tv_sec) +
double(initial_rusage.ru_utime.tv_usec) / 1e6 +
double(initial_rusage.ru_stime.tv_sec) +
double(initial_rusage.ru_stime.tv_usec) / 1e6;
double stop_time =
double(final_rusage.ru_utime.tv_sec) + double(final_rusage.ru_utime.tv_usec) / 1e6 +
double(final_rusage.ru_stime.tv_sec) + double(final_rusage.ru_stime.tv_usec) / 1e6;
double stop_time = double(final_rusage.ru_utime.tv_sec) +
double(final_rusage.ru_utime.tv_usec) / 1e6 +
double(final_rusage.ru_stime.tv_sec) +
double(final_rusage.ru_stime.tv_usec) / 1e6;
int start_mem = initial_rusage.ru_maxrss * 1024;
int stop_mem = initial_rusage.ru_maxrss * 1024;

View file

@ -345,8 +345,8 @@ void do_print_stmt(const std::vector<ValPtr>& vals)
++offset;
}
static auto print_log_type =
static_cast<BifEnum::Log::PrintLogType>(id::find_val("Log::print_to_log")->AsEnum());
static auto print_log_type = static_cast<BifEnum::Log::PrintLogType>(
id::find_val("Log::print_to_log")->AsEnum());
switch ( print_log_type )
{

View file

@ -103,8 +103,8 @@ void TimerMgr::Process()
// Just advance the timer manager based on the current network time. This won't actually
// change the time, but will dispatch any timers that need dispatching.
run_state::current_dispatched +=
Advance(run_state::network_time, max_timer_expires - run_state::current_dispatched);
run_state::current_dispatched += Advance(run_state::network_time,
max_timer_expires - run_state::current_dispatched);
}
void TimerMgr::InitPostScript()

View file

@ -520,8 +520,8 @@ TableType::TableType(TypeListPtr ind, TypePtr yield)
if ( ! is_supported_index_type(tli, &unsupported_type_name) )
{
auto msg =
util::fmt("index type containing '%s' is not supported", unsupported_type_name);
auto msg = util::fmt("index type containing '%s' is not supported",
unsupported_type_name);
Error(msg, tli.get());
SetError();
break;
@ -1720,8 +1720,8 @@ void EnumType::DescribeReST(ODesc* d, bool roles_only) const
if ( doc->GetDeclaringScript() )
enum_from_script = doc->GetDeclaringScript()->Name();
zeekygen::detail::IdentifierInfo* type_doc =
detail::zeekygen_mgr->GetIdentifierInfo(GetName());
zeekygen::detail::IdentifierInfo* type_doc = detail::zeekygen_mgr->GetIdentifierInfo(
GetName());
if ( type_doc && type_doc->GetDeclaringScript() )
type_from_script = type_doc->GetDeclaringScript()->Name();
@ -2310,10 +2310,10 @@ TypePtr merge_types(const TypePtr& arg_t1, const TypePtr& arg_t2)
// actually see those changes from the redef.
return id->GetType();
std::string msg =
util::fmt("incompatible enum types: '%s' and '%s'"
std::string msg = util::fmt("incompatible enum types: '%s' and '%s'"
" ('%s' enum type ID is invalid)",
t1->GetName().data(), t2->GetName().data(), t1->GetName().data());
t1->GetName().data(), t2->GetName().data(),
t1->GetName().data());
t1->Error(msg.data(), t2);
return nullptr;
}

View file

@ -1839,8 +1839,8 @@ ValPtr TableVal::Default(const ValPtr& index)
record_promotion_compatible(dtype->AsRecordType(), ytype->AsRecordType()) )
{
auto rt = cast_intrusive<RecordType>(ytype);
auto coerce =
make_intrusive<detail::RecordCoerceExpr>(def_attr->GetExpr(), std::move(rt));
auto coerce = make_intrusive<detail::RecordCoerceExpr>(def_attr->GetExpr(),
std::move(rt));
def_val = coerce->Eval(nullptr);
}

View file

@ -271,8 +271,8 @@ public:
static constexpr bro_uint_t PREALLOCATED_COUNTS = 4096;
static constexpr bro_uint_t PREALLOCATED_INTS = 512;
static constexpr bro_int_t PREALLOCATED_INT_LOWEST = -255;
static constexpr bro_int_t PREALLOCATED_INT_HIGHEST =
PREALLOCATED_INT_LOWEST + PREALLOCATED_INTS - 1;
static constexpr bro_int_t PREALLOCATED_INT_HIGHEST = PREALLOCATED_INT_LOWEST +
PREALLOCATED_INTS - 1;
ValManager();

View file

@ -865,8 +865,8 @@ bool DNS_Interpreter::ParseRR_EDNS(detail::DNS_MsgInfo* msg, const u_char*& data
if ( server_cookie_len >= 8 )
{
cookie.server_cookie =
ExtractStream(data, server_cookie_len, server_cookie_len);
cookie.server_cookie = ExtractStream(data, server_cookie_len,
server_cookie_len);
}
analyzer->EnqueueConnEvent(dns_EDNS_cookie, analyzer->ConnVal(), msg->BuildHdrVal(),

View file

@ -330,8 +330,8 @@ void HTTP_Entity::SubmitData(int len, const char* buf)
else
{
if ( send_size && content_length > 0 )
precomputed_file_id =
file_mgr->SetSize(content_length, http_message->MyHTTP_Analyzer()->GetAnalyzerTag(),
precomputed_file_id = file_mgr->SetSize(
content_length, http_message->MyHTTP_Analyzer()->GetAnalyzerTag(),
http_message->MyHTTP_Analyzer()->Conn(), http_message->IsOrig(),
precomputed_file_id);
@ -894,8 +894,8 @@ void HTTP_Analyzer::DeliverStream(int len, const u_char* data, bool is_orig)
const char* line = reinterpret_cast<const char*>(data);
const char* end_of_line = line + len;
analyzer::tcp::ContentLine_Analyzer* content_line =
is_orig ? content_line_orig : content_line_resp;
analyzer::tcp::ContentLine_Analyzer* content_line = is_orig ? content_line_orig
: content_line_resp;
if ( content_line->IsPlainDelivery() )
{
@ -1063,8 +1063,8 @@ void HTTP_Analyzer::Undelivered(uint64_t seq, int len, bool is_orig)
HTTP_Message* msg = is_orig ? request_message : reply_message;
analyzer::tcp::ContentLine_Analyzer* content_line =
is_orig ? content_line_orig : content_line_resp;
analyzer::tcp::ContentLine_Analyzer* content_line = is_orig ? content_line_orig
: content_line_resp;
if ( ! content_line->IsSkippedContents(seq, len) )
{

View file

@ -1461,9 +1461,9 @@ void MIME_Mail::SubmitData(int len, const char* buf)
make_intrusive<StringVal>(data_len, data));
}
cur_entity_id =
file_mgr->DataIn(reinterpret_cast<const u_char*>(buf), len, analyzer->GetAnalyzerTag(),
analyzer->Conn(), is_orig, cur_entity_id);
cur_entity_id = file_mgr->DataIn(reinterpret_cast<const u_char*>(buf), len,
analyzer->GetAnalyzerTag(), analyzer->Conn(), is_orig,
cur_entity_id);
cur_entity_len += len;
buffer_start = (buf + len) - (char*)data_buffer->Bytes();

View file

@ -382,11 +382,11 @@ void PIA_TCP::ActivateAnalyzer(analyzer::Tag tag, const zeek::detail::Rule* rule
auto* tcp = static_cast<packet_analysis::TCP::TCPSessionAdapter*>(Parent());
auto* reass_orig =
new tcp::TCP_Reassembler(this, tcp, tcp::TCP_Reassembler::Direct, tcp->Orig());
auto* reass_orig = new tcp::TCP_Reassembler(this, tcp, tcp::TCP_Reassembler::Direct,
tcp->Orig());
auto* reass_resp =
new tcp::TCP_Reassembler(this, tcp, tcp::TCP_Reassembler::Direct, tcp->Resp());
auto* reass_resp = new tcp::TCP_Reassembler(this, tcp, tcp::TCP_Reassembler::Direct,
tcp->Resp());
uint64_t orig_seq = 0;
uint64_t resp_seq = 0;

View file

@ -585,9 +585,9 @@ void POP3_Analyzer::ProcessReply(int length, const char* line)
if ( multiLine == true )
{
bool terminator =
line[0] == '.' &&
(length == 1 || (length > 1 && (line[1] == '\n' ||
bool terminator = line[0] == '.' &&
(length == 1 ||
(length > 1 && (line[1] == '\n' ||
(length > 2 && line[1] == '\r' && line[2] == '\n'))));
if ( terminator )

View file

@ -69,8 +69,8 @@ RPC_CallInfo::RPC_CallInfo(uint32_t arg_xid, const u_char*& buf, int& n, double
stamp = extract_XDR_uint32(cred_opaque, cred_opaque_n);
int machinename_n;
constexpr auto max_machinename_len = 255;
auto mnp =
extract_XDR_opaque(cred_opaque, cred_opaque_n, machinename_n, max_machinename_len);
auto mnp = extract_XDR_opaque(cred_opaque, cred_opaque_n, machinename_n,
max_machinename_len);
if ( ! mnp )
{

View file

@ -42,14 +42,14 @@ TCP_Reassembler::TCP_Reassembler(analyzer::Analyzer* arg_dst_analyzer,
if ( ::tcp_contents )
{
static auto tcp_content_delivery_ports_orig =
id::find_val<TableVal>("tcp_content_delivery_ports_orig");
static auto tcp_content_delivery_ports_resp =
id::find_val<TableVal>("tcp_content_delivery_ports_resp");
const auto& dst_port_val =
val_mgr->Port(ntohs(tcp_analyzer->Conn()->RespPort()), TRANSPORT_TCP);
const auto& ports =
IsOrig() ? tcp_content_delivery_ports_orig : tcp_content_delivery_ports_resp;
static auto tcp_content_delivery_ports_orig = id::find_val<TableVal>(
"tcp_content_delivery_ports_orig");
static auto tcp_content_delivery_ports_resp = id::find_val<TableVal>(
"tcp_content_delivery_ports_resp");
const auto& dst_port_val = val_mgr->Port(ntohs(tcp_analyzer->Conn()->RespPort()),
TRANSPORT_TCP);
const auto& ports = IsOrig() ? tcp_content_delivery_ports_orig
: tcp_content_delivery_ports_resp;
auto result = ports->FindOrDefault(dst_port_val);
if ( (IsOrig() && zeek::detail::tcp_content_deliver_all_orig) ||
@ -519,9 +519,9 @@ void TCP_Reassembler::AckReceived(uint64_t seq)
// Nothing to do.
return;
bool test_active =
! skip_deliveries && ! tcp_analyzer->Skipping() &&
(BifConst::report_gaps_for_partial || (endp->state == TCP_ENDPOINT_ESTABLISHED &&
bool test_active = ! skip_deliveries && ! tcp_analyzer->Skipping() &&
(BifConst::report_gaps_for_partial ||
(endp->state == TCP_ENDPOINT_ESTABLISHED &&
endp->peer->state == TCP_ENDPOINT_ESTABLISHED));
uint64_t num_missing = TrimToSeq(seq);

View file

@ -364,8 +364,8 @@ struct val_converter
unsigned int pos = 0;
for ( auto& item : a )
{
auto item_val =
data_to_val(move(item), pure ? lt->GetPureType().get() : types[pos].get());
auto item_val = data_to_val(move(item),
pure ? lt->GetPureType().get() : types[pos].get());
pos++;
if ( ! item_val )

View file

@ -376,8 +376,8 @@ void Manager::InitializeBrokerStoreForwarding()
if ( id->HasVal() && id->GetAttr(zeek::detail::ATTR_BACKEND) )
{
const auto& attr = id->GetAttr(zeek::detail::ATTR_BACKEND);
auto e =
static_cast<BifEnum::Broker::BackendType>(attr->GetExpr()->Eval(nullptr)->AsEnum());
auto e = static_cast<BifEnum::Broker::BackendType>(
attr->GetExpr()->Eval(nullptr)->AsEnum());
auto storename = std::string("___sync_store_") + global.first;
id->GetVal()->AsTableVal()->SetBrokerStore(storename);
AddForwardedStore(storename, cast_intrusive<TableVal>(id->GetVal()));
@ -739,8 +739,8 @@ bool Manager::PublishLogWrite(EnumVal* stream, EnumVal* writer, string path, int
std::string serial_data(data, len);
free(data);
auto v =
log_topic_func->Invoke(IntrusivePtr{NewRef{}, stream}, make_intrusive<StringVal>(path));
auto v = log_topic_func->Invoke(IntrusivePtr{NewRef{}, stream},
make_intrusive<StringVal>(path));
if ( ! v )
{
@ -1797,8 +1797,8 @@ void Manager::BrokerStoreToZeekTable(const std::string& name, const detail::Stor
if ( its.size() == 1 )
zeek_key = detail::data_to_val(key, its[0].get());
else
zeek_key =
detail::data_to_val(key, table->GetType()->AsTableType()->GetIndices().get());
zeek_key = detail::data_to_val(key,
table->GetType()->AsTableType()->GetIndices().get());
if ( ! zeek_key )
{

View file

@ -177,8 +177,8 @@ RecordValPtr X509::ParseCertificate(X509Val* cert_val, file_analysis::File* f)
if ( OBJ_obj2nid(algorithm) == NID_md5WithRSAEncryption )
{
ASN1_OBJECT* copy =
OBJ_dup(algorithm); // the next line will destroy the original algorithm.
ASN1_OBJECT* copy = OBJ_dup(
algorithm); // the next line will destroy the original algorithm.
X509_PUBKEY_set0_param(X509_get_X509_PUBKEY(ssl_cert), OBJ_nid2obj(NID_rsaEncryption), 0,
NULL, NULL, 0);
algorithm = copy;
@ -288,8 +288,8 @@ void X509::ParseBasicConstraints(X509_EXTENSION* ex)
{
if ( x509_ext_basic_constraints )
{
auto pBasicConstraint =
make_intrusive<RecordVal>(BifType::Record::X509::BasicConstraints);
auto pBasicConstraint = make_intrusive<RecordVal>(
BifType::Record::X509::BasicConstraints);
pBasicConstraint->Assign(0, constr->ca);
if ( constr->pathlen )

View file

@ -205,8 +205,8 @@ void X509Common::ParseSignedCertificateTimestamps(X509_EXTENSION* ext)
unsigned char* ext_val_second_pointer = ext_val_copy;
memcpy(ext_val_copy, ext_val->data, ext_val->length);
ASN1_OCTET_STRING* inner =
d2i_ASN1_OCTET_STRING(NULL, (const unsigned char**)&ext_val_copy, ext_val->length);
ASN1_OCTET_STRING* inner = d2i_ASN1_OCTET_STRING(NULL, (const unsigned char**)&ext_val_copy,
ext_val->length);
if ( ! inner )
{
reporter->Error(

View file

@ -1179,8 +1179,8 @@ int Manager::SendEntryTable(Stream* i, const Value* const* vals)
zeek::detail::hash_t valhash = 0;
if ( stream->num_val_fields > 0 )
{
if ( zeek::detail::HashKey* valhashkey =
HashValues(stream->num_val_fields, vals + stream->num_idx_fields) )
if ( zeek::detail::HashKey* valhashkey = HashValues(stream->num_val_fields,
vals + stream->num_idx_fields) )
{
valhash = valhashkey->Hash();
delete (valhashkey);
@ -1681,8 +1681,8 @@ int Manager::PutTable(Stream* i, const Value* const* vals)
{
// in case of update send back the old value.
assert(stream->num_val_fields > 0);
auto ev =
BifType::Enum::Input::Event->GetEnumVal(BifEnum::Input::EVENT_CHANGED);
auto ev = BifType::Enum::Input::Event->GetEnumVal(
BifEnum::Input::EVENT_CHANGED);
assert(oldval != nullptr);
SendEvent(stream->event, 4, stream->description->Ref(), ev.release(), predidx,
oldval.release());
@ -1746,8 +1746,8 @@ bool Manager::Delete(ReaderFrontend* reader, Value** vals)
{
TableStream* stream = (TableStream*)i;
bool convert_error = false;
Val* idxval =
ValueToIndexVal(i, stream->num_idx_fields, stream->itype, vals, convert_error);
Val* idxval = ValueToIndexVal(i, stream->num_idx_fields, stream->itype, vals,
convert_error);
readVals = stream->num_idx_fields + stream->num_val_fields;
bool streamresult = true;
@ -1772,8 +1772,8 @@ bool Manager::Delete(ReaderFrontend* reader, Value** vals)
Unref(predidx);
else
{
auto ev =
BifType::Enum::Input::Event->GetEnumVal(BifEnum::Input::EVENT_REMOVED);
auto ev = BifType::Enum::Input::Event->GetEnumVal(
BifEnum::Input::EVENT_REMOVED);
streamresult = CallPred(stream->pred, 3, ev.release(), predidx,
IntrusivePtr{val}.release());
@ -1906,8 +1906,8 @@ RecordVal* Manager::ListValToRecordVal(ListVal* list, RecordType* request_type,
Val* fieldVal = nullptr;
if ( request_type->GetFieldType(i)->Tag() == TYPE_RECORD )
fieldVal =
ListValToRecordVal(list, request_type->GetFieldType(i)->AsRecordType(), position);
fieldVal = ListValToRecordVal(list, request_type->GetFieldType(i)->AsRecordType(),
position);
else
{
fieldVal = list->Idx(*position).get();

View file

@ -419,8 +419,8 @@ bool Ascii::DoUpdate()
assert(val->type == TYPE_PORT);
// Error(Fmt("Got type %d != PORT with secondary position!", val->type));
val->val.port_val.proto =
formatter->ParseProto(stringfields[(*fit).secondary_position]);
val->val.port_val.proto = formatter->ParseProto(
stringfields[(*fit).secondary_position]);
}
fields[fpos] = val;

View file

@ -69,8 +69,8 @@ bool Config::DoInit(const ReaderInfo& info, int num_fields, const Field* const*
BifConst::InputConfig::empty_field->Len());
threading::formatter::Ascii::SeparatorInfo sep_info("\t", set_separator, "", empty_field);
formatter =
std::unique_ptr<threading::Formatter>(new threading::formatter::Ascii(this, sep_info));
formatter = std::unique_ptr<threading::Formatter>(
new threading::formatter::Ascii(this, sep_info));
return DoUpdate();
}

View file

@ -256,8 +256,8 @@ bool Raw::Execute()
if ( use_stderr )
{
stderrfile =
std::unique_ptr<FILE, int (*)(FILE*)>(fdopen(pipes[stderr_in], "r"), fclose);
stderrfile = std::unique_ptr<FILE, int (*)(FILE*)>(fdopen(pipes[stderr_in], "r"),
fclose);
if ( ! stderrfile )
{
@ -359,8 +359,8 @@ bool Raw::DoInit(const ReaderInfo& info, int num_fields, const Field* const* fie
fname = source.substr(0, fname.length() - 1);
}
ReaderInfo::config_map::const_iterator it =
info.config.find("stdin"); // data that is sent to the child process
ReaderInfo::config_map::const_iterator it = info.config.find(
"stdin"); // data that is sent to the child process
if ( it != info.config.end() )
{
stdin_string = it->second;
@ -486,8 +486,8 @@ int64_t Raw::GetLine(FILE* arg_file)
repeats++;
// bah, we cannot use realloc because we would have to change the delete in the manager
// to a free.
std::unique_ptr<char[]> newbuf =
std::unique_ptr<char[]>(new char[block_size * repeats]);
std::unique_ptr<char[]> newbuf = std::unique_ptr<char[]>(
new char[block_size * repeats]);
memcpy(newbuf.get(), buf.get(), block_size * (repeats - 1));
buf = std::move(newbuf);
offset = block_size * (repeats - 1);

View file

@ -526,8 +526,8 @@ bool Manager::TraverseRecord(Stream* stream, Filter* filter, RecordType* rt, Tab
bool optional = (bool)rtype->FieldDecl(i)->GetAttr(detail::ATTR_OPTIONAL);
filter->fields[filter->num_fields - 1] =
new threading::Field(new_path.c_str(), nullptr, t->Tag(), st, optional);
filter->fields[filter->num_fields - 1] = new threading::Field(new_path.c_str(), nullptr,
t->Tag(), st, optional);
}
return true;
@ -868,8 +868,8 @@ bool Manager::Write(EnumVal* id, RecordVal* columns_arg)
if ( const auto& val = filter->field_name_map->Find(fn) )
{
delete[] filter->fields[j]->name;
filter->fields[j]->name =
util::copy_string(val->AsStringVal()->CheckString());
filter->fields[j]->name = util::copy_string(
val->AsStringVal()->CheckString());
}
}
arg_fields[j] = new threading::Field(*filter->fields[j]);
@ -1049,8 +1049,8 @@ threading::Value* Manager::ValToLogVal(Val* val, Type* ty)
for ( bro_int_t i = 0; i < lval->val.vector_val.size; i++ )
{
lval->val.vector_val.vals[i] =
ValToLogVal(vec->ValAt(i).get(), vec->GetType()->Yield().get());
lval->val.vector_val.vals[i] = ValToLogVal(vec->ValAt(i).get(),
vec->GetType()->Yield().get());
}
break;
@ -1153,8 +1153,8 @@ WriterFrontend* Manager::CreateWriter(EnumVal* id, EnumVal* writer, WriterBacken
return nullptr;
}
Stream::WriterMap::iterator w =
stream->writers.find(Stream::WriterPathPair(writer->AsEnum(), info->path));
Stream::WriterMap::iterator w = stream->writers.find(
Stream::WriterPathPair(writer->AsEnum(), info->path));
if ( w != stream->writers.end() )
{
@ -1279,8 +1279,8 @@ bool Manager::WriteFromRemote(EnumVal* id, EnumVal* writer, const string& path,
return true;
}
Stream::WriterMap::iterator w =
stream->writers.find(Stream::WriterPathPair(writer->AsEnum(), path));
Stream::WriterMap::iterator w = stream->writers.find(
Stream::WriterPathPair(writer->AsEnum(), path));
if ( w == stream->writers.end() )
{
@ -1478,11 +1478,11 @@ void Manager::InstallRotationTimer(WriterInfo* winfo)
static auto base_time = log_rotate_base_time->AsString()->CheckString();
double base = util::detail::parse_rotate_base_time(base_time);
double delta_t =
util::detail::calc_next_rotate(run_state::network_time, rotation_interval, base);
double delta_t = util::detail::calc_next_rotate(run_state::network_time,
rotation_interval, base);
winfo->rotation_timer =
new RotationTimer(run_state::network_time + delta_t, winfo, true);
winfo->rotation_timer = new RotationTimer(run_state::network_time + delta_t, winfo,
true);
}
zeek::detail::timer_mgr->Add(winfo->rotation_timer);
@ -1561,9 +1561,9 @@ void Manager::Rotate(WriterInfo* winfo)
else
ppf = default_ppf;
auto rotation_path =
FormatRotationPath({NewRef{}, winfo->type}, winfo->writer->Info().path, winfo->open_time,
run_state::network_time, run_state::terminating, std::move(ppf));
auto rotation_path = FormatRotationPath({NewRef{}, winfo->type}, winfo->writer->Info().path,
winfo->open_time, run_state::network_time,
run_state::terminating, std::move(ppf));
winfo->writer->Rotate(rotation_path.data(), winfo->open_time, run_state::network_time,
run_state::terminating);

View file

@ -239,8 +239,8 @@ bool WriterBackend::Write(int arg_num_fields, int num_writes, Value*** vals)
if ( vals[j][i]->type != fields[i]->type )
{
#ifdef DEBUG
const char* msg =
Fmt("Field #%d type doesn't match in WriterBackend::Write() (%d vs. %d)", i,
const char* msg = Fmt(
"Field #%d type doesn't match in WriterBackend::Write() (%d vs. %d)", i,
vals[j][i]->type, fields[i]->type);
Debug(DBG_LOGGING, msg);
#endif

View file

@ -101,8 +101,8 @@ public:
WriterInfo(const WriterInfo& other)
{
path = other.path ? util::copy_string(other.path) : nullptr;
post_proc_func =
other.post_proc_func ? util::copy_string(other.post_proc_func) : nullptr;
post_proc_func = other.post_proc_func ? util::copy_string(other.post_proc_func)
: nullptr;
rotation_interval = other.rotation_interval;
rotation_base = other.rotation_base;
network_time = other.network_time;

View file

@ -105,8 +105,8 @@ static std::optional<LeftoverLog> parse_shadow_log(const std::string& fname)
if ( ! sf_stream )
{
rval.error =
util::fmt("Failed to open %s: %s", rval.shadow_filename.data(), strerror(errno));
rval.error = util::fmt("Failed to open %s: %s", rval.shadow_filename.data(),
strerror(errno));
return rval;
}
@ -124,8 +124,8 @@ static std::optional<LeftoverLog> parse_shadow_log(const std::string& fname)
if ( sf_len == -1 )
{
rval.error =
util::fmt("Failed to ftell() on %s: %s", rval.shadow_filename.data(), strerror(errno));
rval.error = util::fmt("Failed to ftell() on %s: %s", rval.shadow_filename.data(),
strerror(errno));
fclose(sf_stream);
return rval;
}
@ -169,8 +169,8 @@ static std::optional<LeftoverLog> parse_shadow_log(const std::string& fname)
// Use shadow file's modification time as creation time.
if ( stat(rval.shadow_filename.data(), &st) != 0 )
{
rval.error =
util::fmt("Failed to stat %s: %s", rval.shadow_filename.data(), strerror(errno));
rval.error = util::fmt("Failed to stat %s: %s", rval.shadow_filename.data(),
strerror(errno));
return rval;
}
@ -454,8 +454,8 @@ bool Ascii::DoInit(const WriterInfo& info, int num_fields, const threading::Fiel
fname += ext;
bool use_shadow =
BifConst::LogAscii::enable_leftover_log_rotation && Info().rotation_interval > 0;
bool use_shadow = BifConst::LogAscii::enable_leftover_log_rotation &&
Info().rotation_interval > 0;
if ( use_shadow )
{
@ -676,8 +676,8 @@ bool Ascii::DoRotate(const char* rotated_path, double open, double close, bool t
return false;
}
bool use_shadow =
BifConst::LogAscii::enable_leftover_log_rotation && Info().rotation_interval > 0;
bool use_shadow = BifConst::LogAscii::enable_leftover_log_rotation &&
Info().rotation_interval > 0;
if ( use_shadow )
{

View file

@ -49,11 +49,11 @@ bool ICMPAnalyzer::BuildConnTuple(size_t len, const uint8_t* data, Packet* packe
tuple.src_port = htons(icmpp->icmp_type);
if ( packet->proto == IPPROTO_ICMP )
tuple.dst_port =
htons(ICMP4_counterpart(icmpp->icmp_type, icmpp->icmp_code, tuple.is_one_way));
tuple.dst_port = htons(
ICMP4_counterpart(icmpp->icmp_type, icmpp->icmp_code, tuple.is_one_way));
else if ( packet->proto == IPPROTO_ICMPV6 )
tuple.dst_port =
htons(ICMP6_counterpart(icmpp->icmp_type, icmpp->icmp_code, tuple.is_one_way));
tuple.dst_port = htons(
ICMP6_counterpart(icmpp->icmp_type, icmpp->icmp_code, tuple.is_one_way));
else
reporter->InternalError("Reached ICMP packet analyzer with unknown packet protocol %x",
packet->proto);
@ -280,11 +280,11 @@ TransportProto ICMPAnalyzer::GetContextProtocol(const IP_Hdr* ip_hdr, uint32_t*
*src_port = ntohs(icmpp->icmp_type);
if ( ip4 )
*dst_port =
ntohs(ICMP4_counterpart(icmpp->icmp_type, icmpp->icmp_code, is_one_way));
*dst_port = ntohs(
ICMP4_counterpart(icmpp->icmp_type, icmpp->icmp_code, is_one_way));
else
*dst_port =
ntohs(ICMP6_counterpart(icmpp->icmp_type, icmpp->icmp_code, is_one_way));
*dst_port = ntohs(
ICMP6_counterpart(icmpp->icmp_type, icmpp->icmp_code, is_one_way));
break;
}

View file

@ -160,8 +160,8 @@ zeek::Connection* IPBasedAnalyzer::NewConn(const ConnTuple* id, const detail::Co
if ( ! WantConnection(src_h, dst_h, pkt->ip_hdr->Payload(), flip) )
return nullptr;
Connection* conn =
new Connection(key, run_state::processing_start_time, id, pkt->ip_hdr->FlowLabel(), pkt);
Connection* conn = new Connection(key, run_state::processing_start_time, id,
pkt->ip_hdr->FlowLabel(), pkt);
conn->SetTransport(transport);
if ( flip )
@ -293,7 +293,7 @@ void IPBasedAnalyzer::SetIgnoreChecksumsNets(TableValPtr t)
TableValPtr IPBasedAnalyzer::GetIgnoreChecksumsNets()
{
if ( ! IPBasedAnalyzer::ignore_checksums_nets_table )
IPBasedAnalyzer::ignore_checksums_nets_table =
zeek::id::find_val<TableVal>("ignore_checksums_nets");
IPBasedAnalyzer::ignore_checksums_nets_table = zeek::id::find_val<TableVal>(
"ignore_checksums_nets");
return IPBasedAnalyzer::ignore_checksums_nets_table;
}

View file

@ -636,8 +636,8 @@ void TCPSessionAdapter::Process(bool is_orig, const struct tcphdr* tp, int len,
else
{
bool ack_underflow = false;
rel_ack =
get_relative_seq(peer, ack_seq, peer->AckSeq(), peer->AckWraps(), &ack_underflow);
rel_ack = get_relative_seq(peer, ack_seq, peer->AckSeq(), peer->AckWraps(),
&ack_underflow);
if ( ack_underflow )
{
@ -1614,10 +1614,10 @@ void TCPSessionAdapter::AddExtraAnalyzers(Connection* conn)
if ( tcp_contents && ! reass )
{
static auto tcp_content_delivery_ports_orig =
id::find_val<TableVal>("tcp_content_delivery_ports_orig");
static auto tcp_content_delivery_ports_resp =
id::find_val<TableVal>("tcp_content_delivery_ports_resp");
static auto tcp_content_delivery_ports_orig = id::find_val<TableVal>(
"tcp_content_delivery_ports_orig");
static auto tcp_content_delivery_ports_resp = id::find_val<TableVal>(
"tcp_content_delivery_ports_resp");
const auto& dport = val_mgr->Port(ntohs(Conn()->RespPort()), TRANSPORT_TCP);
if ( ! reass )
@ -1821,8 +1821,8 @@ int TCPSessionAdapter::ParseTCPOptions(const struct tcphdr* tcp, bool is_orig)
void TCPSessionAdapter::CheckRecording(bool need_contents, analyzer::tcp::TCP_Flags flags)
{
bool record_current_content = need_contents || Conn()->RecordContents();
bool record_current_packet =
Conn()->RecordPackets() || flags.SYN() || flags.FIN() || flags.RST();
bool record_current_packet = Conn()->RecordPackets() || flags.SYN() || flags.FIN() ||
flags.RST();
Conn()->SetRecordCurrentContent(record_current_content);
Conn()->SetRecordCurrentPacket(record_current_packet);

View file

@ -102,9 +102,10 @@ void UDPAnalyzer::DeliverPacket(Connection* c, double t, bool is_orig, int remai
int chksum = up->uh_sum;
auto validate_checksum =
! run_state::current_pkt->l3_checksummed && ! zeek::detail::ignore_checksums &&
! GetIgnoreChecksumsNets()->Contains(ip->IPHeaderSrcAddr()) && remaining >= len;
auto validate_checksum = ! run_state::current_pkt->l3_checksummed &&
! zeek::detail::ignore_checksums &&
! GetIgnoreChecksumsNets()->Contains(ip->IPHeaderSrcAddr()) &&
remaining >= len;
constexpr auto vxlan_len = 8;
constexpr auto eth_len = 14;
@ -159,10 +160,10 @@ void UDPAnalyzer::DeliverPacket(Connection* c, double t, bool is_orig, int remai
if ( udp_contents )
{
static auto udp_content_ports = id::find_val<TableVal>("udp_content_ports");
static auto udp_content_delivery_ports_orig =
id::find_val<TableVal>("udp_content_delivery_ports_orig");
static auto udp_content_delivery_ports_resp =
id::find_val<TableVal>("udp_content_delivery_ports_resp");
static auto udp_content_delivery_ports_orig = id::find_val<TableVal>(
"udp_content_delivery_ports_orig");
static auto udp_content_delivery_ports_resp = id::find_val<TableVal>(
"udp_content_delivery_ports_resp");
bool do_udp_contents = false;
const auto& sport_val = val_mgr->Port(ntohs(up->uh_sport), TRANSPORT_UDP);
const auto& dport_val = val_mgr->Port(ntohs(up->uh_dport), TRANSPORT_UDP);
@ -172,8 +173,8 @@ void UDPAnalyzer::DeliverPacket(Connection* c, double t, bool is_orig, int remai
do_udp_contents = true;
else
{
uint16_t p =
zeek::detail::udp_content_delivery_ports_use_resp ? c->RespPort() : up->uh_dport;
uint16_t p = zeek::detail::udp_content_delivery_ports_use_resp ? c->RespPort()
: up->uh_dport;
const auto& port_val = zeek::val_mgr->Port(ntohs(p), TRANSPORT_UDP);
if ( is_orig )

View file

@ -193,8 +193,8 @@ template <class T, class C> T ComponentManager<T, C>::GetComponentTag(Val* v) co
template <class T, class C> C* ComponentManager<T, C>::Lookup(const std::string& name) const
{
typename std::map<std::string, C*>::const_iterator i =
components_by_name.find(util::to_upper(name));
typename std::map<std::string, C*>::const_iterator i = components_by_name.find(
util::to_upper(name));
return i != components_by_name.end() ? i->second : 0;
}

View file

@ -135,8 +135,8 @@ public:
return;
block_type excess = extra_bits();
typename std::iterator_traits<ForwardIterator>::difference_type delta =
std::distance(first, last);
typename std::iterator_traits<ForwardIterator>::difference_type delta = std::distance(first,
last);
bits.reserve(Blocks() + delta);

View file

@ -244,8 +244,8 @@ string CPPCompile::GenIncrExpr(const Expr* e, GenType gt, bool is_incr, bool top
// twice, so easiest is to just transform this node
// into the expanded equivalent.
auto op = e->GetOp1();
auto one =
e->GetType()->InternalType() == TYPE_INTERNAL_INT ? val_mgr->Int(1) : val_mgr->Count(1);
auto one = e->GetType()->InternalType() == TYPE_INTERNAL_INT ? val_mgr->Int(1)
: val_mgr->Count(1);
auto one_e = make_intrusive<ConstExpr>(one);
ExprPtr rhs;

View file

@ -187,8 +187,8 @@ void CPPCompile::GenFuncVarInits()
hashes += "}";
auto init =
string("lookup_func__CPP(\"") + fn + "\", " + hashes + ", " + GenTypeName(ft) + ")";
auto init = string("lookup_func__CPP(\"") + fn + "\", " + hashes + ", " + GenTypeName(ft) +
")";
AddInit(fv, const_name, init);
}
@ -226,8 +226,8 @@ void CPPCompile::GenPreInit(const Type* t)
break;
case TYPE_FILE:
pre_init =
string("make_intrusive<FileType>(") + GenTypeName(t->AsFileType()->Yield()) + ")";
pre_init = string("make_intrusive<FileType>(") + GenTypeName(t->AsFileType()->Yield()) +
")";
break;
case TYPE_OPAQUE:

View file

@ -402,8 +402,8 @@ ExprPtr Expr::AssignToTemporary(ExprPtr e, Reducer* c, StmtPtr& red_stmt)
{
auto result_tmp = c->GenTemporaryExpr(GetType(), e);
auto a_e =
make_intrusive<AssignExpr>(result_tmp->MakeLvalue(), e, false, nullptr, nullptr, false);
auto a_e = make_intrusive<AssignExpr>(result_tmp->MakeLvalue(), e, false, nullptr, nullptr,
false);
a_e->SetIsTemp();
a_e->SetOriginal(ThisPtr());

View file

@ -837,8 +837,8 @@ const ZAMStmt ZAMCompiler::LoopOverTable(const ForStmt* f, const NameExpr* val)
if ( value_var )
{
ZOp op =
no_loop_vars ? OP_NEXT_TABLE_ITER_VAL_VAR_NO_VARS_VVV : OP_NEXT_TABLE_ITER_VAL_VAR_VVV;
ZOp op = no_loop_vars ? OP_NEXT_TABLE_ITER_VAL_VAR_NO_VARS_VVV
: OP_NEXT_TABLE_ITER_VAL_VAR_VVV;
z = ZInstI(op, FrameSlot(value_var), iter_slot, 0);
z.CheckIfManaged(value_var->GetType());
z.op_type = OP_VVV_I2_I3;

View file

@ -59,8 +59,8 @@ public:
telemetry::IntCounterFamily total_family = telemetry_mgr->CounterFamily(
"zeek", "total-sessions", {"protocol"}, "Total number of sessions", "1", true);
auto [it, inserted] =
entries.insert({protocol, Protocol{active_family, total_family, protocol}});
auto [it, inserted] = entries.insert(
{protocol, Protocol{active_family, total_family, protocol}});
if ( inserted )
return it;

View file

@ -544,8 +544,8 @@ void zeek::detail::LineBufferedPipe::Emit(const char* msg) const
}
}
auto res =
hook->Invoke(make_intrusive<StringVal>(node_len, node), make_intrusive<StringVal>(msg));
auto res = hook->Invoke(make_intrusive<StringVal>(node_len, node),
make_intrusive<StringVal>(msg));
do_print = res->AsBool();
}

View file

@ -81,8 +81,8 @@ IntHistogramFamily Manager::IntHistoFam(std::string_view prefix, std::string_vie
[&, this](auto xs)
{
auto bounds = caf::span<const int64_t>{ubounds.data(), ubounds.size()};
auto ptr =
deref(pimpl).histogram_family(prefix, name, xs, bounds, helptext, unit, is_sum);
auto ptr = deref(pimpl).histogram_family(prefix, name, xs, bounds, helptext, unit,
is_sum);
return IntHistogramFamily{opaque(ptr)};
});
}
@ -213,8 +213,8 @@ SCENARIO("telemetry managers provide access to counter families")
}
WHEN("retrieving a DblCounter family")
{
auto family =
mgr.CounterFamily<double>("zeek", "runtime", {"query"}, "test", "seconds", true);
auto family = mgr.CounterFamily<double>("zeek", "runtime", {"query"}, "test", "seconds",
true);
THEN("the family object stores the parameters")
{
CHECK_EQ(family.Prefix(), "zeek"sv);
@ -338,8 +338,8 @@ SCENARIO("telemetry managers provide access to gauge families")
}
WHEN("retrieving a DblGauge family")
{
auto family =
mgr.GaugeFamily<double>("zeek", "water-level", {"river"}, "test", "meters");
auto family = mgr.GaugeFamily<double>("zeek", "water-level", {"river"}, "test",
"meters");
THEN("the family object stores the parameters")
{
CHECK_EQ(family.Prefix(), "zeek"sv);
@ -461,8 +461,8 @@ SCENARIO("telemetry managers provide access to histogram families")
WHEN("retrieving an IntHistogram family")
{
int64_t buckets[] = {10, 20};
auto family =
mgr.HistogramFamily("zeek", "payload-size", {"protocol"}, buckets, "test", "bytes");
auto family = mgr.HistogramFamily("zeek", "payload-size", {"protocol"}, buckets, "test",
"bytes");
THEN("the family object stores the parameters")
{
CHECK_EQ(family.Prefix(), "zeek"sv);

View file

@ -890,8 +890,8 @@ double calc_next_rotate(double current, double interval, double base)
double startofday = mktime(&t);
// current < startofday + base + i * interval <= current + interval
double delta_t =
startofday + base + ceil((current - startofday - base) / interval) * interval - current;
double delta_t = startofday + base + ceil((current - startofday - base) / interval) * interval -
current;
return delta_t > 0.0 ? delta_t : interval;
}

View file

@ -371,8 +371,8 @@ static std::vector<std::string> get_script_signature_files()
std::vector<std::string> rval;
// Parse rule files defined on the script level.
char* script_signature_files =
util::copy_string(id::find_val("signature_files")->AsString()->CheckString());
char* script_signature_files = util::copy_string(
id::find_val("signature_files")->AsString()->CheckString());
char* tmp = script_signature_files;
char* s;
@ -921,8 +921,8 @@ 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)};
}

View file

@ -38,8 +38,8 @@ PackageInfo::PackageInfo(const string& arg_name) : Info(), pkg_name(arg_name), r
string PackageInfo::DoReStructuredText(bool roles_only) const
{
string rval =
util::fmt(":doc:`%s </scripts/%s/index>`\n\n", pkg_name.c_str(), pkg_name.c_str());
string rval = util::fmt(":doc:`%s </scripts/%s/index>`\n\n", pkg_name.c_str(),
pkg_name.c_str());
for ( size_t i = 0; i < readme.size(); ++i )
rval += " " + readme[i] + "\n";