mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Add some additional std::moves reported by Coverity
This commit is contained in:
parent
2ce26f1be0
commit
205c72d26f
19 changed files with 27 additions and 26 deletions
|
@ -340,7 +340,7 @@ vector<ParseLocationRec> parse_location_string(const string& s) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
loc_filename = path;
|
loc_filename = std::move(path);
|
||||||
plr.type = PLR_FILE_AND_LINE;
|
plr.type = PLR_FILE_AND_LINE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -708,7 +708,7 @@ void EventTrace::Generate(FILE* f, ValTraceMgr& vtm, const EventTrace* predecess
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Generate(f, vtm, deltas, successor);
|
Generate(f, vtm, deltas, std::move(successor));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ValTraceMgr::TraceEventValues(std::shared_ptr<EventTrace> et, const zeek::Args* args) {
|
void ValTraceMgr::TraceEventValues(std::shared_ptr<EventTrace> et, const zeek::Args* args) {
|
||||||
|
@ -726,7 +726,7 @@ void ValTraceMgr::TraceEventValues(std::shared_ptr<EventTrace> et, const zeek::A
|
||||||
ev_args += ValName(a);
|
ev_args += ValName(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
curr_ev->SetArgs(ev_args);
|
curr_ev->SetArgs(std::move(ev_args));
|
||||||
|
|
||||||
// Now look for any values newly-processed with this event and
|
// Now look for any values newly-processed with this event and
|
||||||
// remember them so we can catch uses of them in future events.
|
// remember them so we can catch uses of them in future events.
|
||||||
|
@ -780,7 +780,7 @@ void ValTraceMgr::AddVal(ValPtr v) {
|
||||||
else {
|
else {
|
||||||
auto vt = std::make_shared<ValTrace>(v);
|
auto vt = std::make_shared<ValTrace>(v);
|
||||||
AssessChange(vt.get(), mapping->second.get());
|
AssessChange(vt.get(), mapping->second.get());
|
||||||
val_map[v.get()] = vt;
|
val_map[v.get()] = std::move(vt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -790,7 +790,7 @@ void ValTraceMgr::NewVal(ValPtr v) {
|
||||||
|
|
||||||
auto vt = std::make_shared<ValTrace>(v);
|
auto vt = std::make_shared<ValTrace>(v);
|
||||||
AssessChange(vt.get(), nullptr);
|
AssessChange(vt.get(), nullptr);
|
||||||
val_map[v.get()] = vt;
|
val_map[v.get()] = std::move(vt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ValTraceMgr::ValUsed(const ValPtr& v) {
|
void ValTraceMgr::ValUsed(const ValPtr& v) {
|
||||||
|
@ -834,7 +834,7 @@ void ValTraceMgr::AssessChange(const ValTrace* vt, const ValTrace* prev_vt) {
|
||||||
previous_deltas.insert(std::move(full_delta));
|
previous_deltas.insert(std::move(full_delta));
|
||||||
|
|
||||||
ValUsed(vp);
|
ValUsed(vp);
|
||||||
curr_ev->AddDelta(vp, rhs, needs_lhs, is_first_def);
|
curr_ev->AddDelta(vp, std::move(rhs), needs_lhs, is_first_def);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& v = vt->GetVal();
|
auto& v = vt->GetVal();
|
||||||
|
@ -1025,7 +1025,7 @@ void EventTraceMgr::StartEvent(const ScriptFunc* ev, const zeek::Args* args) {
|
||||||
auto et = std::make_shared<EventTrace>(ev, nt, events.size());
|
auto et = std::make_shared<EventTrace>(ev, nt, events.size());
|
||||||
events.emplace_back(et);
|
events.emplace_back(et);
|
||||||
|
|
||||||
vtm.TraceEventValues(et, args);
|
vtm.TraceEventValues(std::move(et), args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventTraceMgr::EndEvent(const ScriptFunc* ev, const zeek::Args* args) {
|
void EventTraceMgr::EndEvent(const ScriptFunc* ev, const zeek::Args* args) {
|
||||||
|
|
|
@ -4245,7 +4245,7 @@ LambdaExpr::LambdaExpr(FunctionIngredientsPtr arg_ing, IDPList arg_outer_ids, st
|
||||||
if ( name.empty() )
|
if ( name.empty() )
|
||||||
BuildName();
|
BuildName();
|
||||||
else
|
else
|
||||||
my_name = name;
|
my_name = std::move(name);
|
||||||
|
|
||||||
// Install that in the current scope.
|
// Install that in the current scope.
|
||||||
lambda_id = install_ID(my_name.c_str(), current_module.c_str(), true, false);
|
lambda_id = install_ID(my_name.c_str(), current_module.c_str(), true, false);
|
||||||
|
|
|
@ -616,7 +616,7 @@ Options parse_cmdline(int argc, char** argv) {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
*path = res;
|
*path = std::move(res);
|
||||||
|
|
||||||
if ( (*path)[0] == '/' || (*path)[0] == '~' )
|
if ( (*path)[0] == '/' || (*path)[0] == '~' )
|
||||||
// Now an absolute path
|
// Now an absolute path
|
||||||
|
|
|
@ -136,7 +136,7 @@ bool ScriptCoverageManager::WriteStats() {
|
||||||
auto ft = func->GetType<FuncType>();
|
auto ft = func->GetType<FuncType>();
|
||||||
auto desc = ft->FlavorString() + " " + func->Name() + " BODY";
|
auto desc = ft->FlavorString() + " " + func->Name() + " BODY";
|
||||||
|
|
||||||
TrackUsage(body, desc, body->GetAccessCount());
|
TrackUsage(body, std::move(desc), body->GetAccessCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( const auto& [cond_loc, text, was_true] : cond_instances )
|
for ( const auto& [cond_loc, text, was_true] : cond_instances )
|
||||||
|
|
|
@ -33,7 +33,7 @@ public:
|
||||||
thresholds.emplace_back(lv->Idx(i)->AsCount());
|
thresholds.emplace_back(lv->Idx(i)->AsCount());
|
||||||
std::sort(thresholds.begin(), thresholds.end());
|
std::sort(thresholds.begin(), thresholds.end());
|
||||||
|
|
||||||
zeek::analyzer::conn_size::ConnSize_Analyzer::SetGenericPacketThresholds(thresholds);
|
zeek::analyzer::conn_size::ConnSize_Analyzer::SetGenericPacketThresholds(std::move(thresholds));
|
||||||
}
|
}
|
||||||
} plugin;
|
} plugin;
|
||||||
|
|
||||||
|
|
|
@ -310,7 +310,7 @@ TEST_SUITE_BEGIN("cluster event");
|
||||||
TEST_CASE("add metadata") {
|
TEST_CASE("add metadata") {
|
||||||
auto* handler = zeek::event_registry->Lookup("Supervisor::node_status");
|
auto* handler = zeek::event_registry->Lookup("Supervisor::node_status");
|
||||||
zeek::Args args{zeek::make_intrusive<zeek::StringVal>("TEST"), zeek::val_mgr->Count(42)};
|
zeek::Args args{zeek::make_intrusive<zeek::StringVal>("TEST"), zeek::val_mgr->Count(42)};
|
||||||
zeek::cluster::detail::Event event{handler, args, nullptr};
|
zeek::cluster::detail::Event event{handler, std::move(args), nullptr};
|
||||||
|
|
||||||
auto nts = zeek::id::find_val<zeek::EnumVal>("EventMetadata::NETWORK_TIMESTAMP");
|
auto nts = zeek::id::find_val<zeek::EnumVal>("EventMetadata::NETWORK_TIMESTAMP");
|
||||||
REQUIRE(nts);
|
REQUIRE(nts);
|
||||||
|
|
|
@ -1431,7 +1431,7 @@ int Manager::SendEventStreamEvent(Stream* i, EnumVal* type, const Value* const*
|
||||||
Unref(val);
|
Unref(val);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
SendEvent(stream->event, out_vals);
|
SendEvent(stream->event, std::move(out_vals));
|
||||||
|
|
||||||
return stream->num_fields;
|
return stream->num_fields;
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,7 +175,7 @@ bool Ascii::ReadHeader(bool useCached) {
|
||||||
line = headerline;
|
line = headerline;
|
||||||
|
|
||||||
// construct list of field names.
|
// construct list of field names.
|
||||||
auto ifields = util::split(line, separator[0]);
|
auto ifields = util::split(std::move(line), separator[0]);
|
||||||
|
|
||||||
// printf("Updating fields from description %s\n", line.c_str());
|
// printf("Updating fields from description %s\n", line.c_str());
|
||||||
columnMap.clear();
|
columnMap.clear();
|
||||||
|
|
|
@ -216,7 +216,8 @@ bool Manager::PermitUnknownProtocol(const std::string& analyzer, uint32_t protoc
|
||||||
++count;
|
++count;
|
||||||
|
|
||||||
if ( count == 1 )
|
if ( count == 1 )
|
||||||
zeek::detail::timer_mgr->Add(new UnknownProtocolTimer(run_state::network_time, p, unknown_sampling_duration));
|
zeek::detail::timer_mgr->Add(
|
||||||
|
new UnknownProtocolTimer(run_state::network_time, std::move(p), unknown_sampling_duration));
|
||||||
|
|
||||||
if ( count < unknown_sampling_threshold )
|
if ( count < unknown_sampling_threshold )
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -24,7 +24,7 @@ function register_packet_analyzer%(parent: PacketAnalyzer::Tag, identifier: coun
|
||||||
if ( ! child_analyzer )
|
if ( ! child_analyzer )
|
||||||
return zeek::val_mgr->False();
|
return zeek::val_mgr->False();
|
||||||
|
|
||||||
parent_analyzer->RegisterProtocol(identifier, child_analyzer);
|
parent_analyzer->RegisterProtocol(identifier, std::move(child_analyzer));
|
||||||
return zeek::val_mgr->True();
|
return zeek::val_mgr->True();
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ function try_register_packet_analyzer_by_name%(parent: string, identifier: count
|
||||||
if ( ! child_analyzer )
|
if ( ! child_analyzer )
|
||||||
return zeek::val_mgr->False();
|
return zeek::val_mgr->False();
|
||||||
|
|
||||||
parent_analyzer->RegisterProtocol(identifier, child_analyzer);
|
parent_analyzer->RegisterProtocol(identifier, std::move(child_analyzer));
|
||||||
return zeek::val_mgr->True();
|
return zeek::val_mgr->True();
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ function register_protocol_detection%(parent: PacketAnalyzer::Tag, child: Packet
|
||||||
if ( ! child_analyzer )
|
if ( ! child_analyzer )
|
||||||
return zeek::val_mgr->False();
|
return zeek::val_mgr->False();
|
||||||
|
|
||||||
parent_analyzer->RegisterProtocolDetection(child_analyzer);
|
parent_analyzer->RegisterProtocolDetection(std::move(child_analyzer));
|
||||||
return zeek::val_mgr->True();
|
return zeek::val_mgr->True();
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ bool IPAnalyzer::AnalyzePacket(size_t len, const uint8_t* data, Packet* packet)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we got here, the IP_Hdr is most likely valid and safe to use.
|
// If we got here, the IP_Hdr is most likely valid and safe to use.
|
||||||
packet->ip_hdr = ip_hdr;
|
packet->ip_hdr = std::move(ip_hdr);
|
||||||
|
|
||||||
// If there's an encapsulation stack in this packet, meaning this packet is part of a chain
|
// If there's an encapsulation stack in this packet, meaning this packet is part of a chain
|
||||||
// of tunnels, make sure to store the IP header in the last flow in the stack so it can be
|
// of tunnels, make sure to store the IP header in the last flow in the stack so it can be
|
||||||
|
|
|
@ -204,7 +204,7 @@ bool CPPCompile::AnalyzeFuncBody(FuncInfo& fi, unordered_set<string>& filenames_
|
||||||
else if ( filenames_reported_as_skipped.count(fn) == 0 ) {
|
else if ( filenames_reported_as_skipped.count(fn) == 0 ) {
|
||||||
reporter->Warning("skipping compilation of files in %s due to presence of conditional code",
|
reporter->Warning("skipping compilation of files in %s due to presence of conditional code",
|
||||||
fn.c_str());
|
fn.c_str());
|
||||||
filenames_reported_as_skipped.insert(fn);
|
filenames_reported_as_skipped.emplace(fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
fi.SetSkip(true);
|
fi.SetSkip(true);
|
||||||
|
|
|
@ -659,7 +659,7 @@ void analyze_scripts(bool no_unused_warnings) {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pfs = std::make_shared<ProfileFuncs>(funcs, nullptr, true, true);
|
auto pfs = std::make_shared<ProfileFuncs>(funcs, nullptr, true, true);
|
||||||
analyze_scripts_for_ZAM(pfs);
|
analyze_scripts_for_ZAM(std::move(pfs));
|
||||||
|
|
||||||
if ( reporter->Errors() > 0 )
|
if ( reporter->Errors() > 0 )
|
||||||
reporter->FatalError("Optimized script execution aborted due to errors");
|
reporter->FatalError("Optimized script execution aborted due to errors");
|
||||||
|
|
|
@ -46,7 +46,7 @@ OperationResult SQLite::RunPragma(std::string_view name, std::optional<std::stri
|
||||||
while ( pragma_timeout == 0ms || time_spent < pragma_timeout ) {
|
while ( pragma_timeout == 0ms || time_spent < pragma_timeout ) {
|
||||||
auto res = Step(stmt, value_parser, true);
|
auto res = Step(stmt, value_parser, true);
|
||||||
if ( res.code == ReturnCode::SUCCESS ) {
|
if ( res.code == ReturnCode::SUCCESS ) {
|
||||||
success_res = res;
|
success_res = std::move(res);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if ( res.code == ReturnCode::TIMEOUT ) {
|
else if ( res.code == ReturnCode::TIMEOUT ) {
|
||||||
|
|
|
@ -1531,7 +1531,7 @@ TEST_CASE("util strstrip") {
|
||||||
CHECK(strstrip(s) == "abcd");
|
CHECK(strstrip(s) == "abcd");
|
||||||
|
|
||||||
s = " abcd ";
|
s = " abcd ";
|
||||||
CHECK(strstrip(s) == "abcd");
|
CHECK(strstrip(std::move(s)) == "abcd");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string strstrip(std::string s) {
|
std::string strstrip(std::string s) {
|
||||||
|
|
|
@ -592,7 +592,7 @@ std::vector<T> split(T s, const T& delim) {
|
||||||
*/
|
*/
|
||||||
template<typename T, typename U = typename T::value_type*>
|
template<typename T, typename U = typename T::value_type*>
|
||||||
std::vector<T> split(T s, U delim) {
|
std::vector<T> split(T s, U delim) {
|
||||||
return split(s, T{delim});
|
return split(std::move(s), std::move(T{delim}));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -605,7 +605,7 @@ SetupResult setup(int argc, char** argv, Options* zopts) {
|
||||||
|
|
||||||
if ( options.supervisor_mode ) {
|
if ( options.supervisor_mode ) {
|
||||||
Supervisor::Config cfg = {};
|
Supervisor::Config cfg = {};
|
||||||
cfg.zeek_exe_path = zeek_exe_path;
|
cfg.zeek_exe_path = std::move(zeek_exe_path);
|
||||||
options.filter_supervisor_options();
|
options.filter_supervisor_options();
|
||||||
supervisor_mgr = new Supervisor(std::move(cfg), std::move(*stem));
|
supervisor_mgr = new Supervisor(std::move(cfg), std::move(*stem));
|
||||||
}
|
}
|
||||||
|
|
|
@ -483,7 +483,7 @@ void ScriptTarget::DoGenerate() const {
|
||||||
if ( zeek::detail::zeekygen_mgr->IsUpToDate(target_filename, dep) )
|
if ( zeek::detail::zeekygen_mgr->IsUpToDate(target_filename, dep) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
TargetFile file(target_filename);
|
TargetFile file(std::move(target_filename));
|
||||||
|
|
||||||
fprintf(file.f, "%s\n", d->ReStructuredText().c_str());
|
fprintf(file.f, "%s\n", d->ReStructuredText().c_str());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue