diff --git a/.clang-format b/.clang-format index 79910187b2..a105b7df33 100644 --- a/.clang-format +++ b/.clang-format @@ -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: diff --git a/src/DNS_Mgr.cc b/src/DNS_Mgr.cc index 408fda9f10..827f17ecfe 100644 --- a/src/DNS_Mgr.cc +++ b/src/DNS_Mgr.cc @@ -1167,16 +1167,16 @@ 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; + 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; } if ( ! success ) diff --git a/src/Dict.cc b/src/Dict.cc index 3be737328a..62e4dd0d87 100644 --- a/src/Dict.cc +++ b/src/Dict.cc @@ -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 diff --git a/src/Discard.cc b/src/Discard.cc index ba36754451..6f3d8b94ca 100644 --- a/src/Discard.cc +++ b/src/Discard.cc @@ -72,8 +72,8 @@ bool Discarder::NextPacket(const std::unique_ptr& 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 diff --git a/src/EventHandler.cc b/src/EventHandler.cc index 532dcc78e5..1196ae8ec8 100644 --- a/src/EventHandler.cc +++ b/src/EventHandler.cc @@ -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; diff --git a/src/Expr.cc b/src/Expr.cc index d12c023828..088c42f778 100644 --- a/src/Expr.cc +++ b/src/Expr.cc @@ -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(res); } @@ -2860,9 +2860,9 @@ 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", - type_name(op1->GetType()->Tag())); + 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& 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(field_type)) ) + if ( auto new_val = rhs->AsRecordVal()->CoerceTo( + cast_intrusive(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& 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(field_type)); + auto tmp = def_val->AsRecordVal()->CoerceTo( + cast_intrusive(field_type)); if ( tmp ) def_val = std::move(tmp); @@ -4567,9 +4567,9 @@ LambdaExpr::LambdaExpr(std::unique_ptr 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(ingredients->id, ingredients->body, ingredients->inits, - ingredients->frame_size, ingredients->priority); + auto dummy_func = make_intrusive(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(record, field_name); - auto fe_rhs = - make_intrusive(IntrusivePtr{NewRef{}, init}, field_name); + auto fe_rhs = make_intrusive(IntrusivePtr{NewRef{}, init}, + field_name); Append(get_assign_expr(std::move(fe_lhs), std::move(fe_rhs), is_init)); } } diff --git a/src/IP.cc b/src/IP.cc index ba104277c4..04ac1b6676 100644 --- a/src/IP.cc +++ b/src/IP.cc @@ -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"); diff --git a/src/NetVar.cc b/src/NetVar.cc index 6f3acb2ad1..e9084f3085 100644 --- a/src/NetVar.cc +++ b/src/NetVar.cc @@ -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(); diff --git a/src/PrefixTable.cc b/src/PrefixTable.cc index 9c79db9c7d..ebb655182c 100644 --- a/src/PrefixTable.cc +++ b/src/PrefixTable.cc @@ -94,8 +94,8 @@ std::list> 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; diff --git a/src/Reporter.cc b/src/Reporter.cc index 33ff1be1ba..3bbb121208 100644 --- a/src/Reporter.cc +++ b/src/Reporter.cc @@ -600,11 +600,11 @@ 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, - HookReporter(prefix, event, conn, addl, location, - locs.first, locs.second, time, buffer), - true); + raise_event = PLUGIN_HOOK_WITH_RESULT(HOOK_REPORTER, + HookReporter(prefix, event, conn, addl, location, + locs.first, locs.second, time, + buffer), + true); } else raise_event = PLUGIN_HOOK_WITH_RESULT( diff --git a/src/RuleMatcher.cc b/src/RuleMatcher.cc index 9e00e3aa70..4cf0c15214 100644 --- a/src/RuleMatcher.cc +++ b/src/RuleMatcher.cc @@ -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(data), min(40, static_cast(len))); + const char* s = util::fmt_bytes(reinterpret_cast(data), + min(40, static_cast(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); } } diff --git a/src/RunState.cc b/src/RunState.cc index 96bb7a5b2a..9852fc0744 100644 --- a/src/RunState.cc +++ b/src/RunState.cc @@ -386,9 +386,10 @@ 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 - : 0.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); } diff --git a/src/Scope.cc b/src/Scope.cc index ce8438bb44..896d84707d 100644 --- a/src/Scope.cc +++ b/src/Scope.cc @@ -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 ) { diff --git a/src/Stats.cc b/src/Stats.cc index cea561ee05..a428b934d7 100644 --- a/src/Stats.cc +++ b/src/Stats.cc @@ -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; diff --git a/src/Stmt.cc b/src/Stmt.cc index 257b2fd7a1..87c47d0adc 100644 --- a/src/Stmt.cc +++ b/src/Stmt.cc @@ -345,8 +345,8 @@ void do_print_stmt(const std::vector& vals) ++offset; } - static auto print_log_type = - static_cast(id::find_val("Log::print_to_log")->AsEnum()); + static auto print_log_type = static_cast( + id::find_val("Log::print_to_log")->AsEnum()); switch ( print_log_type ) { diff --git a/src/Timer.cc b/src/Timer.cc index 0bc71e072c..49b9624a43 100644 --- a/src/Timer.cc +++ b/src/Timer.cc @@ -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() diff --git a/src/Type.cc b/src/Type.cc index 7e04f80f74..d35378922b 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -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'" - " ('%s' enum type ID is invalid)", - t1->GetName().data(), t2->GetName().data(), t1->GetName().data()); + 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->Error(msg.data(), t2); return nullptr; } diff --git a/src/Val.cc b/src/Val.cc index 3fa01f64c1..305a638d83 100644 --- a/src/Val.cc +++ b/src/Val.cc @@ -1839,8 +1839,8 @@ ValPtr TableVal::Default(const ValPtr& index) record_promotion_compatible(dtype->AsRecordType(), ytype->AsRecordType()) ) { auto rt = cast_intrusive(ytype); - auto coerce = - make_intrusive(def_attr->GetExpr(), std::move(rt)); + auto coerce = make_intrusive(def_attr->GetExpr(), + std::move(rt)); def_val = coerce->Eval(nullptr); } diff --git a/src/Val.h b/src/Val.h index 402a00d266..6ece8c90de 100644 --- a/src/Val.h +++ b/src/Val.h @@ -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(); diff --git a/src/analyzer/protocol/dns/DNS.cc b/src/analyzer/protocol/dns/DNS.cc index e34d0aa495..fe5424c00e 100644 --- a/src/analyzer/protocol/dns/DNS.cc +++ b/src/analyzer/protocol/dns/DNS.cc @@ -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(), diff --git a/src/analyzer/protocol/http/HTTP.cc b/src/analyzer/protocol/http/HTTP.cc index ff52cb5dab..e8c7b35a07 100644 --- a/src/analyzer/protocol/http/HTTP.cc +++ b/src/analyzer/protocol/http/HTTP.cc @@ -330,10 +330,10 @@ 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(), - http_message->MyHTTP_Analyzer()->Conn(), http_message->IsOrig(), - precomputed_file_id); + precomputed_file_id = file_mgr->SetSize( + content_length, http_message->MyHTTP_Analyzer()->GetAnalyzerTag(), + http_message->MyHTTP_Analyzer()->Conn(), http_message->IsOrig(), + precomputed_file_id); precomputed_file_id = file_mgr->DataIn(reinterpret_cast(buf), len, http_message->MyHTTP_Analyzer()->GetAnalyzerTag(), @@ -894,8 +894,8 @@ void HTTP_Analyzer::DeliverStream(int len, const u_char* data, bool is_orig) const char* line = reinterpret_cast(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) ) { diff --git a/src/analyzer/protocol/mime/MIME.cc b/src/analyzer/protocol/mime/MIME.cc index 5762803a49..00517beac7 100644 --- a/src/analyzer/protocol/mime/MIME.cc +++ b/src/analyzer/protocol/mime/MIME.cc @@ -1461,9 +1461,9 @@ void MIME_Mail::SubmitData(int len, const char* buf) make_intrusive(data_len, data)); } - cur_entity_id = - file_mgr->DataIn(reinterpret_cast(buf), len, analyzer->GetAnalyzerTag(), - analyzer->Conn(), is_orig, cur_entity_id); + cur_entity_id = file_mgr->DataIn(reinterpret_cast(buf), len, + analyzer->GetAnalyzerTag(), analyzer->Conn(), is_orig, + cur_entity_id); cur_entity_len += len; buffer_start = (buf + len) - (char*)data_buffer->Bytes(); diff --git a/src/analyzer/protocol/pia/PIA.cc b/src/analyzer/protocol/pia/PIA.cc index 93a4cbc677..a4314294c1 100644 --- a/src/analyzer/protocol/pia/PIA.cc +++ b/src/analyzer/protocol/pia/PIA.cc @@ -382,11 +382,11 @@ void PIA_TCP::ActivateAnalyzer(analyzer::Tag tag, const zeek::detail::Rule* rule auto* tcp = static_cast(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; diff --git a/src/analyzer/protocol/pop3/POP3.cc b/src/analyzer/protocol/pop3/POP3.cc index 4054c3ffb2..3d13701933 100644 --- a/src/analyzer/protocol/pop3/POP3.cc +++ b/src/analyzer/protocol/pop3/POP3.cc @@ -585,10 +585,10 @@ void POP3_Analyzer::ProcessReply(int length, const char* line) if ( multiLine == true ) { - bool terminator = - line[0] == '.' && - (length == 1 || (length > 1 && (line[1] == '\n' || - (length > 2 && line[1] == '\r' && line[2] == '\n')))); + bool terminator = line[0] == '.' && + (length == 1 || + (length > 1 && (line[1] == '\n' || + (length > 2 && line[1] == '\r' && line[2] == '\n')))); if ( terminator ) { diff --git a/src/analyzer/protocol/rpc/RPC.cc b/src/analyzer/protocol/rpc/RPC.cc index f8bef3a887..f169ea7854 100644 --- a/src/analyzer/protocol/rpc/RPC.cc +++ b/src/analyzer/protocol/rpc/RPC.cc @@ -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 ) { diff --git a/src/analyzer/protocol/tcp/TCP_Reassembler.cc b/src/analyzer/protocol/tcp/TCP_Reassembler.cc index fb1323a2c6..7c521f7bfd 100644 --- a/src/analyzer/protocol/tcp/TCP_Reassembler.cc +++ b/src/analyzer/protocol/tcp/TCP_Reassembler.cc @@ -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("tcp_content_delivery_ports_orig"); - static auto tcp_content_delivery_ports_resp = - id::find_val("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( + "tcp_content_delivery_ports_orig"); + static auto tcp_content_delivery_ports_resp = id::find_val( + "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,10 +519,10 @@ 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 && - endp->peer->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); diff --git a/src/broker/Data.cc b/src/broker/Data.cc index 8045edb6b7..80651fc822 100644 --- a/src/broker/Data.cc +++ b/src/broker/Data.cc @@ -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 ) diff --git a/src/broker/Manager.cc b/src/broker/Manager.cc index 65a70c4316..d4a8445c37 100644 --- a/src/broker/Manager.cc +++ b/src/broker/Manager.cc @@ -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(attr->GetExpr()->Eval(nullptr)->AsEnum()); + auto e = static_cast( + attr->GetExpr()->Eval(nullptr)->AsEnum()); auto storename = std::string("___sync_store_") + global.first; id->GetVal()->AsTableVal()->SetBrokerStore(storename); AddForwardedStore(storename, cast_intrusive(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(path)); + auto v = log_topic_func->Invoke(IntrusivePtr{NewRef{}, stream}, + make_intrusive(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 ) { diff --git a/src/file_analysis/analyzer/x509/X509.cc b/src/file_analysis/analyzer/x509/X509.cc index 20e43514eb..2851c241ce 100644 --- a/src/file_analysis/analyzer/x509/X509.cc +++ b/src/file_analysis/analyzer/x509/X509.cc @@ -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(BifType::Record::X509::BasicConstraints); + auto pBasicConstraint = make_intrusive( + BifType::Record::X509::BasicConstraints); pBasicConstraint->Assign(0, constr->ca); if ( constr->pathlen ) diff --git a/src/file_analysis/analyzer/x509/X509Common.cc b/src/file_analysis/analyzer/x509/X509Common.cc index afbedbf36b..57c74965a7 100644 --- a/src/file_analysis/analyzer/x509/X509Common.cc +++ b/src/file_analysis/analyzer/x509/X509Common.cc @@ -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( diff --git a/src/input/Manager.cc b/src/input/Manager.cc index 2869bfb9d2..d8c389cef6 100644 --- a/src/input/Manager.cc +++ b/src/input/Manager.cc @@ -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(); diff --git a/src/input/readers/ascii/Ascii.cc b/src/input/readers/ascii/Ascii.cc index 2a001f04fa..0c78dc4eb1 100644 --- a/src/input/readers/ascii/Ascii.cc +++ b/src/input/readers/ascii/Ascii.cc @@ -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; diff --git a/src/input/readers/config/Config.cc b/src/input/readers/config/Config.cc index 011498f059..fb5201fcf0 100644 --- a/src/input/readers/config/Config.cc +++ b/src/input/readers/config/Config.cc @@ -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(new threading::formatter::Ascii(this, sep_info)); + formatter = std::unique_ptr( + new threading::formatter::Ascii(this, sep_info)); return DoUpdate(); } diff --git a/src/input/readers/raw/Raw.cc b/src/input/readers/raw/Raw.cc index 1d938f6be4..463f4d6a2d 100644 --- a/src/input/readers/raw/Raw.cc +++ b/src/input/readers/raw/Raw.cc @@ -256,8 +256,8 @@ bool Raw::Execute() if ( use_stderr ) { - stderrfile = - std::unique_ptr(fdopen(pipes[stderr_in], "r"), fclose); + stderrfile = std::unique_ptr(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 newbuf = - std::unique_ptr(new char[block_size * repeats]); + std::unique_ptr newbuf = std::unique_ptr( + new char[block_size * repeats]); memcpy(newbuf.get(), buf.get(), block_size * (repeats - 1)); buf = std::move(newbuf); offset = block_size * (repeats - 1); diff --git a/src/logging/Manager.cc b/src/logging/Manager.cc index 8cd1adc099..a50c1d8952 100644 --- a/src/logging/Manager.cc +++ b/src/logging/Manager.cc @@ -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); diff --git a/src/logging/WriterBackend.cc b/src/logging/WriterBackend.cc index 54246cbd96..33c8d5e23c 100644 --- a/src/logging/WriterBackend.cc +++ b/src/logging/WriterBackend.cc @@ -239,9 +239,9 @@ 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, - vals[j][i]->type, fields[i]->type); + 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 DisableFrontend(); diff --git a/src/logging/WriterBackend.h b/src/logging/WriterBackend.h index 10035c1cbb..b3397c49ca 100644 --- a/src/logging/WriterBackend.h +++ b/src/logging/WriterBackend.h @@ -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; diff --git a/src/logging/writers/ascii/Ascii.cc b/src/logging/writers/ascii/Ascii.cc index c0c7758326..a53464f925 100644 --- a/src/logging/writers/ascii/Ascii.cc +++ b/src/logging/writers/ascii/Ascii.cc @@ -105,8 +105,8 @@ static std::optional 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 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 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 ) { diff --git a/src/packet_analysis/protocol/icmp/ICMP.cc b/src/packet_analysis/protocol/icmp/ICMP.cc index 4913859b18..18a89c16fb 100644 --- a/src/packet_analysis/protocol/icmp/ICMP.cc +++ b/src/packet_analysis/protocol/icmp/ICMP.cc @@ -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; } diff --git a/src/packet_analysis/protocol/ip/IPBasedAnalyzer.cc b/src/packet_analysis/protocol/ip/IPBasedAnalyzer.cc index 193fb6958c..785d914498 100644 --- a/src/packet_analysis/protocol/ip/IPBasedAnalyzer.cc +++ b/src/packet_analysis/protocol/ip/IPBasedAnalyzer.cc @@ -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("ignore_checksums_nets"); + IPBasedAnalyzer::ignore_checksums_nets_table = zeek::id::find_val( + "ignore_checksums_nets"); return IPBasedAnalyzer::ignore_checksums_nets_table; } diff --git a/src/packet_analysis/protocol/tcp/TCPSessionAdapter.cc b/src/packet_analysis/protocol/tcp/TCPSessionAdapter.cc index 80c1e68235..a563650b74 100644 --- a/src/packet_analysis/protocol/tcp/TCPSessionAdapter.cc +++ b/src/packet_analysis/protocol/tcp/TCPSessionAdapter.cc @@ -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("tcp_content_delivery_ports_orig"); - static auto tcp_content_delivery_ports_resp = - id::find_val("tcp_content_delivery_ports_resp"); + static auto tcp_content_delivery_ports_orig = id::find_val( + "tcp_content_delivery_ports_orig"); + static auto tcp_content_delivery_ports_resp = id::find_val( + "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); diff --git a/src/packet_analysis/protocol/udp/UDP.cc b/src/packet_analysis/protocol/udp/UDP.cc index 50c9f32a2b..374f69c50c 100644 --- a/src/packet_analysis/protocol/udp/UDP.cc +++ b/src/packet_analysis/protocol/udp/UDP.cc @@ -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("udp_content_ports"); - static auto udp_content_delivery_ports_orig = - id::find_val("udp_content_delivery_ports_orig"); - static auto udp_content_delivery_ports_resp = - id::find_val("udp_content_delivery_ports_resp"); + static auto udp_content_delivery_ports_orig = id::find_val( + "udp_content_delivery_ports_orig"); + static auto udp_content_delivery_ports_resp = id::find_val( + "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 ) diff --git a/src/plugin/ComponentManager.h b/src/plugin/ComponentManager.h index a59326077c..a1bb6d80be 100644 --- a/src/plugin/ComponentManager.h +++ b/src/plugin/ComponentManager.h @@ -193,8 +193,8 @@ template T ComponentManager::GetComponentTag(Val* v) co template C* ComponentManager::Lookup(const std::string& name) const { - typename std::map::const_iterator i = - components_by_name.find(util::to_upper(name)); + typename std::map::const_iterator i = components_by_name.find( + util::to_upper(name)); return i != components_by_name.end() ? i->second : 0; } diff --git a/src/probabilistic/BitVector.h b/src/probabilistic/BitVector.h index ca4f0f238e..3f4c94e9e9 100644 --- a/src/probabilistic/BitVector.h +++ b/src/probabilistic/BitVector.h @@ -135,8 +135,8 @@ public: return; block_type excess = extra_bits(); - typename std::iterator_traits::difference_type delta = - std::distance(first, last); + typename std::iterator_traits::difference_type delta = std::distance(first, + last); bits.reserve(Blocks() + delta); diff --git a/src/script_opt/CPP/Exprs.cc b/src/script_opt/CPP/Exprs.cc index 0ac70abc14..c2a9cc2753 100644 --- a/src/script_opt/CPP/Exprs.cc +++ b/src/script_opt/CPP/Exprs.cc @@ -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(one); ExprPtr rhs; diff --git a/src/script_opt/CPP/Inits.cc b/src/script_opt/CPP/Inits.cc index d6f41da620..48f3dd1cc1 100644 --- a/src/script_opt/CPP/Inits.cc +++ b/src/script_opt/CPP/Inits.cc @@ -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(") + GenTypeName(t->AsFileType()->Yield()) + ")"; + pre_init = string("make_intrusive(") + GenTypeName(t->AsFileType()->Yield()) + + ")"; break; case TYPE_OPAQUE: diff --git a/src/script_opt/Expr.cc b/src/script_opt/Expr.cc index c87ef21b31..75e7fb74e7 100644 --- a/src/script_opt/Expr.cc +++ b/src/script_opt/Expr.cc @@ -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(result_tmp->MakeLvalue(), e, false, nullptr, nullptr, false); + auto a_e = make_intrusive(result_tmp->MakeLvalue(), e, false, nullptr, nullptr, + false); a_e->SetIsTemp(); a_e->SetOriginal(ThisPtr()); diff --git a/src/script_opt/ZAM/Stmt.cc b/src/script_opt/ZAM/Stmt.cc index 01fbc3bcf7..84ca6598aa 100644 --- a/src/script_opt/ZAM/Stmt.cc +++ b/src/script_opt/ZAM/Stmt.cc @@ -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; diff --git a/src/session/Manager.cc b/src/session/Manager.cc index 47f5b7d239..2fdb05c4e4 100644 --- a/src/session/Manager.cc +++ b/src/session/Manager.cc @@ -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; diff --git a/src/supervisor/Supervisor.cc b/src/supervisor/Supervisor.cc index ab905f4ade..4b7d67e9a4 100644 --- a/src/supervisor/Supervisor.cc +++ b/src/supervisor/Supervisor.cc @@ -544,8 +544,8 @@ void zeek::detail::LineBufferedPipe::Emit(const char* msg) const } } - auto res = - hook->Invoke(make_intrusive(node_len, node), make_intrusive(msg)); + auto res = hook->Invoke(make_intrusive(node_len, node), + make_intrusive(msg)); do_print = res->AsBool(); } diff --git a/src/telemetry/Manager.cc b/src/telemetry/Manager.cc index 7a8da4a25d..d7eac6904e 100644 --- a/src/telemetry/Manager.cc +++ b/src/telemetry/Manager.cc @@ -81,8 +81,8 @@ IntHistogramFamily Manager::IntHistoFam(std::string_view prefix, std::string_vie [&, this](auto xs) { auto bounds = caf::span{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("zeek", "runtime", {"query"}, "test", "seconds", true); + auto family = mgr.CounterFamily("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("zeek", "water-level", {"river"}, "test", "meters"); + auto family = mgr.GaugeFamily("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); diff --git a/src/util.cc b/src/util.cc index 14241481e6..cfa612a864 100644 --- a/src/util.cc +++ b/src/util.cc @@ -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; } diff --git a/src/zeek-setup.cc b/src/zeek-setup.cc index 07671948b1..dad543c282 100644 --- a/src/zeek-setup.cc +++ b/src/zeek-setup.cc @@ -371,8 +371,8 @@ static std::vector get_script_signature_files() std::vector 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)}; } diff --git a/src/zeekygen/PackageInfo.cc b/src/zeekygen/PackageInfo.cc index bbdbb85c5d..f7ef9b1734 100644 --- a/src/zeekygen/PackageInfo.cc +++ b/src/zeekygen/PackageInfo.cc @@ -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 `\n\n", pkg_name.c_str(), pkg_name.c_str()); + string rval = util::fmt(":doc:`%s `\n\n", pkg_name.c_str(), + pkg_name.c_str()); for ( size_t i = 0; i < readme.size(); ++i ) rval += " " + readme[i] + "\n";