Fix a swath of AUTO_CAUSES_COPY issues reported by Coverity

This commit is contained in:
Tim Wojtulewicz 2022-08-15 09:45:46 -07:00
parent f631551ffb
commit 2abc82722f
7 changed files with 9 additions and 9 deletions

View file

@ -883,7 +883,7 @@ bool SwitchStmt::AddCaseLabelValueMapping(const Val* v, int idx)
bool SwitchStmt::AddCaseLabelTypeMapping(ID* t, int idx)
{
for ( auto i : case_label_type_list )
for ( const auto& i : case_label_type_list )
{
if ( same_type(i.first->GetType(), t->GetType()) )
return false;
@ -918,7 +918,7 @@ std::pair<int, ID*> SwitchStmt::FindCaseLabelMatch(const Val* v) const
}
// Find matching type cases.
for ( auto i : case_label_type_list )
for ( const auto& i : case_label_type_list )
{
auto id = i.first;
const auto& type = id->GetType();

View file

@ -161,7 +161,7 @@ zeek::StringValPtr asn1_oid_to_val(const ASN1Encoding* oid)
// Underflow.
return zeek::val_mgr->EmptyString();
for ( auto subidentifier : subidentifiers )
for ( const auto& subidentifier : subidentifiers )
{
uint64 value = 0;

View file

@ -120,7 +120,7 @@ bool WriterBackend::WriterInfo::FromBroker(broker::data d)
rotation_interval = *brotation_interval;
network_time = *bnetwork_time;
for ( auto i : *bconfig )
for ( const auto& i : *bconfig )
{
auto k = broker::get_if<std::string>(&i.first);
auto v = broker::get_if<std::string>(&i.second);

View file

@ -314,7 +314,7 @@ void CPPCompile::GenEpilog()
GenCPPDynStmt();
NL();
for ( auto gi : all_global_info )
for ( const auto& gi : all_global_info )
gi->GenerateInitializers(this);
NL();
@ -449,7 +449,7 @@ void CPPCompile::GenFinishInit()
max_cohort = std::max(max_cohort, gi->MaxCohort());
for ( auto c = 0; c <= max_cohort; ++c )
for ( auto gi : all_global_info )
for ( const auto& gi : all_global_info )
if ( gi->CohortSize(c) > 0 )
Emit("%s.InitializeCohort(&im, %s);", gi->InitializersName(), Fmt(c));

View file

@ -895,7 +895,7 @@ StmtPtr InitStmt::Duplicate()
// Need to duplicate the initializer list since later reductions
// can modify it in place.
std::vector<IDPtr> new_inits;
for ( auto id : inits )
for ( const auto& id : inits )
new_inits.push_back(id);
return SetSucc(new InitStmt(new_inits));

View file

@ -83,7 +83,7 @@ bool UseDefs::RemoveUnused(int iter)
const auto& inits = init->Inits();
std::vector<IDPtr> used_ids;
for ( auto id : inits )
for ( const auto& id : inits )
if ( is_atomic_type(id->GetType()) || ! CheckIfUnused(s, id.get(), false) )
used_ids.emplace_back(id);

View file

@ -370,7 +370,7 @@ void ZAMCompiler::Dump()
if ( remapped_frame )
printf("Original frame for %s:\n", func->Name());
for ( auto elem : frame_layout1 )
for ( const auto& elem : frame_layout1 )
printf("frame[%d] = %s\n", elem.second, elem.first->Name());
if ( remapped_frame )