mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Fix a bunch of variable shadowing issues from LGTM
This commit is contained in:
parent
f8eb2d9241
commit
e8dbfc1cb0
10 changed files with 28 additions and 27 deletions
|
@ -388,10 +388,10 @@ void Attributes::CheckAttr(Attr* a)
|
|||
|
||||
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 ||
|
||||
a->Tag() == ATTR_EXPIRE_CREATE )
|
||||
if ( at->Tag() == ATTR_EXPIRE_READ || at->Tag() == ATTR_EXPIRE_WRITE ||
|
||||
at->Tag() == ATTR_EXPIRE_CREATE )
|
||||
num_expires++;
|
||||
}
|
||||
|
||||
|
|
|
@ -333,9 +333,10 @@ bool CompositeHash::RecoverOneVal(const HashKey& hk, Type* t, ValPtr* pval, bool
|
|||
{
|
||||
ValPtr v;
|
||||
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;
|
||||
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
|
||||
// get the error described.
|
||||
// NOLINTNEXTLINE(clang-analyzer-core.uninitialized.Branch)
|
||||
if ( ! (v || optional) )
|
||||
if ( ! (v || is_optional) )
|
||||
{
|
||||
reporter->InternalError(
|
||||
"didn't recover expected number of fields from HashKey");
|
||||
|
|
|
@ -256,8 +256,8 @@ ExprListStmt::ExprListStmt(StmtTag t, ListExprPtr arg_l) : Stmt(t), l(std::move(
|
|||
const ExprPList& e = l->Exprs();
|
||||
for ( const auto& expr : e )
|
||||
{
|
||||
const auto& t = expr->GetType();
|
||||
if ( ! t || t->Tag() == TYPE_VOID )
|
||||
const auto& et = expr->GetType();
|
||||
if ( ! et || et->Tag() == TYPE_VOID )
|
||||
Error("value of type void illegal");
|
||||
}
|
||||
|
||||
|
|
|
@ -1396,13 +1396,13 @@ TableVal::TableVal(TableTypePtr t, detail::AttributesPtr a) : Val(t)
|
|||
if ( ! run_state::is_parsing )
|
||||
return;
|
||||
|
||||
for ( const auto& t : table_type->GetIndexTypes() )
|
||||
for ( const auto& it : table_type->GetIndexTypes() )
|
||||
{
|
||||
std::set<RecordType*> found;
|
||||
std::set<const RecordType*> analyzed_records;
|
||||
// TODO: this likely doesn't have to be repeated for each new TableVal,
|
||||
// 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 )
|
||||
parse_time_table_record_dependencies[rt].emplace_back(NewRef{}, this);
|
||||
|
|
|
@ -94,11 +94,11 @@ bool PortmapperInterp::RPC_BuildReply(RPC_CallInfo* c, BifEnum::rpc_status statu
|
|||
case PMAPPROC_SET:
|
||||
if ( success )
|
||||
{
|
||||
uint32_t status = extract_XDR_uint32(buf, n);
|
||||
uint32_t proc_status = extract_XDR_uint32(buf, n);
|
||||
if ( ! buf )
|
||||
return false;
|
||||
|
||||
reply = val_mgr->Bool(status);
|
||||
reply = val_mgr->Bool(proc_status);
|
||||
event = pm_request_set;
|
||||
}
|
||||
else
|
||||
|
@ -109,11 +109,11 @@ bool PortmapperInterp::RPC_BuildReply(RPC_CallInfo* c, BifEnum::rpc_status statu
|
|||
case PMAPPROC_UNSET:
|
||||
if ( success )
|
||||
{
|
||||
uint32_t status = extract_XDR_uint32(buf, n);
|
||||
uint32_t proc_status = extract_XDR_uint32(buf, n);
|
||||
if ( ! buf )
|
||||
return false;
|
||||
|
||||
reply = val_mgr->Bool(status);
|
||||
reply = val_mgr->Bool(proc_status);
|
||||
event = pm_request_unset;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -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);
|
||||
std::string s(text, sqlite3_column_bytes(st, pos));
|
||||
int pos = s.find('/');
|
||||
int width = atoi(s.substr(pos + 1).c_str());
|
||||
std::string addr = s.substr(0, pos);
|
||||
size_t slash_pos = s.find('/');
|
||||
int width = atoi(s.substr(slash_pos + 1).c_str());
|
||||
std::string addr = s.substr(0, slash_pos);
|
||||
|
||||
val->val.subnet_val.prefix = io->ParseAddr(addr);
|
||||
val->val.subnet_val.length = width;
|
||||
|
|
|
@ -1209,9 +1209,9 @@ WriterFrontend* Manager::CreateWriter(EnumVal* id, EnumVal* writer, WriterBacken
|
|||
|
||||
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);
|
||||
winfo->interval = id->GetVal()->AsInterval();
|
||||
winfo->interval = interval->GetVal()->AsInterval();
|
||||
|
||||
if ( winfo->info->post_proc_func && strlen(winfo->info->post_proc_func) )
|
||||
{
|
||||
|
|
|
@ -1005,8 +1005,8 @@ StmtPtr CatchReturnStmt::DoReduce(Reducer* c)
|
|||
|
||||
if ( ret_e_dup->Tag() == EXPR_CONST )
|
||||
{
|
||||
auto c = ret_e_dup->AsConstExpr();
|
||||
rv_dup->AsNameExpr()->Id()->GetOptInfo()->SetConst(c);
|
||||
auto ce = ret_e_dup->AsConstExpr();
|
||||
rv_dup->AsNameExpr()->Id()->GetOptInfo()->SetConst(ce);
|
||||
}
|
||||
|
||||
return assign_stmt;
|
||||
|
|
|
@ -480,13 +480,13 @@ const ZAMStmt ZAMCompiler::ValueSwitch(const SwitchStmt* sw, const NameExpr* v,
|
|||
std::vector<InstLabel> case_start;
|
||||
|
||||
PushFallThroughs();
|
||||
for ( auto c : *cases )
|
||||
for ( auto sw_case : *cases )
|
||||
{
|
||||
auto start = GoToTargetBeyond(body_end);
|
||||
ResolveFallThroughs(start);
|
||||
case_start.push_back(start);
|
||||
PushFallThroughs();
|
||||
body_end = CompileStmt(c->Body());
|
||||
body_end = CompileStmt(sw_case->Body());
|
||||
}
|
||||
|
||||
auto sw_end = GoToTargetBeyond(body_end);
|
||||
|
|
|
@ -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.parent_pid = stem_ppid;
|
||||
|
||||
Stem stem{std::move(ss)};
|
||||
supervised_node = stem.Run();
|
||||
Stem new_stem{std::move(ss)};
|
||||
supervised_node = new_stem.Run();
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -1195,8 +1195,8 @@ std::optional<SupervisorStemHandle> Supervisor::CreateStem(bool supervisor_mode)
|
|||
|
||||
if ( pid == 0 )
|
||||
{
|
||||
Stem stem{std::move(ss)};
|
||||
supervised_node = stem.Run();
|
||||
Stem new_stem{std::move(ss)};
|
||||
supervised_node = new_stem.Run();
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue