Fix a bunch of variable shadowing issues from LGTM

This commit is contained in:
Tim Wojtulewicz 2022-11-02 15:54:51 -07:00
parent f8eb2d9241
commit e8dbfc1cb0
10 changed files with 28 additions and 27 deletions

View file

@ -388,10 +388,10 @@ void Attributes::CheckAttr(Attr* a)
int num_expires = 0; int num_expires = 0;
for ( const auto& a : attrs ) for ( const auto& at : attrs )
{ {
if ( a->Tag() == ATTR_EXPIRE_READ || a->Tag() == ATTR_EXPIRE_WRITE || if ( at->Tag() == ATTR_EXPIRE_READ || at->Tag() == ATTR_EXPIRE_WRITE ||
a->Tag() == ATTR_EXPIRE_CREATE ) at->Tag() == ATTR_EXPIRE_CREATE )
num_expires++; num_expires++;
} }

View file

@ -333,9 +333,10 @@ bool CompositeHash::RecoverOneVal(const HashKey& hk, Type* t, ValPtr* pval, bool
{ {
ValPtr v; ValPtr v;
Attributes* a = rt->FieldDecl(i)->attrs.get(); Attributes* a = rt->FieldDecl(i)->attrs.get();
bool optional = (a && a->Find(ATTR_OPTIONAL)); bool is_optional = (a && a->Find(ATTR_OPTIONAL));
if ( ! RecoverOneVal(hk, rt->GetFieldType(i).get(), &v, optional, false) ) if ( ! RecoverOneVal(hk, rt->GetFieldType(i).get(), &v, is_optional,
false) )
{ {
*pval = nullptr; *pval = nullptr;
return false; return false;
@ -345,7 +346,7 @@ bool CompositeHash::RecoverOneVal(const HashKey& hk, Type* t, ValPtr* pval, bool
// abort() and broken the call tree that clang-tidy is relying on to // abort() and broken the call tree that clang-tidy is relying on to
// get the error described. // get the error described.
// NOLINTNEXTLINE(clang-analyzer-core.uninitialized.Branch) // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.Branch)
if ( ! (v || optional) ) if ( ! (v || is_optional) )
{ {
reporter->InternalError( reporter->InternalError(
"didn't recover expected number of fields from HashKey"); "didn't recover expected number of fields from HashKey");

View file

@ -256,8 +256,8 @@ ExprListStmt::ExprListStmt(StmtTag t, ListExprPtr arg_l) : Stmt(t), l(std::move(
const ExprPList& e = l->Exprs(); const ExprPList& e = l->Exprs();
for ( const auto& expr : e ) for ( const auto& expr : e )
{ {
const auto& t = expr->GetType(); const auto& et = expr->GetType();
if ( ! t || t->Tag() == TYPE_VOID ) if ( ! et || et->Tag() == TYPE_VOID )
Error("value of type void illegal"); Error("value of type void illegal");
} }

View file

@ -1396,13 +1396,13 @@ TableVal::TableVal(TableTypePtr t, detail::AttributesPtr a) : Val(t)
if ( ! run_state::is_parsing ) if ( ! run_state::is_parsing )
return; return;
for ( const auto& t : table_type->GetIndexTypes() ) for ( const auto& it : table_type->GetIndexTypes() )
{ {
std::set<RecordType*> found; std::set<RecordType*> found;
std::set<const RecordType*> analyzed_records; std::set<const RecordType*> analyzed_records;
// TODO: this likely doesn't have to be repeated for each new TableVal, // TODO: this likely doesn't have to be repeated for each new TableVal,
// can remember the resulting dependencies per TableType // can remember the resulting dependencies per TableType
find_nested_record_types(t, &found, &analyzed_records); find_nested_record_types(it, &found, &analyzed_records);
for ( auto rt : found ) for ( auto rt : found )
parse_time_table_record_dependencies[rt].emplace_back(NewRef{}, this); parse_time_table_record_dependencies[rt].emplace_back(NewRef{}, this);

View file

@ -94,11 +94,11 @@ bool PortmapperInterp::RPC_BuildReply(RPC_CallInfo* c, BifEnum::rpc_status statu
case PMAPPROC_SET: case PMAPPROC_SET:
if ( success ) if ( success )
{ {
uint32_t status = extract_XDR_uint32(buf, n); uint32_t proc_status = extract_XDR_uint32(buf, n);
if ( ! buf ) if ( ! buf )
return false; return false;
reply = val_mgr->Bool(status); reply = val_mgr->Bool(proc_status);
event = pm_request_set; event = pm_request_set;
} }
else else
@ -109,11 +109,11 @@ bool PortmapperInterp::RPC_BuildReply(RPC_CallInfo* c, BifEnum::rpc_status statu
case PMAPPROC_UNSET: case PMAPPROC_UNSET:
if ( success ) if ( success )
{ {
uint32_t status = extract_XDR_uint32(buf, n); uint32_t proc_status = extract_XDR_uint32(buf, n);
if ( ! buf ) if ( ! buf )
return false; return false;
reply = val_mgr->Bool(status); reply = val_mgr->Bool(proc_status);
event = pm_request_unset; event = pm_request_unset;
} }
else else

View file

@ -207,9 +207,9 @@ Value* SQLite::EntryToVal(sqlite3_stmt* st, const threading::Field* field, int p
{ {
const char* text = (const char*)sqlite3_column_text(st, pos); const char* text = (const char*)sqlite3_column_text(st, pos);
std::string s(text, sqlite3_column_bytes(st, pos)); std::string s(text, sqlite3_column_bytes(st, pos));
int pos = s.find('/'); size_t slash_pos = s.find('/');
int width = atoi(s.substr(pos + 1).c_str()); int width = atoi(s.substr(slash_pos + 1).c_str());
std::string addr = s.substr(0, pos); std::string addr = s.substr(0, slash_pos);
val->val.subnet_val.prefix = io->ParseAddr(addr); val->val.subnet_val.prefix = io->ParseAddr(addr);
val->val.subnet_val.length = width; val->val.subnet_val.length = width;

View file

@ -1209,9 +1209,9 @@ WriterFrontend* Manager::CreateWriter(EnumVal* id, EnumVal* writer, WriterBacken
if ( ! found_filter_match ) if ( ! found_filter_match )
{ {
const auto& id = zeek::detail::global_scope()->Find("Log::default_rotation_interval"); const auto& interval = zeek::detail::global_scope()->Find("Log::default_rotation_interval");
assert(id); assert(id);
winfo->interval = id->GetVal()->AsInterval(); winfo->interval = interval->GetVal()->AsInterval();
if ( winfo->info->post_proc_func && strlen(winfo->info->post_proc_func) ) if ( winfo->info->post_proc_func && strlen(winfo->info->post_proc_func) )
{ {

View file

@ -1005,8 +1005,8 @@ StmtPtr CatchReturnStmt::DoReduce(Reducer* c)
if ( ret_e_dup->Tag() == EXPR_CONST ) if ( ret_e_dup->Tag() == EXPR_CONST )
{ {
auto c = ret_e_dup->AsConstExpr(); auto ce = ret_e_dup->AsConstExpr();
rv_dup->AsNameExpr()->Id()->GetOptInfo()->SetConst(c); rv_dup->AsNameExpr()->Id()->GetOptInfo()->SetConst(ce);
} }
return assign_stmt; return assign_stmt;

View file

@ -480,13 +480,13 @@ const ZAMStmt ZAMCompiler::ValueSwitch(const SwitchStmt* sw, const NameExpr* v,
std::vector<InstLabel> case_start; std::vector<InstLabel> case_start;
PushFallThroughs(); PushFallThroughs();
for ( auto c : *cases ) for ( auto sw_case : *cases )
{ {
auto start = GoToTargetBeyond(body_end); auto start = GoToTargetBeyond(body_end);
ResolveFallThroughs(start); ResolveFallThroughs(start);
case_start.push_back(start); case_start.push_back(start);
PushFallThroughs(); PushFallThroughs();
body_end = CompileStmt(c->Body()); body_end = CompileStmt(sw_case->Body());
} }
auto sw_end = GoToTargetBeyond(body_end); auto sw_end = GoToTargetBeyond(body_end);

View file

@ -1173,8 +1173,8 @@ std::optional<SupervisorStemHandle> Supervisor::CreateStem(bool supervisor_mode)
ss.pipe = std::make_unique<detail::PipePair>(FD_CLOEXEC, O_NONBLOCK, fds); ss.pipe = std::make_unique<detail::PipePair>(FD_CLOEXEC, O_NONBLOCK, fds);
ss.parent_pid = stem_ppid; ss.parent_pid = stem_ppid;
Stem stem{std::move(ss)}; Stem new_stem{std::move(ss)};
supervised_node = stem.Run(); supervised_node = new_stem.Run();
return {}; return {};
} }
@ -1195,8 +1195,8 @@ std::optional<SupervisorStemHandle> Supervisor::CreateStem(bool supervisor_mode)
if ( pid == 0 ) if ( pid == 0 )
{ {
Stem stem{std::move(ss)}; Stem new_stem{std::move(ss)};
supervised_node = stem.Run(); supervised_node = new_stem.Run();
return {}; return {};
} }